better isWakeupByPowerButton

This commit is contained in:
Xuan Son Nguyen 2026-01-22 16:02:49 +01:00
parent bab513cc95
commit 482a4c3d46

View File

@ -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() {