feat: add fertilizer pump functionality with configuration, web UI, and HAL integration
This commit is contained in:
@@ -129,6 +129,7 @@ pub struct PlantConfig {
|
|||||||
pub min_pump_current_ma: u16,
|
pub min_pump_current_ma: u16,
|
||||||
pub max_pump_current_ma: u16,
|
pub max_pump_current_ma: u16,
|
||||||
pub ignore_current_error: bool,
|
pub ignore_current_error: bool,
|
||||||
|
pub fertilizer_s: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PlantConfig {
|
impl Default for PlantConfig {
|
||||||
@@ -150,6 +151,7 @@ impl Default for PlantConfig {
|
|||||||
min_pump_current_ma: 10,
|
min_pump_current_ma: 10,
|
||||||
max_pump_current_ma: 3000,
|
max_pump_current_ma: 3000,
|
||||||
ignore_current_error: true,
|
ignore_current_error: true,
|
||||||
|
fertilizer_s: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -715,6 +715,15 @@ pub async fn do_secure_pump(
|
|||||||
let mut pump_time_ms: u32 = 0;
|
let mut pump_time_ms: u32 = 0;
|
||||||
|
|
||||||
if !dry_run {
|
if !dry_run {
|
||||||
|
// Run fertilizer pump first if configured
|
||||||
|
if plant_config.fertilizer_s > 0 {
|
||||||
|
info!("Starting fertilizer pump for {} seconds", plant_config.fertilizer_s);
|
||||||
|
board.board_hal.extra2(true).await?;
|
||||||
|
Timer::after_millis(plant_config.fertilizer_s as u64 * 1000).await;
|
||||||
|
board.board_hal.extra2(false).await?;
|
||||||
|
info!("Fertilizer pump stopped");
|
||||||
|
}
|
||||||
|
|
||||||
board.board_hal.get_tank_sensor()?.reset_flow_meter();
|
board.board_hal.get_tank_sensor()?.reset_flow_meter();
|
||||||
board.board_hal.get_tank_sensor()?.start_flow_meter();
|
board.board_hal.get_tank_sensor()?.start_flow_meter();
|
||||||
board.board_hal.pump(plant_id, true).await?;
|
board.board_hal.pump(plant_id, true).await?;
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ export interface PlantConfig {
|
|||||||
min_moisture: number,
|
min_moisture: number,
|
||||||
pump_time_s: number,
|
pump_time_s: number,
|
||||||
pump_cooldown_min: number,
|
pump_cooldown_min: number,
|
||||||
|
fertilizer_s: number,
|
||||||
pump_hour_start: number,
|
pump_hour_start: number,
|
||||||
pump_hour_end: number,
|
pump_hour_end: number,
|
||||||
pump_limit_ml: number,
|
pump_limit_ml: number,
|
||||||
|
|||||||
@@ -78,6 +78,11 @@
|
|||||||
<input class="plantvalue" id="plant_${plantId}_pump_cooldown_min" type="number" min="0" max="600"
|
<input class="plantvalue" id="plant_${plantId}_pump_cooldown_min" type="number" min="0" max="600"
|
||||||
placeholder="30">
|
placeholder="30">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flexcontainer plantPumpEnabledOnly_${plantId}">
|
||||||
|
<div class="plantkey">Fertilizer (s):</div>
|
||||||
|
<input class="plantvalue" id="plant_${plantId}_fertilizer_s" type="number" min="0" max="60"
|
||||||
|
placeholder="0">
|
||||||
|
</div>
|
||||||
<div class="flexcontainer plantPumpEnabledOnly_${plantId}">
|
<div class="flexcontainer plantPumpEnabledOnly_${plantId}">
|
||||||
<div class="plantkey">"Pump Hour Start":</div>
|
<div class="plantkey">"Pump Hour Start":</div>
|
||||||
<select class="plantvalue" id="plant_${plantId}_pump_hour_start">10</select>
|
<select class="plantvalue" id="plant_${plantId}_pump_hour_start">10</select>
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ export class PlantView {
|
|||||||
private readonly minMoisture: HTMLInputElement;
|
private readonly minMoisture: HTMLInputElement;
|
||||||
private readonly pumpTimeS: HTMLInputElement;
|
private readonly pumpTimeS: HTMLInputElement;
|
||||||
private readonly pumpCooldown: HTMLInputElement;
|
private readonly pumpCooldown: HTMLInputElement;
|
||||||
|
private readonly fertilizerS: HTMLInputElement;
|
||||||
private readonly pumpHourStart: HTMLSelectElement;
|
private readonly pumpHourStart: HTMLSelectElement;
|
||||||
private readonly pumpHourEnd: HTMLSelectElement;
|
private readonly pumpHourEnd: HTMLSelectElement;
|
||||||
private readonly sensorAInstalled: HTMLInputElement;
|
private readonly sensorAInstalled: HTMLInputElement;
|
||||||
@@ -180,6 +181,11 @@ export class PlantView {
|
|||||||
controller.configChanged()
|
controller.configChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.fertilizerS = document.getElementById("plant_" + plantId + "_fertilizer_s") as HTMLInputElement;
|
||||||
|
this.fertilizerS.onchange = function () {
|
||||||
|
controller.configChanged()
|
||||||
|
}
|
||||||
|
|
||||||
this.pumpHourStart = document.getElementById("plant_" + plantId + "_pump_hour_start") as HTMLSelectElement;
|
this.pumpHourStart = document.getElementById("plant_" + plantId + "_pump_hour_start") as HTMLSelectElement;
|
||||||
this.pumpHourStart.onchange = function () {
|
this.pumpHourStart.onchange = function () {
|
||||||
controller.configChanged()
|
controller.configChanged()
|
||||||
@@ -328,6 +334,7 @@ export class PlantView {
|
|||||||
this.minMoisture.value = plantConfig.min_moisture?.toString() || "";
|
this.minMoisture.value = plantConfig.min_moisture?.toString() || "";
|
||||||
this.pumpTimeS.value = plantConfig.pump_time_s.toString();
|
this.pumpTimeS.value = plantConfig.pump_time_s.toString();
|
||||||
this.pumpCooldown.value = plantConfig.pump_cooldown_min.toString();
|
this.pumpCooldown.value = plantConfig.pump_cooldown_min.toString();
|
||||||
|
this.fertilizerS.value = plantConfig.fertilizer_s?.toString() || "0";
|
||||||
this.pumpHourStart.value = plantConfig.pump_hour_start.toString();
|
this.pumpHourStart.value = plantConfig.pump_hour_start.toString();
|
||||||
this.pumpHourEnd.value = plantConfig.pump_hour_end.toString();
|
this.pumpHourEnd.value = plantConfig.pump_hour_end.toString();
|
||||||
this.sensorBInstalled.checked = plantConfig.sensor_b;
|
this.sensorBInstalled.checked = plantConfig.sensor_b;
|
||||||
@@ -355,6 +362,7 @@ export class PlantView {
|
|||||||
pump_time_s: this.pumpTimeS.valueAsNumber,
|
pump_time_s: this.pumpTimeS.valueAsNumber,
|
||||||
pump_limit_ml: 5000,
|
pump_limit_ml: 5000,
|
||||||
pump_cooldown_min: this.pumpCooldown.valueAsNumber,
|
pump_cooldown_min: this.pumpCooldown.valueAsNumber,
|
||||||
|
fertilizer_s: this.fertilizerS.valueAsNumber || 0,
|
||||||
pump_hour_start: +this.pumpHourStart.value,
|
pump_hour_start: +this.pumpHourStart.value,
|
||||||
pump_hour_end: +this.pumpHourEnd.value,
|
pump_hour_end: +this.pumpHourEnd.value,
|
||||||
sensor_b: this.sensorBInstalled.checked,
|
sensor_b: this.sensorBInstalled.checked,
|
||||||
|
|||||||
Reference in New Issue
Block a user