diff --git a/lib/hal/HalGPIO.cpp b/lib/hal/HalGPIO.cpp index 59b6eb72..b150dc8c 100644 --- a/lib/hal/HalGPIO.cpp +++ b/lib/hal/HalGPIO.cpp @@ -223,6 +223,8 @@ bool HalGPIO::wasAnyReleased() const { return inputMgr.wasAnyReleased(); } unsigned long HalGPIO::getHeldTime() const { return inputMgr.getHeldTime(); } +unsigned long HalGPIO::getPowerButtonHeldTime() const { return inputMgr.getPowerButtonHeldTime(); } + void HalGPIO::startDeepSleep() { // Ensure that the power button has been released to avoid immediately turning back on if you're holding it while (inputMgr.isPressed(BTN_POWER)) { @@ -258,8 +260,8 @@ void HalGPIO::verifyPowerButtonWakeup(uint16_t requiredDurationMs, bool shortPre do { delay(10); inputMgr.update(); - } while (inputMgr.isPressed(BTN_POWER) && inputMgr.getHeldTime() < calibratedDuration); - if (inputMgr.getHeldTime() < calibratedDuration) { + } while (inputMgr.isPressed(BTN_POWER) && inputMgr.getPowerButtonHeldTime() < calibratedDuration); + if (inputMgr.getPowerButtonHeldTime() < calibratedDuration) { startDeepSleep(); } } else { diff --git a/lib/hal/HalGPIO.h b/lib/hal/HalGPIO.h index 6337cf9e..94e9bcd7 100644 --- a/lib/hal/HalGPIO.h +++ b/lib/hal/HalGPIO.h @@ -70,6 +70,7 @@ class HalGPIO { bool wasReleased(uint8_t buttonIndex) const; bool wasAnyReleased() const; unsigned long getHeldTime() const; + unsigned long getPowerButtonHeldTime() const; // Setup wake up GPIO and enter deep sleep void startDeepSleep(); diff --git a/open-x4-sdk b/open-x4-sdk index a64a3c29..76a1b2fc 160000 --- a/open-x4-sdk +++ b/open-x4-sdk @@ -1 +1 @@ -Subproject commit a64a3c29bebc59b2ccdfe15492cfc4b5e4c26360 +Subproject commit 76a1b2fc30af6cb932340fc12327076a1120c653 diff --git a/src/main.cpp b/src/main.cpp index 7cdf8068..9ff49684 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -185,8 +185,8 @@ void verifyPowerButtonDuration() { do { delay(10); gpio.update(); - } while (gpio.isPressed(HalGPIO::BTN_POWER) && gpio.getHeldTime() < calibratedPressDuration); - abort = gpio.getHeldTime() < calibratedPressDuration; + } while (gpio.isPressed(HalGPIO::BTN_POWER) && gpio.getPowerButtonHeldTime() < calibratedPressDuration); + abort = gpio.getPowerButtonHeldTime() < calibratedPressDuration; } else { abort = true; } @@ -461,7 +461,7 @@ void loop() { return; } - if (gpio.isPressed(HalGPIO::BTN_POWER) && gpio.getHeldTime() > SETTINGS.getPowerButtonDuration()) { + if (gpio.isPressed(HalGPIO::BTN_POWER) && gpio.getPowerButtonHeldTime() > SETTINGS.getPowerButtonDuration()) { // If the screenshot combination is potentially being pressed, don't sleep if (gpio.isPressed(HalGPIO::BTN_DOWN)) { return;