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

Ignore old GoToRunning messages #2165

Merged
merged 1 commit into from
Nov 17, 2024
Merged
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
13 changes: 11 additions & 2 deletions src/displayapp/DisplayApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,13 @@ void DisplayApp::Refresh() {
switch (msg) {
case Messages::GoToSleep:
case Messages::GoToAOD:
if (state != States::Running) {
// Checking if SystemTask is sleeping is purely an optimisation.
// If it's no longer sleeping since it sent GoToSleep, it has
// cancelled the sleep and transitioned directly from
// GoingToSleep->Running, so we are about to receive GoToRunning
// and can ignore this message. If it wasn't ignored, DisplayApp
// would go to sleep and then immediately re-wake
if (state != States::Running || !systemTask->IsSleeping()) {
break;
}
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Low) {
Expand Down Expand Up @@ -334,7 +340,10 @@ void DisplayApp::Refresh() {
lv_disp_trig_activity(nullptr);
break;
case Messages::GoToRunning:
if (state == States::Running) {
// If SystemTask is sleeping, the GoToRunning message is old
// and must be ignored. Otherwise DisplayApp will use SPI
// that is powered down and cause bad behaviour
if (state == States::Running || systemTask->IsSleeping()) {
break;
}
if (state == States::AOD) {
Expand Down
Loading