Expand description
A device abstraction for a single digital LED with animation support.
Use the led! macro to generate one or more concrete LED
device types.
See LedGenerated for a sample generated type.
§Example
use device_envoy_esp::{
Result,
init_and_start,
led,
led::{Led as _, LedLevel, OnLevel},
};
use embassy_time::Duration;
led! {
pub LedOne {
pin: GPIO2
}
}
led! {
pub LedTwo {
pin: GPIO3,
max_steps: 2
}
}
async fn example(spawner: embassy_executor::Spawner) -> Result<()> {
init_and_start!(p);
let led_one = LedOne::new(p.GPIO2, OnLevel::High, spawner)?;
let led_two = LedTwo::new(p.GPIO3, OnLevel::High, spawner)?;
led_one.set_level(LedLevel::On);
led_two.set_level(LedLevel::Off);
embassy_time::Timer::after(Duration::from_millis(250)).await;
led_one.animate([
(LedLevel::On, Duration::from_millis(200)),
(LedLevel::Off, Duration::from_millis(200)),
]);
led_two.animate([
(LedLevel::Off, Duration::from_millis(150)),
(LedLevel::On, Duration::from_millis(150)),
]);
core::future::pending().await
}Modules§
- led_
generated - Module containing a sample struct type generated by the
led!macro:LedGenerated.
Macros§
- led
- Macro to generate a single LED struct type (includes syntax details).
Enums§
Traits§
- Led
- Platform-agnostic single LED device contract.