add single pump test mode to config page

This commit is contained in:
2024-04-06 21:14:56 +02:00
parent 1f71b94238
commit e7e38e9fca
8 changed files with 182995 additions and 150452 deletions

View File

@@ -83,6 +83,7 @@ pub enum ClearConfigType {
}
#[derive(Debug)]
#[derive(PartialEq)]
pub enum Sensor {
A,
B,
@@ -143,6 +144,7 @@ pub trait PlantCtrlBoardInteraction {
fn wifi_ap(&mut self) -> Result<()>;
fn wifi_scan(&mut self) -> Result<Vec<AccessPointInfo>>;
fn test(&mut self) -> Result<()>;
fn test_pump(&mut self, plant:usize) -> Result<()>;
fn is_wifi_config_file_existant(&mut self) -> bool;
fn mqtt(&mut self, config: &Config) -> Result<()>;
fn mqtt_publish(&mut self, config: &Config, subtopic: &str, message: &[u8]) -> Result<()>;
@@ -357,12 +359,20 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
let factor = 1000 as f32 / measurement as f32;
self.shift_register.decompose()[index].set_high().unwrap();
if plant == 0 && sensor == Sensor::A {
let index = plant * PINS_PER_PLANT + PLANT_MOIST_PUMP_OFFSET;
//self.shift_register.decompose()[index].set_high().unwrap();
}
//give some time to stabilize
delay.delay_ms(10);
self.signal_counter.counter_resume()?;
delay.delay_ms(measurement);
self.signal_counter.counter_pause()?;
self.shift_register.decompose()[index].set_low().unwrap();
if plant == 0 && sensor == Sensor::A {
let index = plant * PINS_PER_PLANT + PLANT_MOIST_PUMP_OFFSET;
//self.shift_register.decompose()[index].set_low().unwrap();
}
let unscaled = self.signal_counter.get_counter_value()? as i32;
let hz = (unscaled as f32 * factor) as i32;
println!("Measuring {:?} @ {} with {}", sensor, plant, hz);
@@ -566,6 +576,15 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
Ok(self.wifi_driver.get_scan_result()?)
}
fn test_pump(&mut self, plant:usize) -> Result<()> {
self.any_pump(true)?;
self.pump(plant, true)?;
unsafe { vTaskDelay(30000) };
self.pump(plant, false)?;
self.any_pump(false)?;
Ok(())
}
fn test(&mut self) -> Result<()> {
self.general_fault(true);
unsafe { vTaskDelay(100) };
@@ -791,6 +810,7 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
Err(err) => bail!("Error reading State of Health {:?}", err),
}
}
}
fn print_battery(