diff --git a/lib/hal/HalInput.cpp b/lib/hal/HalInput.cpp index 0c55f1e7..bed3d861 100644 --- a/lib/hal/HalInput.cpp +++ b/lib/hal/HalInput.cpp @@ -69,17 +69,17 @@ unsigned long HalInput::getHeldTime() const { #endif } -void HalInput::setupGpioWakeup() { +void startDeepSleep(InputManager& inputMgr) { #if CROSSPOINT_EMULATED == 0 esp_deep_sleep_enable_gpio_wakeup(1ULL << InputManager::POWER_BUTTON_PIN, ESP_GPIO_WAKEUP_GPIO_LOW); // Ensure that the power button has been released to avoid immediately turning back on if you're holding it - while (isPressed(InputManager::BTN_POWER)) { + while (inputMgr.isPressed(InputManager::BTN_POWER)) { delay(50); - update(); + inputMgr.update(); } // Enter Deep Sleep esp_deep_sleep_start(); #else - // TODO + Serial.println("[ ] GPIO wakeup setup skipped in emulation mode."); #endif } diff --git a/lib/hal/HalInput.h b/lib/hal/HalInput.h index a06771b4..f1dd8ce5 100644 --- a/lib/hal/HalInput.h +++ b/lib/hal/HalInput.h @@ -23,8 +23,6 @@ class HalInput { bool wasAnyReleased() const; unsigned long getHeldTime() const; - void setupGpioWakeup(); - // Button indices static constexpr uint8_t BTN_BACK = 0; static constexpr uint8_t BTN_CONFIRM = 1; @@ -38,3 +36,5 @@ class HalInput { #if CROSSPOINT_EMULATED == 1 using InputManager = HalInput; #endif + +void startDeepSleep(InputManager& inputMgr); diff --git a/src/main.cpp b/src/main.cpp index 82d9a0c9..54ecade2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -184,7 +184,7 @@ void verifyWakeupLongPress() { if (abort) { // Button released too early. Returning to sleep. // IMPORTANT: Re-arm the wakeup trigger before sleeping again - inputManager.setupGpioWakeup(); + startDeepSleep(inputManager); } } @@ -207,7 +207,7 @@ void enterDeepSleep() { einkDisplay.deepSleep(); Serial.printf("[%lu] [ ] Power button press calibration value: %lu ms\n", millis(), t2 - t1); Serial.printf("[%lu] [ ] Entering deep sleep.\n", millis()); - inputManager.setupGpioWakeup(); + startDeepSleep(inputManager); } void onGoHome();