Add apply_fertilizer parameter to do_secure_pump to prevent fertilizer applying on corrosion protection
This commit is contained in:
@@ -462,7 +462,7 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
|
|||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let result = do_secure_pump(&mut board, plant_id, plant_config, dry_run).await;
|
let result = do_secure_pump(&mut board, plant_id, plant_config, dry_run, true).await;
|
||||||
match result {
|
match result {
|
||||||
Ok(state) => {
|
Ok(state) => {
|
||||||
overcurrent_results[plant_id] = state.overcurrent_ma;
|
overcurrent_results[plant_id] = state.overcurrent_ma;
|
||||||
@@ -547,7 +547,7 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
|
|||||||
"corrosion_prot",
|
"corrosion_prot",
|
||||||
"",
|
"",
|
||||||
);
|
);
|
||||||
let _ = do_secure_pump(&mut board, plant_id, &plant_config, dry_run).await;
|
let _ = do_secure_pump(&mut board, plant_id, &plant_config, dry_run, false).await;
|
||||||
let _ = board.board_hal.pump(plant_id, false).await;
|
let _ = board.board_hal.pump(plant_id, false).await;
|
||||||
}
|
}
|
||||||
board
|
board
|
||||||
@@ -705,6 +705,7 @@ pub async fn do_secure_pump(
|
|||||||
plant_id: usize,
|
plant_id: usize,
|
||||||
plant_config: &PlantConfig,
|
plant_config: &PlantConfig,
|
||||||
dry_run: bool,
|
dry_run: bool,
|
||||||
|
apply_fertilizer: bool,
|
||||||
) -> FatResult<PumpResult> {
|
) -> FatResult<PumpResult> {
|
||||||
const STARTUP_IGNORE_MS: u32 = 500;
|
const STARTUP_IGNORE_MS: u32 = 500;
|
||||||
const STARTUP_ABORT_CURRENT_MA: u16 = 1500;
|
const STARTUP_ABORT_CURRENT_MA: u16 = 1500;
|
||||||
@@ -719,8 +720,8 @@ pub async fn do_secure_pump(
|
|||||||
let mut overcurrent_ma: Option<u16> = None;
|
let mut overcurrent_ma: Option<u16> = None;
|
||||||
|
|
||||||
if !dry_run {
|
if !dry_run {
|
||||||
// Run fertilizer pump first if configured and not in cooldown
|
// Run fertilizer pump first if configured, requested, and not in cooldown
|
||||||
if plant_config.fertilizer_s > 0 {
|
if apply_fertilizer && plant_config.fertilizer_s > 0 {
|
||||||
let current_time = board.board_hal.get_time().await;
|
let current_time = board.board_hal.get_time().await;
|
||||||
let last_fertilizer = board.board_hal.get_esp().last_fertilizer_time(plant_id);
|
let last_fertilizer = board.board_hal.get_esp().last_fertilizer_time(plant_id);
|
||||||
// Convert last_fertilizer from milliseconds to seconds for correct subtraction
|
// Convert last_fertilizer from milliseconds to seconds for correct subtraction
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ where
|
|||||||
let mut board = BOARD_ACCESS.get().await.lock().await;
|
let mut board = BOARD_ACCESS.get().await.lock().await;
|
||||||
|
|
||||||
let config = &board.board_hal.get_config().plants[pump_test.pump].clone();
|
let config = &board.board_hal.get_config().plants[pump_test.pump].clone();
|
||||||
let pump_result = do_secure_pump(&mut board, pump_test.pump, config, false).await;
|
let pump_result = do_secure_pump(&mut board, pump_test.pump, config, false, false).await;
|
||||||
//ensure it is disabled before unwrapping
|
//ensure it is disabled before unwrapping
|
||||||
board.board_hal.pump(pump_test.pump, false).await?;
|
board.board_hal.pump(pump_test.pump, false).await?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user