Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: only certain commands wake up the device #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions fl16-inputmodules/src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 6 additions & 4 deletions ledmatrix/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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, _) => {}
}
Expand Down