Only enable wakeup via EXT_CHRG_DETECT if we shut down due to low power (#10263)
This commit is contained in:
@@ -100,6 +100,7 @@ class Power : public concurrency::OSThread
|
|||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
void setStatusHandler(meshtastic::PowerStatus *handler) { statusHandler = handler; }
|
void setStatusHandler(meshtastic::PowerStatus *handler) { statusHandler = handler; }
|
||||||
const uint16_t OCV[11] = {OCV_ARRAY};
|
const uint16_t OCV[11] = {OCV_ARRAY};
|
||||||
|
bool isLowBattery() { return low_voltage_counter >= 10; };
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
int beforeLightSleep(void *unused);
|
int beforeLightSleep(void *unused);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "variant.h"
|
#include "variant.h"
|
||||||
#include "nrf.h"
|
#include "nrf.h"
|
||||||
|
#include "power.h"
|
||||||
#include "wiring_constants.h"
|
#include "wiring_constants.h"
|
||||||
#include "wiring_digital.h"
|
#include "wiring_digital.h"
|
||||||
|
|
||||||
@@ -65,7 +66,11 @@ void variant_shutdown()
|
|||||||
nrf_gpio_pin_sense_t sense1 = NRF_GPIO_PIN_SENSE_LOW;
|
nrf_gpio_pin_sense_t sense1 = NRF_GPIO_PIN_SENSE_LOW;
|
||||||
nrf_gpio_cfg_sense_set(PIN_BUTTON1, sense1);
|
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
|
// If we are sleeping because of low battery, wake up when the solar charger detects power.
|
||||||
nrf_gpio_pin_sense_t sense2 = NRF_GPIO_PIN_SENSE_LOW;
|
// But if the user intentionally put us to sleep with the button, don't wake up just because the lights are on
|
||||||
nrf_gpio_cfg_sense_set(EXT_CHRG_DETECT, sense2);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ static const uint8_t A0 = PIN_A0;
|
|||||||
|
|
||||||
#define HAS_SOLAR
|
#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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user