Files
firmware/src/driver/simple_led.rs
T
swaits 41b5775268 refactor: unify SimpleLed via embedded-hal, remove Option<L> from BoardParts
- Added embedded-hal 1.0 as direct dep (already transitive via embedded-hal-async)
- SimpleLed<P: OutputPin> now generic over any HAL — single definition in driver/
- Removed duplicate SimpleLed from board/esp32s3.rs and board/wio_tracker_l1.rs
- Changed BoardParts.led from Option<L> to L — boards with no LED use ()
- Display task calls led.set_rgb() unconditionally (no-op for () boards)
- RAK board: led: () instead of led: None
2026-04-07 12:40:55 -06:00

21 lines
506 B
Rust

//! Simple single-color LED driver (GPIO on/off).
//!
//! Generic over any `OutputPin`. Any non-zero RGB value turns the LED on;
//! all zeros turns it off.
use embedded_hal::digital::OutputPin;
use crate::board::RgbLed;
pub struct SimpleLed<P>(pub P);
impl<P: OutputPin> RgbLed for SimpleLed<P> {
async fn set_rgb(&mut self, r: u8, g: u8, b: u8) {
if r > 0 || g > 0 || b > 0 {
let _ = self.0.set_high();
} else {
let _ = self.0.set_low();
}
}
}