![]() |
HitLib 1.5.0
VEX V5 LED animation library for PROS
|
The profile system lets you define named animation modes with a priority level, then activate and deactivate them at runtime. The highest-priority currently-active mode wins and drives the strand.
Three ready-made profiles are available in hitlib/profiles/classic.hpp.
| Mode | Classic | Modern | Showy |
|---|---|---|---|
| Showoff | 0 rainbow | 0 rainbow | not in this profile |
| Idle | 1 magenta flow | 1 pink pulse | 0 purple flow |
| Alliance Red | 2 red pulse | 2 red pulse + orange bg | 1 white pulse / red bg |
| Alliance Blue | 3 blue pulse | 3 blue pulse + cyan bg | 2 white pulse / blue bg |
| Scoring | 4 green pulse | 4 green flash | 3 teal pulse |
| Matchloading | 5 yellow pulse | 5 yellow pulse | not in this profile |
| Endgame | 6 warn -> white -> cycle | 6 solid green -> pulse | 4 yellow -> rainbow |
Classic and Modern have seven modes each and share their numbering. Showy has five, so its indices are its own: no Showoff or Matchloading, and Endgame is 4, not 6. activateMode() takes a raw index into the profile's mode array, so activateMode(6) against Showy is out of range and simply never wins.
Pattern Studio writes the three steps above for you, and can put the result straight into your project.
Show it your PROS or VEXcode project once - Export > Choose Robot Project..., or drag the project folder onto the window - and Deploy writes include/hitlib_studio.hpp (hitlib_studio.h for VEXcode) every time you click it. Re-deploying overwrites that one file, so changing a port or adding a mode is: click Deploy, rebuild.
begin() registers every strand in the design, starts its refresh task at the design's interval, attaches each profile and activates each strand's first mode. A second call does nothing, so a routine that re-runs its own init is safe.
The exported file opens with this same snippet as a comment, filled in with your design's real identifiers and mode names.
A VEXcode project gets the same file for VEXcode's C++11 compiler. The snippet uses the competition template's functions, and everything you call is spelled the same. The header is hitlib_studio.h, since VEXcode Pro V5 only shows .h headers in its file tree:
C++11 has no inline variables, so inside the file each shared object is a static member of a small class template, with a reference of the usual name bound to it:
That keeps one strand however many files include the header. Use strand; strand_ is only where it lives.
Deploy picks the form from the project it writes into. File and clipboard exports use Export > Target Platform, which follows the last project you chose.
Each strand gets its own namespace under hitlib::profiles:
The constexpr hardware values are why the strand on the robot matches the one in the preview: the port, length and refresh interval come from the design rather than being retyped. strand is an ordinary hitlib::LedStrand built from those constants - every API call still works on it directly. The mode:: constants replace counting rows in modeTable to work out what index activateMode() wants.
The strand and the group are optional. Two ways to opt out, each one line:
puts the design's strands into a group you already own and attaches their profiles, leaving init(), start() and the refresh interval to you. Or:
and the file defines no strands and no group - only the profile and the constants:
One deployed header per project: it defines hitlib::studio, so two in one build would define begin() twice. Keep every strand in one document, which is what Deploy exports.
Deploy writes the whole document, so multi-strand designs need nothing extra. Two separately exported headers can collide: if both have an Idle mode, each defines its own setup function for it and they cannot share a .cpp.
Strands designed at different refresh intervals get a group each, since a group ticks everything it owns at one rate. begin() handles that; it is still one call.
Strand names become namespace names, so each strand needs a distinct one. Pattern Studio blocks the export until they are unique.
Export > Export Current Strand as C++... and Export All Strands as C++... still save through a normal file dialog, for a project Pattern Studio cannot see or a header you want to check in by hand. The generated code is identical.
hitlib::Sequencer drives multi-phase endgame / event sequences inside onActivate and onTick profile callbacks.
Phases loop indefinitely until the mode is deactivated.
One Sequencer can run on several strands at once, each at its own phase, so a profile attached to a whole group (group.attachProfile(), or a generated apply(group)) sequences every strand in it. It keeps track of up to Sequencer::MAX_STRANDS (8) strands; starting it on a ninth takes over from the strand that has gone longest without an update(), normally one whose mode has since been replaced. stop() stops it everywhere and stop(strand) on one strand.