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>
64 lines
1.8 KiB
C
64 lines
1.8 KiB
C
#ifndef BATTERY_UV_H
|
|
#define BATTERY_UV_H
|
|
|
|
#include "board_input.h"
|
|
#include "powerpod.h"
|
|
#include <stdbool.h>
|
|
|
|
#if POWERPOD_BATTERY_UV_ENABLE
|
|
|
|
/** ADC pin voltage (mV) below which UV is triggered (3.0 V pack via 33k/10k divider). */
|
|
#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);
|
|
|
|
void battery_uv_poll(const board_lipo_reading_t *reading);
|
|
|
|
/** Blocks: LED indicator, then minimal ADC polling until charged. */
|
|
void battery_uv_run_mode(void);
|
|
|
|
#else
|
|
|
|
static inline bool battery_uv_is_latched(void) { return false; }
|
|
|
|
static inline bool battery_uv_reading_is_under(const board_lipo_reading_t *reading) {
|
|
(void)reading;
|
|
return false;
|
|
}
|
|
|
|
static inline bool battery_uv_reading_is_charged(const board_lipo_reading_t *reading) {
|
|
(void)reading;
|
|
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) {
|
|
(void)reading;
|
|
}
|
|
|
|
static inline void battery_uv_run_mode(void) {}
|
|
|
|
#endif
|
|
|
|
#endif
|