also disable warning light at start
This commit is contained in:
parent
e87012cc9c
commit
27858948e5
@ -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,
|
||||||
@ -128,7 +129,7 @@ fn safe_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let count = unsafe { esp_ota_get_app_partition_count() };
|
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 mut ota_state: esp_ota_img_states_t = 0;
|
||||||
let running_partition = unsafe { esp_ota_get_running_partition() };
|
let running_partition = unsafe { esp_ota_get_running_partition() };
|
||||||
let address = unsafe { (*running_partition).address };
|
let address = unsafe { (*running_partition).address };
|
||||||
@ -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!(
|
||||||
|
Loading…
Reference in New Issue
Block a user