Add ALLOW_SLEEP flag to enable sleep mode in inactivity checks

This commit is contained in:
Nacho 2026-05-28 21:35:41 +02:00
parent f15ea8190f
commit 3de6c121a5
2 changed files with 6 additions and 1 deletions

View File

@ -30,6 +30,7 @@ build_flags =
-DBOARD_HAS_PSRAM -DBOARD_HAS_PSRAM
-DARDUINO_USB_CDC_ON_BOOT=0 -DARDUINO_USB_CDC_ON_BOOT=0
-DDEV_UNIT -DDEV_UNIT
-DALLOW_SLEEP
-DDEBUG -DDEBUG
upload_port = COM8 upload_port = COM8
@ -49,7 +50,9 @@ build_flags =
-DBOARD_HAS_PSRAM -DBOARD_HAS_PSRAM
-DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=1 -DARDUINO_USB_MODE=1
-DALLOW_SLEEP
-DDEV_UNIT -DDEV_UNIT
-DDEBUG
board_build.partitions = default.csv board_build.partitions = default.csv
lib_deps = TFT_eSPI, fbiego/ESP32Time@^2.0.6, electroniccats/MPU6050@^1.4.3 lib_deps = TFT_eSPI, fbiego/ESP32Time@^2.0.6, electroniccats/MPU6050@^1.4.3

View File

@ -16,9 +16,11 @@ bool k4_prev = HIGH;
void buttons_checkInactivity() { void buttons_checkInactivity() {
uint64_t currentTime = esp_timer_get_time(); uint64_t currentTime = esp_timer_get_time();
if (currentTime - lastPressedButtonTime > INACTIVITY_THRESHOLD_TIME_US && !screenOff) { if (currentTime - lastPressedButtonTime > INACTIVITY_THRESHOLD_TIME_US && !screenOff && !alwaysOnEnabled) {
#ifdef ALLOW_SLEEP
digitalWrite(BL_PIN, LOW); digitalWrite(BL_PIN, LOW);
screenKey = OFF_SCREEN; screenKey = OFF_SCREEN;
#endif
} else if (currentTime - lastPressedButtonTime > LAST_PRESSED_BUTTON_THRESHOLD_TIME_US && !inactive) { } else if (currentTime - lastPressedButtonTime > LAST_PRESSED_BUTTON_THRESHOLD_TIME_US && !inactive) {
screenKey = MAIN_SCREEN; screenKey = MAIN_SCREEN;