diff --git a/rp2040/src/status_led.rs b/rp2040/src/status_led.rs index 65f163f..5108008 100644 --- a/rp2040/src/status_led.rs +++ b/rp2040/src/status_led.rs @@ -25,11 +25,14 @@ use ws2812_pio::Ws2812Direct; pub enum StatusMode { Off = 0, Normal = 1, - Activity = 2, - Other = 3, - Warning = 4, - Error = 5, - Bootloader = 6, + NormalFlash = 2, + Activity = 3, + ActivityFlash = 4, + Other = 5, + OtherFlash = 6, + Warning = 7, + Error = 8, + Bootloader = 9, } #[warn(dead_code)] @@ -108,24 +111,46 @@ where /// /// Make sure to call this function regularly to keep the LED flashing pub fn update(&mut self, mode: StatusMode) { - let colors: [RGB8; 7] = [ + let colors: [RGB8; 10] = [ (0, 0, 0).into(), // Off (10, 7, 0).into(), // Green + (10, 7, 0).into(), // Green (10, 4, 10).into(), // Blue + (10, 4, 10).into(), // Blue + (5, 10, 0).into(), // Orange (5, 10, 0).into(), // Orange (2, 20, 0).into(), // Red (2, 20, 0).into(), // Red (0, 10, 10).into(), // Purple ]; - self.mode = mode; + if mode == StatusMode::Warning + || mode == StatusMode::NormalFlash + || mode == StatusMode::ActivityFlash + || mode == StatusMode::OtherFlash + || mode != self.mode + { + self.mode = mode; + } else { + return; + } - if mode == StatusMode::Warning && !self.state { + if (mode == StatusMode::Warning + || mode == StatusMode::NormalFlash + || mode == StatusMode::ActivityFlash + || mode == StatusMode::OtherFlash) + && !self.state + { self.ws2812_direct .write([colors[mode as usize]].iter().copied()) .unwrap(); self.state = true; - } else if mode == StatusMode::Warning || mode == StatusMode::Off { + } else if mode == StatusMode::Warning + || mode == StatusMode::NormalFlash + || mode == StatusMode::ActivityFlash + || mode == StatusMode::OtherFlash + || mode == StatusMode::Off + { self.ws2812_direct .write([colors[0]].iter().copied()) .unwrap();