Added get_mode to status_led class
This commit is contained in:
parent
86d2f8ea95
commit
2bb2c8c010
@ -55,6 +55,7 @@ where
|
||||
{
|
||||
ws2812_direct: Ws2812Direct<P, SM, I>,
|
||||
state: bool,
|
||||
mode: StatusMode,
|
||||
}
|
||||
|
||||
impl<P, SM, I> Ws2812StatusLed<P, SM, I>
|
||||
@ -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())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user