Trait embedded_simple_ui::led::Led

source ·
pub trait Led<C: Clock> {
    // Required methods
    fn is_on(&mut self) -> bool;
    fn turn_on(&mut self);
    fn turn_off(&mut self);
    fn toggle(&mut self);
    fn set_effect(&mut self, effect: LedEffect<C>);
    fn set_effect_duration(&mut self, dur: Milliseconds<C::T>);
    fn get_effect(&self) -> Option<&LedEffect<C>>;
    fn clear_effect(&mut self);
    fn poll(&mut self, now: Instant<C>);
}
Expand description

UI LED

This LED abstraction tracks it’s status and provides an interface for setting visual effects such as blinking on the LED.

Implementors should own their resources TODO: implement ability to set the default state for the user

Required Methods§

source

fn is_on(&mut self) -> bool

source

fn turn_on(&mut self)

Turns on the LED

Has no effect if the LED is already turned on

source

fn turn_off(&mut self)

Turns off the LED

has no effect if the LED is already turned off

source

fn toggle(&mut self)

Toggles the led on/off

source

fn set_effect(&mut self, effect: LedEffect<C>)

Sets the effect on this LED instance

By default effect will have infinite duration unless set otherwise by set_effect_duration call

Setting the effect while another one is active will overwrite it on the next poll call

source

fn set_effect_duration(&mut self, dur: Milliseconds<C::T>)

Sets the current effect duration on this LED instance

Can be used to prolong current effect duration

Does nothing if no effect is currently in place

source

fn get_effect(&self) -> Option<&LedEffect<C>>

Returns the current LED effect

Returns None if no effect is in place

source

fn clear_effect(&mut self)

Clears current the effect

This should also revert the LED to the state it was in before the effect took place

source

fn poll(&mut self, now: Instant<C>)

Polls the LED, updating it’s state tracking and hardware state

This must be done in regular intervals in order to make this abstraction work properly. There might be limits on what this abstraction can track based on how small / large the intervals are.

Implementors§

source§

impl<P: StatefulOutputPin, C: Clock> Led<C> for PinLed<P, C>