From 3a9086dfc5831fe5e11dc1df596bbaf0306c3d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 27 Apr 2022 11:02:45 +0200 Subject: [PATCH] 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. --- src/ButtonThread.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/ButtonThread.h b/src/ButtonThread.h index 8a6603888..3a6f67a72 100644 --- a/src/ButtonThread.h +++ b/src/ButtonThread.h @@ -135,7 +135,7 @@ class ButtonThread : public concurrency::OSThread screen->adjustBrightness(); #endif // 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 if (axp192_found == true) { setLed(false); @@ -144,7 +144,7 @@ class ButtonThread : public concurrency::OSThread #elif NRF52_SERIES // Do actual shutdown when button released, otherwise the button release // may wake the board immediatedly. - if (!shutdown_on_long_stop) { + if ((!shutdown_on_long_stop) && (millis() > 30 * 1000)) { screen->startShutdownScreen(); DEBUG_MSG("Shutdown from long press"); playBeep(); @@ -180,18 +180,22 @@ class ButtonThread : public concurrency::OSThread static void userButtonPressedLongStart() { - DEBUG_MSG("Long press start!\n"); - longPressTime = millis(); + if (millis() > 30 * 1000) { + DEBUG_MSG("Long press start!\n"); + longPressTime = millis(); + } } static void userButtonPressedLongStop() { - DEBUG_MSG("Long press stop!\n"); - longPressTime = 0; - if (shutdown_on_long_stop) { - playShutdownMelody(); - delay(3000); - power->shutdown(); + if (millis() > 30 * 1000){ + DEBUG_MSG("Long press stop!\n"); + longPressTime = 0; + if (shutdown_on_long_stop) { + playShutdownMelody(); + delay(3000); + power->shutdown(); + } } } };