mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 22:57:50 +03:00
fix startDeepSleep()
This commit is contained in:
parent
fa05eba8a1
commit
72c2da971d
@ -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
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user