fix: V3 has white LED on GPIO35, not WS2812B on GPIO38
The Heltec V3 has a plain white LED on GPIO35 (simple GPIO, not addressable). Only the V4 has a WS2812B RGB LED on GPIO38. - Created driver/simple_led.rs for single-color GPIO LEDs - V3/V3-UART boards: SimpleLed on GPIO35 (white blink on RX/TX) - V4 board: unchanged (WS2812 on GPIO38, green/red colors) - nRF boards: unchanged (no LED, type LedDriver = ())
This commit is contained in:
1 parent
5ac4b73739
commit
019198b636
4 files changed
+46
-29
No files matched your search
+4
-1
@@ -1,5 +1,8 @@
|
||||
#[cfg(feature = "wio_tracker_l1")]
|
||||
pub mod sh1106;
|
||||
|
||||
#[cfg(any(feature = "heltec_v3", feature = "heltec_v3_uart", feature = "heltec_v4"))]
|
||||
#[cfg(any(feature = "heltec_v3", feature = "heltec_v3_uart"))]
|
||||
pub mod simple_led;
|
||||
|
||||
#[cfg(feature = "heltec_v4")]
|
||||
pub mod ws2812;
|
||||
@@ -0,0 +1,28 @@
|
||||
//! 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