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
This commit is contained in:
swaits committed 2026-04-07 12:40:55 -06:00
1 parent f9117d71c8
commit 41b5775268
12 files changed
+50 -59

No files matched your search

-14
View File
@@ -18,20 +18,6 @@ use crate::hal::esp32s3 as mcu;
pub use mcu::{I2cBus as DisplayI2c, SpiBus};
// ── LED driver ──────────────────────────────────────────────────────
pub struct SimpleLed(pub Output<'static>);
impl super::traits::RgbLed for SimpleLed {
async fn set_rgb(&mut self, r: u8, g: u8, b: u8) {
if r > 0 || g > 0 || b > 0 {
self.0.set_high();
} else {
self.0.set_low();
}
}
}
// ── Concrete peripheral types ───────────────────────────────────────
type Nss = Output<'static>;
+3 -3
View File
@@ -11,7 +11,7 @@ use static_cell::StaticCell;
use super::esp32s3;
use super::traits::{BoardParts, LoRaBoard};
use super::esp32s3::SimpleLed;
use crate::driver::simple_led::SimpleLed;
use crate::hal::esp32s3 as mcu;
pub use super::esp32s3::{
@@ -19,7 +19,7 @@ pub use super::esp32s3::{
};
pub type UsbDriver = esp_hal::otg_fs::asynch::Driver<'static>;
pub type LedDriver = SimpleLed;
pub type LedDriver = SimpleLed<Output<'static>>;
pub struct UsbParts {
pub driver: UsbDriver,
@@ -84,7 +84,7 @@ impl LoRaBoard for Board {
// White LED on GPIO35
let led_pin = Output::new(p.GPIO35, Level::Low, OutputConfig::default());
let led = Some(SimpleLed(led_pin));
let led = SimpleLed(led_pin);
BoardParts {
radio,
+3 -3
View File
@@ -10,7 +10,7 @@ use esp_hal::gpio::{Level, Output, OutputConfig};
use super::esp32s3;
use super::traits::{BoardParts, LoRaBoard};
use super::esp32s3::SimpleLed;
use crate::driver::simple_led::SimpleLed;
use crate::hal::esp32s3 as mcu;
pub use super::esp32s3::{
@@ -18,7 +18,7 @@ pub use super::esp32s3::{
};
pub type UartDriver = esp_hal::uart::Uart<'static, esp_hal::Async>;
pub type LedDriver = SimpleLed;
pub type LedDriver = SimpleLed<Output<'static>>;
pub struct UartParts {
pub driver: UartDriver,
@@ -80,7 +80,7 @@ impl LoRaBoard for Board {
// White LED on GPIO35
let led_pin = Output::new(p.GPIO35, Level::Low, OutputConfig::default());
let led = Some(SimpleLed(led_pin));
let led = SimpleLed(led_pin);
BoardParts {
radio,
+3 -3
View File
@@ -3,7 +3,7 @@ use static_cell::StaticCell;
use super::esp32s3;
use super::traits::{BoardParts, LoRaBoard};
use super::esp32s3::SimpleLed;
use crate::driver::simple_led::SimpleLed;
use crate::hal::esp32s3 as mcu;
pub use super::esp32s3::{
@@ -12,7 +12,7 @@ pub use super::esp32s3::{
pub type UsbDriver = esp_hal::otg_fs::asynch::Driver<'static>;
pub type LedDriver = SimpleLed;
pub type LedDriver = SimpleLed<Output<'static>>;
pub struct UsbParts {
pub driver: UsbDriver,
@@ -77,7 +77,7 @@ impl LoRaBoard for Board {
// Orange LED on GPIO35
let led_pin = Output::new(p.GPIO35, Level::Low, OutputConfig::default());
let led = Some(SimpleLed(led_pin));
let led = SimpleLed(led_pin);
BoardParts {
radio,
+1 -1
View File
@@ -137,7 +137,7 @@ impl LoRaBoard for Board {
radio,
host,
display,
led: None,
led: (),
mac: Self::mac_address(),
}
}
+1 -1
View File
@@ -56,6 +56,6 @@ pub struct BoardParts<R, C, D, L> {
pub radio: R,
pub host: C,
pub display: Option<D>,
pub led: Option<L>,
pub led: L,
pub mac: [u8; 6],
}
+2 -16
View File
@@ -21,21 +21,7 @@ pub type RadioDriver = Sx126x<RadioSpiDevice, Iv, Sx1262>;
pub type UsbDriver = mcu::UsbNrfDriver;
pub type DisplayI2c = mcu::I2cBus;
// ── LED driver (green LED on P1.01) ─────────────────────────────────
pub struct SimpleLed(pub Output<'static>);
impl super::traits::RgbLed for SimpleLed {
async fn set_rgb(&mut self, r: u8, g: u8, b: u8) {
if r > 0 || g > 0 || b > 0 {
self.0.set_high();
} else {
self.0.set_low();
}
}
}
pub type LedDriver = SimpleLed;
pub type LedDriver = crate::driver::simple_led::SimpleLed<Output<'static>>;
pub type DisplayDriver = crate::driver::sh1106::Sh1106<DisplayI2c>;
@@ -148,7 +134,7 @@ impl LoRaBoard for Board {
// Green LED on P1.01
let led_pin = Output::new(p.P1_01, Level::Low, OutputDrive::Standard);
let led = Some(SimpleLed(led_pin));
let led = crate::driver::simple_led::SimpleLed(led_pin);
BoardParts {
radio,