pub struct LowBatteryDetector { /* private fields */ }Expand description
Tracks consecutive low-battery samples and emits a PowerIntent::PowerOff
once the streak crosses the configured threshold while the device is
not USB-powered.
Matches the Meshtastic behavior documented in
docs/hardware/t1000e-hardware.md: the T1000-E has no confirmed hardware
undervoltage cutoff, so firmware must protect the Li-ion cell by
shutting down before the voltage falls too far below the OCV table’s
3.1 V floor.
Implementations§
Source§impl LowBatteryDetector
impl LowBatteryDetector
Sourcepub fn new(threshold_mv: u16, streak_required: u8) -> Self
pub fn new(threshold_mv: u16, streak_required: u8) -> Self
Create a detector. threshold_mv is the floor (samples strictly
below this count toward the streak); streak_required is the
number of consecutive low samples while not USB-powered needed
to fire.
Sourcepub fn t1000e_default() -> Self
pub fn t1000e_default() -> Self
Default per the T1000-E plan: 3.1 V floor, 10-sample streak.
Sourcepub fn observe(
&mut self,
sample_mv: u16,
usb_powered: bool,
) -> Option<PowerIntent>
pub fn observe( &mut self, sample_mv: u16, usb_powered: bool, ) -> Option<PowerIntent>
Feed one sample. Returns PowerIntent::PowerOff the first
time the streak crosses the threshold; subsequent calls return
None until reset is called. This lets the
power task act on a single fire and ignore further samples
while it tears down.