mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 14:47:37 +03:00
Start power off sequence as soon as hold duration for the power button is reached (#93)
## Summary * Swap from `wasReleased` to `isPressed` when checking power button duration * In practice it makes the power down experience feel a lot snappier * Remove the unnecessary 1000ms delay when powering off ## Additional Context * A little discussion in here: https://github.com/daveallie/crosspoint-reader/discussions/53#discussioncomment-15309707
This commit is contained in:
parent
fcfa10bb1f
commit
246afae6ef
12
src/main.cpp
12
src/main.cpp
@ -119,14 +119,12 @@ void enterDeepSleep() {
|
|||||||
exitActivity();
|
exitActivity();
|
||||||
enterNewActivity(new SleepActivity(renderer, inputManager));
|
enterNewActivity(new SleepActivity(renderer, inputManager));
|
||||||
|
|
||||||
Serial.printf("[%lu] [ ] Entering deep sleep.\n", millis());
|
|
||||||
delay(1000); // Allow Serial buffer to empty and display to update
|
|
||||||
|
|
||||||
// Enable Wakeup on LOW (button press)
|
|
||||||
esp_deep_sleep_enable_gpio_wakeup(1ULL << InputManager::POWER_BUTTON_PIN, ESP_GPIO_WAKEUP_GPIO_LOW);
|
|
||||||
|
|
||||||
einkDisplay.deepSleep();
|
einkDisplay.deepSleep();
|
||||||
|
|
||||||
|
Serial.printf("[%lu] [ ] Entering deep sleep.\n", millis());
|
||||||
|
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
|
||||||
|
waitForPowerRelease();
|
||||||
// Enter Deep Sleep
|
// Enter Deep Sleep
|
||||||
esp_deep_sleep_start();
|
esp_deep_sleep_start();
|
||||||
}
|
}
|
||||||
@ -231,7 +229,7 @@ void loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputManager.wasReleased(InputManager::BTN_POWER) &&
|
if (inputManager.isPressed(InputManager::BTN_POWER) &&
|
||||||
inputManager.getHeldTime() > SETTINGS.getPowerButtonDuration()) {
|
inputManager.getHeldTime() > SETTINGS.getPowerButtonDuration()) {
|
||||||
enterDeepSleep();
|
enterDeepSleep();
|
||||||
// This should never be hit as `enterDeepSleep` calls esp_deep_sleep_start
|
// This should never be hit as `enterDeepSleep` calls esp_deep_sleep_start
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user