Skip to main content

rgb_sequencer/
command.rs

1//! Command-based control for sequencers.
2
3use crate::sequence::RgbSequence;
4use crate::time::TimeDuration;
5
6/// Actions for controlling sequencers.
7///
8/// Each variant corresponds to a method on `RgbSequencer`. Use with `SequencerCommand`
9/// for routing in multi-LED systems.
10#[derive(Debug, Clone)]
11pub enum SequencerAction<D: TimeDuration, const N: usize> {
12    /// Load sequence (transitions to `Loaded` state).
13    Load(RgbSequence<D, N>),
14    /// Start loaded sequence (requires `Loaded` state).
15    Start,
16    /// Stop and turn off LED (keeps sequence loaded).
17    Stop,
18    /// Pause at current color (requires `Running` state).
19    Pause,
20    /// Resume from pause with timing compensation.
21    Resume,
22    /// Restart from beginning (from `Running`, `Paused`, or `Complete`).
23    Restart,
24    /// Clear sequence and turn off LED.
25    Clear,
26    /// Set brightness multiplier (0.0-1.0, clamped).
27    SetBrightness(f32),
28}
29
30/// Command targeting a specific LED.
31#[derive(Debug, Clone)]
32pub struct SequencerCommand<Id, D: TimeDuration, const N: usize> {
33    /// LED identifier.
34    pub led_id: Id,
35    /// Action to execute.
36    pub action: SequencerAction<D, N>,
37}
38
39impl<Id, D: TimeDuration, const N: usize> SequencerCommand<Id, D, N> {
40    /// Creates command.
41    pub fn new(led_id: Id, action: SequencerAction<D, N>) -> Self {
42        Self { led_id, action }
43    }
44}