also disable warning light at start

This commit is contained in:
Empire Phoenix 2024-06-08 21:13:26 +02:00
parent e87012cc9c
commit 27858948e5

View File

@ -97,6 +97,7 @@ enum SensorError {
#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Default)] #[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Default)]
struct TankState { struct TankState {
enough_water: bool, enough_water: bool,
warn_level: bool,
left_ml: u32, left_ml: u32,
sensor_error: bool, sensor_error: bool,
raw: u16, raw: u16,
@ -156,7 +157,7 @@ fn safe_main() -> anyhow::Result<()> {
println!("Board hal init"); println!("Board hal init");
let mut board: std::sync::MutexGuard<'_, PlantCtrlBoard<'_>> = BOARD_ACCESS.lock().unwrap(); let mut board: std::sync::MutexGuard<'_, PlantCtrlBoard<'_>> = BOARD_ACCESS.lock().unwrap();
board.general_fault(false);
println!("Mounting filesystem"); println!("Mounting filesystem");
board.mount_file_system()?; board.mount_file_system()?;
let free_space = board.file_system_size()?; let free_space = board.file_system_size()?;
@ -337,6 +338,11 @@ fn safe_main() -> anyhow::Result<()> {
"/water/enough_water", "/water/enough_water",
tank_state.enough_water.to_string().as_bytes(), tank_state.enough_water.to_string().as_bytes(),
); );
let _ = board.mqtt_publish(
&config,
"/water/low_warning",
tank_state.warn_level.to_string().as_bytes(),
);
let _ = let _ =
board.mqtt_publish(&config, "/water/raw", tank_state.raw.to_string().as_bytes()); board.mqtt_publish(&config, "/water/raw", tank_state.raw.to_string().as_bytes());
} }
@ -722,6 +728,7 @@ fn determine_tank_state(
"Low water, current percent is {}, minimum warn level is {}", "Low water, current percent is {}, minimum warn level is {}",
percent as u8, config.tank_warn_percent percent as u8, config.tank_warn_percent
); );
rv.warn_level = true;
} }
if config.tank_empty_percent < percent as u8 { if config.tank_empty_percent < percent as u8 {
println!( println!(