From 482a4c3d465a1a644bbc68bc674f605b5b6a3010 Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Thu, 22 Jan 2026 16:02:49 +0100 Subject: [PATCH] better isWakeupByPowerButton --- src/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b6370fac..b81f3caa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -298,7 +298,12 @@ bool isWakeupAfterFlashing() { bool isWakeupByPowerButton() { const auto wakeupCause = esp_sleep_get_wakeup_cause(); - return wakeupCause == ESP_SLEEP_WAKEUP_GPIO; + const auto resetReason = esp_reset_reason(); + if (isUsbConnected()) { + return wakeupCause == ESP_SLEEP_WAKEUP_GPIO; + } else { + return (wakeupCause == ESP_SLEEP_WAKEUP_UNDEFINED) && (resetReason == ESP_RST_POWERON); + } } void setup() {