From 5f9ed820c138f1d6af87a5d200d9918ed4400a6e Mon Sep 17 00:00:00 2001 From: JerrySB03 Date: Tue, 21 Jan 2025 17:49:48 +0100 Subject: [PATCH] Feat: only certain commands wake up the device --- fl16-inputmodules/src/control.rs | 34 ++++++++++++++++++++++++++++++++ ledmatrix/src/main.rs | 10 ++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/fl16-inputmodules/src/control.rs b/fl16-inputmodules/src/control.rs index ed1fbd32..8e3ce2f5 100644 --- a/fl16-inputmodules/src/control.rs +++ b/fl16-inputmodules/src/control.rs @@ -214,6 +214,40 @@ pub enum Command { _Unknown, } +impl Command { + pub fn should_wake(&self) -> bool { + match self { + Self::SetBrightness(_) + | Self::Pattern(_) + | Self::Percentage(_) + | Self::SetAnimate(_) + | Self::Draw(_) + | Self::DrawGreyColBuffer + | Self::StartGame(_) + | Self::GameControl(_) + | Self::DisplayOn(_) + | Self::InvertScreen(_) + | Self::SetPixelColumn(_, _) + | Self::FlushFramebuffer + | Self::ScreenSaver(_) + | Self::SetFps(_) + | Self::SetPowerMode(_) + | Self::SetDebugMode(_) => true, + + #[cfg(feature = "ledmatrix")] + Self::Draw(_) | Self::SetPwmFreq(_) => true, + + #[cfg(feature = "c1minimal")] + Self::SetColor(_) => true, + + #[cfg(feature = "b1display")] + Self::SetText(_) => true, + + _ => false, + } + } +} + #[cfg(any(feature = "c1minimal", feature = "b1display"))] #[derive(Clone)] pub enum SimpleSleepState { diff --git a/ledmatrix/src/main.rs b/ledmatrix/src/main.rs index c4082c72..d0c42a68 100644 --- a/ledmatrix/src/main.rs +++ b/ledmatrix/src/main.rs @@ -449,9 +449,10 @@ fn main() -> ! { true, SleepReason::Command, ); - } else { + } else if command.should_wake() { // If already sleeping, wake up. - // This means every command will wake the device up. + // Only certain commnads should wake the device - for example + // StageGreyCol shouldn't // Much more convenient than having to send the wakeup commmand. sleep_reason = None; } @@ -493,8 +494,9 @@ fn main() -> ! { ) .unwrap(); // let _ = serial.write(text.as_bytes()); - - fill_grid_pixels(&state, &mut matrix); + if command.should_wake() { + fill_grid_pixels(&state, &mut matrix); + } } (None, _) => {} }