We may have RAK modules in Slot D pulling IO5 to Low permanently (like the RAK12002 RTC Module). React to assumed Long presses of the device button only 30 seconds after bootup to prevent a reboot loop. This is Particularly important for button-less RAK19003 Baseboard.

This commit is contained in:
Thomas Göttgens 2022-04-27 11:02:45 +02:00
parent a0f34a8d0a
commit 3a9086dfc5

View File

@ -135,7 +135,7 @@ class ButtonThread : public concurrency::OSThread
screen->adjustBrightness(); screen->adjustBrightness();
#endif #endif
// If user button is held down for 5 seconds, shutdown the device. // If user button is held down for 5 seconds, shutdown the device.
if (millis() - longPressTime > 5 * 1000) { if ((millis() - longPressTime > 5 * 1000) && (longPressTime > 0)) {
#ifdef TBEAM_V10 #ifdef TBEAM_V10
if (axp192_found == true) { if (axp192_found == true) {
setLed(false); setLed(false);
@ -144,7 +144,7 @@ class ButtonThread : public concurrency::OSThread
#elif NRF52_SERIES #elif NRF52_SERIES
// Do actual shutdown when button released, otherwise the button release // Do actual shutdown when button released, otherwise the button release
// may wake the board immediatedly. // may wake the board immediatedly.
if (!shutdown_on_long_stop) { if ((!shutdown_on_long_stop) && (millis() > 30 * 1000)) {
screen->startShutdownScreen(); screen->startShutdownScreen();
DEBUG_MSG("Shutdown from long press"); DEBUG_MSG("Shutdown from long press");
playBeep(); playBeep();
@ -180,12 +180,15 @@ class ButtonThread : public concurrency::OSThread
static void userButtonPressedLongStart() static void userButtonPressedLongStart()
{ {
if (millis() > 30 * 1000) {
DEBUG_MSG("Long press start!\n"); DEBUG_MSG("Long press start!\n");
longPressTime = millis(); longPressTime = millis();
} }
}
static void userButtonPressedLongStop() static void userButtonPressedLongStop()
{ {
if (millis() > 30 * 1000){
DEBUG_MSG("Long press stop!\n"); DEBUG_MSG("Long press stop!\n");
longPressTime = 0; longPressTime = 0;
if (shutdown_on_long_stop) { if (shutdown_on_long_stop) {
@ -194,6 +197,7 @@ class ButtonThread : public concurrency::OSThread
power->shutdown(); power->shutdown();
} }
} }
}
}; };
} }