From 3a702cb84feafd74dc4ae2f418522b3037ec1165 Mon Sep 17 00:00:00 2001 From: ju6ge Date: Sat, 15 Mar 2025 15:57:15 +0100 Subject: [PATCH] suggestion for logging location --- rust/src/main.rs | 24 ++++++++++++++++++++++++ rust/src/tank.rs | 7 ------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index 3f4902c..294f210 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -401,6 +401,30 @@ fn safe_main() -> anyhow::Result<()> { let dry_run = false; let tank_state = determine_tank_state(&mut board, &config); + if let Some(_err) = tank_state.got_error(&config.tank) { + //TODO log error state to serial + } else if tank_state.warn_level(&config.tank).is_ok_and(|warn| warn) { + //TODO(judge) enable logging again, might require returning level as well + //println!( + //"Low water, current percent is {}, minimum warn level is {}", + //percent as u8, config.tank.tank_warn_percent + //); + board.general_fault(true); + } else if tank_state.enough_water(&config.tank).is_ok_and(|enough| enough) { + //TODO(judge) enable logging again, might require returning level as well + //println!( + //"Enough water, current percent is {}, minimum empty level is {}", + //percent as u8, config.tank.tank_empty_percent + //); + } else { + if let Ok(_left_ml) = tank_state.left_ml(&config.tank) { + //TODO(judge) enable logging again, might require returning level as well + //println!( + //"Tank sensor returned mv {} as {}% leaving {} ml useable", + //rv.raw, percent as u8, rv.left_ml + //); + } + } let mut water_frozen = false; let mut attempt = 1; diff --git a/rust/src/tank.rs b/rust/src/tank.rs index 29b9041..000c596 100644 --- a/rust/src/tank.rs +++ b/rust/src/tank.rs @@ -98,13 +98,6 @@ impl TankState { TankState::TankSensorPresent(raw_value_mv) => { let tank_fill_percent = raw_voltage_to_tank_fill_percent(*raw_value_mv, config)?; if tank_fill_percent < config.tank_warn_percent.into() { - //TODO(judge) move logging to more sensible place - //println!( - //"Low water, current percent is {}, minimum warn level is {}", - //percent as u8, config.tank.tank_warn_percent - //); - // TODO(judge) move board fault setting - // board.general_fault(true); Ok(true) } else { Ok(false)