From af5613c0944d2a506657df9ff549e7b4a5cf15e4 Mon Sep 17 00:00:00 2001 From: csrutil Date: Sat, 11 Oct 2025 08:45:46 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20improve=20user=20button=20w?= =?UTF-8?q?ake-up=20for=20Heltec=20V3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor wake-up configuration to use ext0 for button wake instead of combining button and LoRa interrupt in ext1. Add button release detection and debouncing in powerOff to prevent immediate re-trigger on wake. --- src/helpers/HeltecV3Board.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/helpers/HeltecV3Board.h b/src/helpers/HeltecV3Board.h index c63ed2d87..e7c97eae7 100644 --- a/src/helpers/HeltecV3Board.h +++ b/src/helpers/HeltecV3Board.h @@ -70,10 +70,10 @@ class HeltecV3Board : public ESP32Board { rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS); - if (pin_wake_btn < 0) { - esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet - } else { - esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn + esp_sleep_enable_ext1_wakeup((1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet + + if (pin_wake_btn >= 0) { + esp_sleep_enable_ext0_wakeup((gpio_num_t)pin_wake_btn, 0); // wake up on: button press (LOW) } if (secs > 0) { @@ -85,7 +85,15 @@ class HeltecV3Board : public ESP32Board { } void powerOff() override { - enterDeepSleep(0); +#ifdef PIN_USER_BTN + // Wait for button release to avoid immediate re-trigger + while (digitalRead(PIN_USER_BTN) == LOW) { + delay(10); + } + delay(50); // Debounce +#endif + + enterDeepSleep(0, PIN_USER_BTN); } uint16_t getBattMilliVolts() override {