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)]
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!(