LedEngine

Struct LedEngine 

Source
pub struct LedEngine { /* private fields */ }
Expand description

LED sequence engine.

Implementations§

Source§

impl LedEngine

Source

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.

Source

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.

Source

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.

Source

pub fn stop_alert(&mut self)

Stop the locate alert, returning the LED to sequences and the heartbeat.

Source

pub fn alert_active(&self) -> bool

Whether the locate alert is running.

Source

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.

Source

pub fn tick(&mut self, now_ms: u64) -> LedDecision

Compute the LED state to apply at now_ms and the next deadline.

Trait Implementations§

Source§

impl Debug for LedEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.