HitLib 1.3.0
VEX V5 LED animation library for PROS
Loading...
Searching...
No Matches
led_sequencer.hpp
Go to the documentation of this file.
1#pragma once
2#include <cstdint>
3
8
9namespace hitlib {
10
11class LedStrand;
12
13// ============================================================================
14
46class Sequencer {
47public:
48 // ------------------------------------------------------------------------
49
53 struct Phase {
54 uint32_t durationMs;
55 void (*startFn)(LedStrand&);
56 };
57
58 // ------------------------------------------------------------------------
59
67 constexpr Sequencer(const Phase* phases, uint8_t count)
68 : phases(phases), phaseCount(count) {}
69
70 // ------------------------------------------------------------------------
71
80 void start(LedStrand& strand);
81
87 void stop();
88
98 void update(LedStrand& strand);
99
103 bool isRunning() const { return running; }
104
105private:
106 const Phase* phases;
107 uint8_t phaseCount;
108 uint8_t currentPhase = 0;
109 uint32_t phaseStartMs = 0;
110 bool running = false;
111};
112
113} // namespace hitlib
Driver for a single WS2812B-compatible LED strip on a VEX ADI port.
Definition led_strand.hpp:53
void stop()
Stop the sequence without advancing.
bool isRunning() const
Returns true if the sequence is currently running.
Definition led_sequencer.hpp:103
void update(LedStrand &strand)
Advance the sequence, call every tick from an onTick callback.
void start(LedStrand &strand)
Start the sequence from phase 0.
constexpr Sequencer(const Phase *phases, uint8_t count)
Construct a Sequencer from a static phase array.
Definition led_sequencer.hpp:67
Definition led_group.hpp:11
One phase in the animation sequence.
Definition led_sequencer.hpp:53
void(* startFn)(LedStrand &)
Called once when the phase begins.
Definition led_sequencer.hpp:55
uint32_t durationMs
How long this phase runs (milliseconds).
Definition led_sequencer.hpp:54