Skip to content
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to explicitly list the ones that shouldn't. StageGreyCol makes sense, what else?

}
}
}

#[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