fix: Wio Tracker LED on P1.01, move SimpleLed to board layer
Per the Wio Tracker L1 schematic, it has a green LED on P1.01. Moved SimpleLed from driver/ to board layer (esp32s3.rs and wio_tracker_l1.rs) since the impl needs HAL-specific Output types. Removed driver/simple_led.rs — each board layer defines its own. RAK WisBlock remains LedDriver=() (no user LED on the core module).
This commit is contained in:
1 parent
3bb41da223
commit
f9117d71c8
7 files changed
+43
-41
No files matched your search
@@ -18,6 +18,20 @@ 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>;
|
||||
|
||||
@@ -11,7 +11,7 @@ use static_cell::StaticCell;
|
||||
|
||||
use super::esp32s3;
|
||||
use super::traits::{BoardParts, LoRaBoard};
|
||||
use crate::driver::simple_led::SimpleLed;
|
||||
use super::esp32s3::SimpleLed;
|
||||
use crate::hal::esp32s3 as mcu;
|
||||
|
||||
pub use super::esp32s3::{
|
||||
@@ -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::new(led_pin));
|
||||
let led = Some(SimpleLed(led_pin));
|
||||
|
||||
BoardParts {
|
||||
radio,
|
||||
|
||||
@@ -10,7 +10,7 @@ use esp_hal::gpio::{Level, Output, OutputConfig};
|
||||
|
||||
use super::esp32s3;
|
||||
use super::traits::{BoardParts, LoRaBoard};
|
||||
use crate::driver::simple_led::SimpleLed;
|
||||
use super::esp32s3::SimpleLed;
|
||||
use crate::hal::esp32s3 as mcu;
|
||||
|
||||
pub use super::esp32s3::{
|
||||
@@ -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::new(led_pin));
|
||||
let led = Some(SimpleLed(led_pin));
|
||||
|
||||
BoardParts {
|
||||
radio,
|
||||
|
||||
@@ -3,7 +3,7 @@ use static_cell::StaticCell;
|
||||
|
||||
use super::esp32s3;
|
||||
use super::traits::{BoardParts, LoRaBoard};
|
||||
use crate::driver::simple_led::SimpleLed;
|
||||
use super::esp32s3::SimpleLed;
|
||||
use crate::hal::esp32s3 as mcu;
|
||||
|
||||
pub use super::esp32s3::{
|
||||
@@ -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::new(led_pin));
|
||||
let led = Some(SimpleLed(led_pin));
|
||||
|
||||
BoardParts {
|
||||
radio,
|
||||
|
||||
@@ -20,7 +20,22 @@ type RadioSpiDevice = SpiDevice<'static, NoopRawMutex, mcu::SpiBus, Nss>;
|
||||
pub type RadioDriver = Sx126x<RadioSpiDevice, Iv, Sx1262>;
|
||||
pub type UsbDriver = mcu::UsbNrfDriver;
|
||||
pub type DisplayI2c = mcu::I2cBus;
|
||||
pub type LedDriver = ();
|
||||
|
||||
// ── 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 DisplayDriver = crate::driver::sh1106::Sh1106<DisplayI2c>;
|
||||
|
||||
@@ -67,7 +82,7 @@ impl LoRaBoard for Board {
|
||||
type CommParts = UsbParts;
|
||||
type DisplayParts = DisplayParts;
|
||||
type DisplayDriver = DisplayDriver;
|
||||
type LedDriver = ();
|
||||
type LedDriver = LedDriver;
|
||||
|
||||
fn init() -> Self {
|
||||
let mut config = embassy_nrf::config::Config::default();
|
||||
@@ -81,7 +96,7 @@ impl LoRaBoard for Board {
|
||||
mcu::mac_address()
|
||||
}
|
||||
|
||||
fn into_parts(self) -> BoardParts<RadioParts, UsbParts, DisplayParts, ()> {
|
||||
fn into_parts(self) -> BoardParts<RadioParts, UsbParts, DisplayParts, LedDriver> {
|
||||
let p = self.p;
|
||||
|
||||
// ── SPI bus for SX1262 ──────────────────────────────────
|
||||
@@ -131,11 +146,15 @@ impl LoRaBoard for Board {
|
||||
);
|
||||
let display = Some(DisplayParts { i2c });
|
||||
|
||||
// Green LED on P1.01
|
||||
let led_pin = Output::new(p.P1_01, Level::Low, OutputDrive::Standard);
|
||||
let led = Some(SimpleLed(led_pin));
|
||||
|
||||
BoardParts {
|
||||
radio,
|
||||
host,
|
||||
display,
|
||||
led: None,
|
||||
led,
|
||||
mac: Self::mac_address(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
#[cfg(feature = "wio_tracker_l1")]
|
||||
pub mod sh1106;
|
||||
|
||||
#[cfg(any(feature = "heltec_v3", feature = "heltec_v3_uart", feature = "heltec_v4"))]
|
||||
pub mod simple_led;
|
||||
@@ -1,28 +0,0 @@
|
||||
//! Simple single-color LED driver (GPIO on/off).
|
||||
//!
|
||||
//! For boards with a plain LED (not addressable RGB). Any non-zero
|
||||
//! RGB value turns the LED on; all zeros turns it off.
|
||||
|
||||
use esp_hal::gpio::Output;
|
||||
|
||||
use crate::board::RgbLed;
|
||||
|
||||
pub struct SimpleLed {
|
||||
pin: Output<'static>,
|
||||
}
|
||||
|
||||
impl SimpleLed {
|
||||
pub fn new(pin: Output<'static>) -> Self {
|
||||
Self { pin }
|
||||
}
|
||||
}
|
||||
|
||||
impl RgbLed for SimpleLed {
|
||||
async fn set_rgb(&mut self, r: u8, g: u8, b: u8) {
|
||||
if r > 0 || g > 0 || b > 0 {
|
||||
self.pin.set_high();
|
||||
} else {
|
||||
self.pin.set_low();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user