switch fertilizer to extra 1
This commit is contained in:
@@ -164,7 +164,7 @@ pub trait BoardInteraction<'a> {
|
|||||||
async fn get_mptt_voltage(&mut self) -> FatResult<Voltage>;
|
async fn get_mptt_voltage(&mut self) -> FatResult<Voltage>;
|
||||||
async fn get_mptt_current(&mut self) -> FatResult<Current>;
|
async fn get_mptt_current(&mut self) -> FatResult<Current>;
|
||||||
async fn can_power(&mut self, state: bool) -> FatResult<()>;
|
async fn can_power(&mut self, state: bool) -> FatResult<()>;
|
||||||
async fn extra2(&mut self, enable: bool) -> FatResult<()>;
|
async fn extra1(&mut self, enable: bool) -> FatResult<()>;
|
||||||
|
|
||||||
async fn backup_config(&mut self, config: &PlantControllerConfig) -> FatResult<()>;
|
async fn backup_config(&mut self, config: &PlantControllerConfig) -> FatResult<()>;
|
||||||
async fn read_backup(&mut self) -> FatResult<PlantControllerConfig>;
|
async fn read_backup(&mut self) -> FatResult<PlantControllerConfig>;
|
||||||
@@ -176,12 +176,7 @@ pub trait BoardInteraction<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return the last known firmware build timestamps per sensor, set during detect_sensors.
|
/// Return the last known firmware build timestamps per sensor, set during detect_sensors.
|
||||||
fn get_sensor_build_minutes(
|
fn get_sensor_build_minutes(&self) -> ([Option<u32>; PLANT_COUNT], [Option<u32>; PLANT_COUNT]) {
|
||||||
&self,
|
|
||||||
) -> (
|
|
||||||
[Option<u32>; PLANT_COUNT],
|
|
||||||
[Option<u32>; PLANT_COUNT],
|
|
||||||
) {
|
|
||||||
([None; PLANT_COUNT], [None; PLANT_COUNT])
|
([None; PLANT_COUNT], [None; PLANT_COUNT])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -484,11 +484,11 @@ impl<'a> BoardInteraction<'a> for V4<'a> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn extra2(&mut self, enable: bool) -> FatResult<()> {
|
async fn extra1(&mut self, enable: bool) -> FatResult<()> {
|
||||||
if enable {
|
if enable {
|
||||||
self.extra2.set_high();
|
self.extra1.set_high();
|
||||||
} else {
|
} else {
|
||||||
self.extra2.set_low();
|
self.extra1.set_low();
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -652,9 +652,7 @@ impl<'a> BoardInteraction<'a> for V4<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_sensor_build_minutes(
|
fn get_sensor_build_minutes(&self) -> ([Option<u32>; PLANT_COUNT], [Option<u32>; PLANT_COUNT]) {
|
||||||
&self,
|
|
||||||
) -> ([Option<u32>; PLANT_COUNT], [Option<u32>; PLANT_COUNT]) {
|
|
||||||
(self.sensor_a_build_minutes, self.sensor_b_build_minutes)
|
(self.sensor_a_build_minutes, self.sensor_b_build_minutes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -722,8 +722,10 @@ pub async fn do_secure_pump(
|
|||||||
let elapsed_minutes = (current_time.timestamp() - last_fertilizer) / 60;
|
let elapsed_minutes = (current_time.timestamp() - last_fertilizer) / 60;
|
||||||
|
|
||||||
if elapsed_minutes >= plant_config.fertilizer_cooldown_min as i64 {
|
if elapsed_minutes >= plant_config.fertilizer_cooldown_min as i64 {
|
||||||
info!("Starting fertilizer pump for {} seconds (last fertilizer was {} minutes ago)",
|
info!(
|
||||||
plant_config.fertilizer_s, elapsed_minutes);
|
"Starting fertilizer pump for {} seconds (last fertilizer was {} minutes ago)",
|
||||||
|
plant_config.fertilizer_s, elapsed_minutes
|
||||||
|
);
|
||||||
log(
|
log(
|
||||||
LogMessage::FertilizerApplied,
|
LogMessage::FertilizerApplied,
|
||||||
plant_config.fertilizer_s as u32,
|
plant_config.fertilizer_s as u32,
|
||||||
@@ -731,16 +733,23 @@ pub async fn do_secure_pump(
|
|||||||
&elapsed_minutes.to_string(),
|
&elapsed_minutes.to_string(),
|
||||||
"",
|
"",
|
||||||
);
|
);
|
||||||
board.board_hal.extra2(true).await?;
|
board.board_hal.extra1(true).await?;
|
||||||
Timer::after_millis(plant_config.fertilizer_s as u64 * 1000).await;
|
Timer::after_millis(plant_config.fertilizer_s as u64 * 1000).await;
|
||||||
board.board_hal.extra2(false).await?;
|
board.board_hal.extra1(false).await?;
|
||||||
info!("Fertilizer pump stopped");
|
info!("Fertilizer pump stopped");
|
||||||
|
|
||||||
// Store the current time as last fertilizer time
|
// Store the current time as last fertilizer time
|
||||||
board.board_hal.get_esp().store_last_fertilizer_time(plant_id, current_time);
|
board
|
||||||
|
.board_hal
|
||||||
|
.get_esp()
|
||||||
|
.store_last_fertilizer_time(plant_id, current_time);
|
||||||
} else {
|
} else {
|
||||||
let remaining_minutes = plant_config.fertilizer_cooldown_min as i64 - elapsed_minutes;
|
let remaining_minutes =
|
||||||
info!("Skipping fertilizer (cooldown: {} minutes remaining)", remaining_minutes);
|
plant_config.fertilizer_cooldown_min as i64 - elapsed_minutes;
|
||||||
|
info!(
|
||||||
|
"Skipping fertilizer (cooldown: {} minutes remaining)",
|
||||||
|
remaining_minutes
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,9 +109,9 @@ where
|
|||||||
T: Read + Write,
|
T: Read + Write,
|
||||||
{
|
{
|
||||||
let mut board = BOARD_ACCESS.get().await.lock().await;
|
let mut board = BOARD_ACCESS.get().await.lock().await;
|
||||||
board.board_hal.extra2(true).await?;
|
board.board_hal.extra1(true).await?;
|
||||||
embassy_time::Timer::after_millis(1000).await;
|
embassy_time::Timer::after_millis(1000).await;
|
||||||
board.board_hal.extra2(false).await?;
|
board.board_hal.extra1(false).await?;
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user