add awake and charge indicator led functions
This commit is contained in:
parent
59d27ab0b8
commit
3cf9298756
@ -180,6 +180,8 @@ struct PlantStateMQTT<'a> {
|
||||
next_pump: &'a str,
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn safe_main() -> anyhow::Result<()> {
|
||||
// It is necessary to call this function once. Otherwise some patches to the runtime
|
||||
// implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
|
||||
@ -256,7 +258,9 @@ fn safe_main() -> anyhow::Result<()> {
|
||||
log(log::LogMessage::YearInplausibleForceConfig, 0,0,"","");
|
||||
}
|
||||
|
||||
|
||||
println!("cur is {}", cur);
|
||||
board.update_charge_indicator();
|
||||
|
||||
if board.get_restart_to_conf() {
|
||||
log(log::LogMessage::ConfigModeSoftwareOverride, 0,0,"","");
|
||||
@ -941,6 +945,7 @@ fn wait_infinity(wait_type: WaitType, reboot_now: Arc<AtomicBool>) -> ! {
|
||||
led_count += 1;
|
||||
};
|
||||
unsafe {
|
||||
BOARD_ACCESS.lock().unwrap().update_charge_indicator();
|
||||
//do not trigger watchdog
|
||||
for i in 0..8 {
|
||||
BOARD_ACCESS.lock().unwrap().fault(i, i < led_count);
|
||||
|
@ -216,7 +216,17 @@ pub struct BackupHeader{
|
||||
}
|
||||
|
||||
impl PlantCtrlBoard<'_> {
|
||||
pub fn update_charge_indicator(&mut self){
|
||||
let is_charging = match self.battery_driver.average_current() {
|
||||
OkStd(current) => current < 20,
|
||||
Err(_) => false,
|
||||
};
|
||||
self.shift_register.decompose()[CHARGING].set_state(is_charging.into()).unwrap();
|
||||
}
|
||||
|
||||
|
||||
pub fn deep_sleep(&mut self, duration_in_ms:u64) -> !{
|
||||
self.shift_register.decompose()[AWAKE].set_low().unwrap();
|
||||
unsafe {
|
||||
//if we dont do this here, we might just revert a newly flashed firmeware
|
||||
mark_app_valid();
|
||||
|
Loading…
x
Reference in New Issue
Block a user