From ef831a0b4d1a05298f01a55ebbe0e939c10ef5a6 Mon Sep 17 00:00:00 2001 From: geeksville Date: Sun, 17 May 2020 05:11:32 -0700 Subject: [PATCH] Fix leaving display on in deep sleep. We shutoff screen immediately, rather than waiting for our loop call() --- src/screen.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/screen.h b/src/screen.h index 634cdd10c..be5444c1e 100644 --- a/src/screen.h +++ b/src/screen.h @@ -100,7 +100,14 @@ class Screen : public PeriodicTask void setup(); /// Turns the screen on/off. - void setOn(bool on) { enqueueCmd(CmdItem{.cmd = on ? Cmd::SET_ON : Cmd::SET_OFF}); } + void setOn(bool on) + { + if (!on) + handleSetOn( + false); // We handle off commands immediately, because they might be called because the CPU is shutting down + else + enqueueCmd(CmdItem{.cmd = on ? Cmd::SET_ON : Cmd::SET_OFF}); + } /// Handles a button press. void onPress() { enqueueCmd(CmdItem{.cmd = Cmd::ON_PRESS}); }