From c554785aa09a728e82f1b9d620337e3257a2991c Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 22 Apr 2026 17:03:22 -0500 Subject: [PATCH] Only enable wakeup via EXT_CHRG_DETECT if we shut down due to low power --- src/power.h | 1 + variants/nrf52840/ELECROW-ThinkNode-M6/variant.cpp | 11 ++++++++--- variants/nrf52840/ELECROW-ThinkNode-M6/variant.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/power.h b/src/power.h index 81e5b6c4e..967f4536b 100644 --- a/src/power.h +++ b/src/power.h @@ -116,6 +116,7 @@ class Power : private concurrency::OSThread virtual int32_t runOnce() override; void setStatusHandler(meshtastic::PowerStatus *handler) { statusHandler = handler; } const uint16_t OCV[11] = {OCV_ARRAY}; + bool isLowBattery() { return low_voltage_counter >= 10; }; protected: meshtastic::PowerStatus *statusHandler; diff --git a/variants/nrf52840/ELECROW-ThinkNode-M6/variant.cpp b/variants/nrf52840/ELECROW-ThinkNode-M6/variant.cpp index bc0381a48..075850d72 100644 --- a/variants/nrf52840/ELECROW-ThinkNode-M6/variant.cpp +++ b/variants/nrf52840/ELECROW-ThinkNode-M6/variant.cpp @@ -20,6 +20,7 @@ #include "variant.h" #include "nrf.h" +#include "power.h" #include "wiring_constants.h" #include "wiring_digital.h" @@ -68,7 +69,11 @@ void variant_shutdown() nrf_gpio_pin_sense_t sense1 = NRF_GPIO_PIN_SENSE_LOW; nrf_gpio_cfg_sense_set(PIN_BUTTON1, sense1); - nrf_gpio_cfg_input(EXT_CHRG_DETECT, NRF_GPIO_PIN_PULLUP); // Configure the pin to be woken up as an input - nrf_gpio_pin_sense_t sense2 = NRF_GPIO_PIN_SENSE_LOW; - nrf_gpio_cfg_sense_set(EXT_CHRG_DETECT, sense2); + // If we are sleeping because of low battery, wake up when the solar charger detects power. + // But if the user intentionally put us to sleep with the button, don't wake up just because the lights are on + if (power->isLowBattery()) { + nrf_gpio_cfg_input(EXT_CHRG_DETECT, NRF_GPIO_PIN_PULLUP); // Configure the pin to be woken up as an input + nrf_gpio_pin_sense_t sense2 = NRF_GPIO_PIN_SENSE_LOW; + nrf_gpio_cfg_sense_set(EXT_CHRG_DETECT, sense2); + } } diff --git a/variants/nrf52840/ELECROW-ThinkNode-M6/variant.h b/variants/nrf52840/ELECROW-ThinkNode-M6/variant.h index 90232987b..f94d0ba99 100644 --- a/variants/nrf52840/ELECROW-ThinkNode-M6/variant.h +++ b/variants/nrf52840/ELECROW-ThinkNode-M6/variant.h @@ -139,7 +139,7 @@ static const uint8_t A0 = PIN_A0; #define HAS_SOLAR -#define OCV_ARRAY 4080, 3990, 3935, 3880, 3825, 3770, 3715, 3660, 3605, 3550, 3450 +#define OCV_ARRAY 4080, 3990, 3935, 3880, 3825, 3770, 3715, 3660, 3605, 3550, 3490 #ifdef __cplusplus }