RAK / NRF shutdown functionality on user button long press (#1113)

This commit is contained in:
Ben Meadors
2022-01-19 17:10:02 -06:00
committed by GitHub
parent 4e3fda87a1
commit 9309824874
4 changed files with 35 additions and 2 deletions

View File

@@ -300,8 +300,9 @@ class ButtonThread : public OSThread
static void userButtonPressedLong()
{
// DEBUG_MSG("Long press!\n");
#ifndef NRF52_SERIES
screen->adjustBrightness();
#endif
// If user button is held down for 5 seconds, shutdown the device.
if (millis() - longPressTime > 5 * 1000) {
#ifdef TBEAM_V10
@@ -313,6 +314,7 @@ class ButtonThread : public OSThread
// Do actual shutdown when button released, otherwise the button release
// may wake the board immediatedly.
if (!shutdown_on_long_stop) {
screen->startShutdownScreen();
DEBUG_MSG("Shutdown from long press");
playBeep();
ledOff(PIN_LED1);
@@ -354,6 +356,7 @@ class ButtonThread : public OSThread
longPressTime = 0;
if (shutdown_on_long_stop) {
playShutdownMelody();
delay(3000);
power->shutdown();
}
}