![]() |
HitLib 1.5.0
VEX V5 LED animation library for PROS
|
Forward declaration. More...
#include <led_sequencer.hpp>
Classes | |
| struct | Phase |
| One phase in the animation sequence. More... | |
Public Member Functions | |
| constexpr | Sequencer (const Phase *phases, uint8_t count) |
| Construct a Sequencer from a static phase array. | |
| void | start (LedStrand &strand) |
Start the sequence on strand from phase 0. | |
| void | stop () |
| Stop the sequence on every strand without advancing. | |
| void | stop (const LedStrand &strand) |
Stop the sequence on strand only. See stop(). | |
| void | update (LedStrand &strand) |
Advance the sequence, call every tick from an onTick callback. | |
| bool | isRunning () const |
Returns true if the sequence is running on any strand. | |
| bool | isRunning (const LedStrand &strand) const |
Returns true if the sequence is running on strand. | |
Static Public Attributes | |
| static constexpr uint8_t | MAX_STRANDS |
| Strands one Sequencer can run on at the same time. | |
Forward declaration.
Drives a looping sequence of timed animation phases on a LedStrand.
A Sequencer holds a pointer to a statically-allocated array of Phase descriptors, and keeps each strand's place in it separately: one Sequencer can run on several strands at once, each at its own phase. That is what a profile attached to a whole LedGroup needs, since every strand in the group calls the same onActivate and onTick, and so the same Sequencer. Up to MAX_STRANDS strands can run at a time; see start() for what happens past that.
|
inlineconstexpr |
| void hitlib::Sequencer::start | ( | LedStrand & | strand | ) |
Start the sequence on strand from phase 0.
Calls phases[0].startFn(strand) immediately. Typically called from a ProfileMode onActivate callback. Restarts strand's run if it already has one, and leaves every other strand's alone.
With MAX_STRANDS strands already running, the one that has gone longest without an update() - normally one whose mode has since been replaced - gives its place up to strand, and stops.
| strand | The strand to animate. |
| void hitlib::Sequencer::stop | ( | ) |
Stop the sequence on every strand without advancing.
The strands' animations are not changed, they simply stop being updated.
| void hitlib::Sequencer::stop | ( | const LedStrand & | strand | ) |
Stop the sequence on strand only. See stop().
| void hitlib::Sequencer::update | ( | LedStrand & | strand | ) |
Advance the sequence, call every tick from an onTick callback.
Checks whether strand's current phase has expired. If so, advances it to the next phase (wrapping to 0) and calls that phase's startFn. Does nothing if the sequence is not running on strand.
| strand | The strand to animate. |
| bool hitlib::Sequencer::isRunning | ( | ) | const |
Returns true if the sequence is running on any strand.
| bool hitlib::Sequencer::isRunning | ( | const LedStrand & | strand | ) | const |
Returns true if the sequence is running on strand.
|
staticconstexpr |
Strands one Sequencer can run on at the same time.