pub struct LedEngine { /* private fields */ }Expand description
LED sequence engine.
Implementations§
Source§impl LedEngine
impl LedEngine
Sourcepub fn new(timings: LedTimings, start_ms: u64) -> Self
pub fn new(timings: LedTimings, start_ms: u64) -> Self
Create a new engine anchored at start_ms. The first heartbeat
pulse begins at start_ms.
Sourcepub fn attention_only(start_ms: u64) -> Self
pub fn attention_only(start_ms: u64) -> Self
An engine for an indicator that idles dark: no heartbeat, only the locate alert and one-shot sequences.
For a board with two LEDs, where one carries the “this board is alive and here is its link state” story and the other is reserved for the things meant to catch an eye. A second heartbeat would only compete with the first.
Implemented as a zero-length heartbeat pulse, which
heartbeat_decision resolves to
permanently off. The interval then only sets how often the loop
wakes to find nothing to do, so it is long.
Sourcepub fn start_alert(&mut self, now_ms: u64)
pub fn start_alert(&mut self, now_ms: u64)
Start the locate alert. Idempotent: re-starting a running alert keeps its existing rhythm rather than restarting the blink, so a host re-arming the deadline does not produce a visible stutter.
Sourcepub fn stop_alert(&mut self)
pub fn stop_alert(&mut self)
Stop the locate alert, returning the LED to sequences and the heartbeat.
Sourcepub fn alert_active(&self) -> bool
pub fn alert_active(&self) -> bool
Whether the locate alert is running.
Sourcepub fn play(&mut self, seq: LedSequence, now_ms: u64)
pub fn play(&mut self, seq: LedSequence, now_ms: u64)
Start a one-shot sequence, preempting any currently active sequence and any in-progress heartbeat pulse.
Sourcepub fn tick(&mut self, now_ms: u64) -> LedDecision
pub fn tick(&mut self, now_ms: u64) -> LedDecision
Compute the LED state to apply at now_ms and the next deadline.