From 27858948e5af6003f9c3698c952c91ab2173c56b Mon Sep 17 00:00:00 2001 From: Empire Phoenix Date: Sat, 8 Jun 2024 21:13:26 +0200 Subject: [PATCH] also disable warning light at start --- rust/src/main.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index 9861440..171d61b 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -97,6 +97,7 @@ enum SensorError { #[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Default)] struct TankState { enough_water: bool, + warn_level: bool, left_ml: u32, sensor_error: bool, raw: u16, @@ -128,7 +129,7 @@ fn safe_main() -> anyhow::Result<()> { ); let count = unsafe { esp_ota_get_app_partition_count() }; - println!("Partition count is {}", count); + println!("Partit ion count is {}", count); let mut ota_state: esp_ota_img_states_t = 0; let running_partition = unsafe { esp_ota_get_running_partition() }; let address = unsafe { (*running_partition).address }; @@ -156,7 +157,7 @@ fn safe_main() -> anyhow::Result<()> { println!("Board hal init"); let mut board: std::sync::MutexGuard<'_, PlantCtrlBoard<'_>> = BOARD_ACCESS.lock().unwrap(); - + board.general_fault(false); println!("Mounting filesystem"); board.mount_file_system()?; let free_space = board.file_system_size()?; @@ -337,6 +338,11 @@ fn safe_main() -> anyhow::Result<()> { "/water/enough_water", 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 _ = 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 {}", percent as u8, config.tank_warn_percent ); + rv.warn_level = true; } if config.tank_empty_percent < percent as u8 { println!(