Skip to main content

Led

Trait Led 

Source
pub trait Led {
    // Required methods
    fn on(&mut self);
    fn off(&mut self);

    // Provided method
    fn set(&mut self, on: bool) { ... }
}
Expand description

LED control trait.

Three methods: turn on, turn off, set explicitly. The third one has a default impl in terms of the first two so backends only need to implement Self::on and Self::off. Everything fancier (blink, pulse, fade) is composed on top by reading the LED pattern out of the crate::state_machine::TokenState and calling Self::set at the right cadence.

Required Methods§

Source

fn on(&mut self)

Turn the LED on (drive the GPIO high on active-high wiring).

Source

fn off(&mut self)

Turn the LED off.

Provided Methods§

Source

fn set(&mut self, on: bool)

Convenience: set the LED to a specific level. Default impl dispatches to Self::on or Self::off.

Implementors§