diff --git a/rp2040/src/status_led.rs b/rp2040/src/status_led.rs index 1f5e03a..65f163f 100644 --- a/rp2040/src/status_led.rs +++ b/rp2040/src/status_led.rs @@ -55,6 +55,7 @@ where { ws2812_direct: Ws2812Direct, state: bool, + mode: StatusMode, } impl Ws2812StatusLed @@ -81,12 +82,19 @@ where // prepare the PIO program let ws2812_direct = Ws2812Direct::new(pin, pio, sm, clock_freq); let state = false; + let mode = StatusMode::Off; Self { ws2812_direct, state, + mode, } } + /// Get current status mode + pub fn get_mode(&self) -> StatusMode { + self.mode + } + /// Update status LED /// Depending on the mode, the LED will be set to a different colour /// @@ -110,6 +118,8 @@ where (0, 10, 10).into(), // Purple ]; + self.mode = mode; + if mode == StatusMode::Warning && !self.state { self.ws2812_direct .write([colors[mode as usize]].iter().copied())