Add runtime UV protection toggle and treat near-zero sense as external power.
Per-pod NVS enable (default off) via UART/ESP-NOW/dashboard, and skip UV latch when LiPo ADC reads ~0 mV so USB/external supply still boots. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,10 +11,17 @@
|
||||
#define BATTERY_UV_ADC_MV 2300u
|
||||
/** ADC pin voltage (mV) at which charging is detected (4.0 V pack, rounded). */
|
||||
#define BATTERY_CHARGE_ADC_MV 3000u
|
||||
/**
|
||||
* ADC readings below this are treated as no pack / external supply (not UV).
|
||||
* Noise floor / open sense divider → near 0 mV.
|
||||
*/
|
||||
#define BATTERY_UV_ABSENT_ADC_MV 100u
|
||||
|
||||
bool battery_uv_is_latched(void);
|
||||
bool battery_uv_reading_is_under(const board_lipo_reading_t *reading);
|
||||
bool battery_uv_reading_is_charged(const board_lipo_reading_t *reading);
|
||||
/** true when every valid channel is near 0 (externally powered / no LiPo). */
|
||||
bool battery_uv_reading_is_external(const board_lipo_reading_t *reading);
|
||||
|
||||
/** true → enter UV energy-save path (does not return). */
|
||||
bool battery_uv_evaluate_boot(void);
|
||||
@@ -38,6 +45,11 @@ static inline bool battery_uv_reading_is_charged(const board_lipo_reading_t *rea
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool battery_uv_reading_is_external(const board_lipo_reading_t *reading) {
|
||||
(void)reading;
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool battery_uv_evaluate_boot(void) { return false; }
|
||||
|
||||
static inline void battery_uv_poll(const board_lipo_reading_t *reading) {
|
||||
|
||||
Reference in New Issue
Block a user