Skip to content
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
10 changes: 10 additions & 0 deletions Code/PocketMageOS/src/UTILS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,16 @@ void checkTimeout() {
if (PWR_BTN_event && CurrentHOMEState != NOWLATER) {
PWR_BTN_event = false;
ESP_LOGE(TAG, "Power Button Event: Sleeping now");
// Fix #271: Clear pending key events so KB_IRQ can deassert before deep sleep.
while (KB().updateKeypress() != 0) {}
delay(50);
pocketmage::deepSleep();

} else if (PWR_BTN_event && CurrentHOMEState == NOWLATER) {
ESP_LOGE(TAG, "Power Button Event: powering off from NOWLATER");
PWR_BTN_event = false;
while (KB().updateKeypress() != 0) {}
delay(50);
pocketmage::deepSleep();
}
}
Expand Down Expand Up @@ -153,6 +158,9 @@ void checkTimeout() {

} else {
ESP_LOGD(TAG, "Not charging");
// Fix #271: Clear pending key events so KB_IRQ can deassert before deep sleep.
while (KB().updateKeypress() != 0) {}
delay(50);
switch (CurrentAppState) {
case TXT:
if (SLEEPMODE == "TEXT" && PM_SDAUTO().getEditingFile() != "") {
Expand Down Expand Up @@ -184,6 +192,8 @@ void checkTimeout() {
} else if (PWR_BTN_event && CurrentHOMEState == NOWLATER) {
ESP_LOGE(TAG, "Power Button Event: powering off from NOWLATER");
PWR_BTN_event = false;
while (KB().updateKeypress() != 0) {}
delay(50);
pocketmage::deepSleep();
}
}
Expand Down
Loading