Fix leaving display on in deep sleep.

We shutoff screen immediately, rather than waiting for our loop call()
This commit is contained in:
geeksville 2020-05-17 05:11:32 -07:00
parent efc239533c
commit ef831a0b4d

View File

@ -100,7 +100,14 @@ class Screen : public PeriodicTask
void setup(); void setup();
/// Turns the screen on/off. /// 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. /// Handles a button press.
void onPress() { enqueueCmd(CmdItem{.cmd = Cmd::ON_PRESS}); } void onPress() { enqueueCmd(CmdItem{.cmd = Cmd::ON_PRESS}); }