Detect under-voltage on GPIO1/11, persist UV state in NVS, enter a minimal power mode without ESP-NOW, and recover after charge; expose LED mode 6 battery-low for host testing via goTool. Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.3 KiB
C
52 lines
1.3 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
|
|
|
|
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 → 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_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
|