Skip to content

ItzSt0rmz/StormLib

Repository files navigation

Intro

StormLib is a template built for PROS 4 that includes LED control and an auton selector. For installation details, see the Releases page.

Have any questions or feature requests, join the discord: https://discord.gg/vTmMG3dAX6

LEDs

LED example

Hardware

Note: You will need to be able to solder to make LED strips work with the brain.

To physically make an LED strand, you need a ws2812b LED strip. Ideally, it should be the 3.2 ft / 144 LEDs version. I have found succes with these.

Once you have a roll of LEDs, you will clip the size you want (must be less than 64 pixels), then solder it to a vex 3-wire cable according to the following diagram:

LEDwiringdiagram Credit: Sylvie

Note

If you don't want to solder the LEDs yourself, you can order them from the_storm_cloud on Discord.

Software

LEDs are constructed as:
stormlib::aRGB name(adiPort, length);

Then fed into the manager, constructed as:
stormlib::aRGB_manager LEDmanager( &name, &strand2, &strand3, nullptr, nullptr, nullptr, nullptr, nullptr );

Finally, to initalize your LEDs, run LEDmanager.initialize(int refreshRate); in initialize(). The refresh rate of the leds can now be modified in this function, but the default is 20. In general, lower is better looking, but uses more resources.

Now, individual strands or the manager as a whole can take the following commands:

  • set_color(uint32_t color) - sets the strand(s) a color
  • flow(uint32_t color1, uint32_t color2, int speed) - sets the strand(s) to cycle a gradient between two colors
  • rainbow(int speed) - sets the strand(s) to cycle a rainbow
  • flash(uint32_t color1, int speed, uint32_t color2) - sets the strand(s) to flash a color or flash between two colors
  • pulse(uint32_t color, int length, int speed, uint32_t color2) - sends a pulse down the strand(s)
  • off() - turns off the strand(s)

Auton Selector

auton selector example

The auton selector is constructed as:
stormlib::selector autonSelector(stormlib::selector::E_BLUE_RIGHT_4, "slot1Name", "slot2Name", "slot3Name", "slot4Name");

Then, to initalize it, run autonSelector.initialize(); in initialize()

In autonomous(), autons are assigned to slots as following:
if (autonSelector.getAuton() == ENUMERATED SLOT VALUE) {function here}

A default auton can be set using the form:
if (autonSelector.getAuton() == 0) {function here};

Clock

A clock is initialized as:
stormlib::clock driverClock;

Then, to start it, run driverClock.start(time_in_seconds * 100); It is default 1:45 (i.e. opcontrol period) if you leave the parameter blank.

Once the clock is started, you can now access how much time is left via:

driverClock.timeLeft()

Or delay until a certain time, which is useful for tasks dependent on the game clock:

driverClock.waitUntil(time_in_seconds * 1000);

Contributing

If you want to see a feature, feel free to open a pull request!

About

A VEX library for LEDs, a customizable auton selector, and other utilities designed for PROS 4

Resources

License

Stars

Watchers

Forks

Contributors