Skip to content

Commit 8aefa3b

Browse files
mark9064FintasticMan
authored andcommitted
Ignore old GoToRunning messages
1 parent 6c7eb66 commit 8aefa3b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/displayapp/DisplayApp.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,13 @@ void DisplayApp::Refresh() {
292292
switch (msg) {
293293
case Messages::GoToSleep:
294294
case Messages::GoToAOD:
295-
if (state != States::Running) {
295+
// Checking if SystemTask is sleeping is purely an optimisation.
296+
// If it's no longer sleeping since it sent GoToSleep, it has
297+
// cancelled the sleep and transitioned directly from
298+
// GoingToSleep->Running, so we are about to receive GoToRunning
299+
// and can ignore this message. If it wasn't ignored, DisplayApp
300+
// would go to sleep and then immediately re-wake
301+
if (state != States::Running || !systemTask->IsSleeping()) {
296302
break;
297303
}
298304
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Low) {
@@ -334,7 +340,10 @@ void DisplayApp::Refresh() {
334340
lv_disp_trig_activity(nullptr);
335341
break;
336342
case Messages::GoToRunning:
337-
if (state == States::Running) {
343+
// If SystemTask is sleeping, the GoToRunning message is old
344+
// and must be ignored. Otherwise DisplayApp will use SPI
345+
// that is powered down and cause bad behaviour
346+
if (state == States::Running || systemTask->IsSleeping()) {
338347
break;
339348
}
340349
if (state == States::AOD) {

0 commit comments

Comments
 (0)