WIP refactor plant_state

This commit is contained in:
2025-04-18 01:05:12 +02:00
parent cf31ce8d43
commit 2b5c1da484
7 changed files with 263 additions and 409 deletions

View File

@@ -2,6 +2,7 @@ use std::str::FromStr;
use serde::{Deserialize, Serialize};
use crate::plant_state::PlantWateringMode;
use crate::PLANT_COUNT;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
@@ -83,8 +84,8 @@ pub struct PlantControllerConfig {
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[serde(default)]
pub struct PlantConfig {
pub mode: Mode,
pub target_moisture: u8,
pub mode: PlantWateringMode,
pub target_moisture: f32,
pub pump_time_s: u16,
pub pump_cooldown_min: u16,
pub pump_hour_start: u8,
@@ -96,8 +97,8 @@ pub struct PlantConfig {
impl Default for PlantConfig {
fn default() -> Self {
Self {
mode: Mode::OFF,
target_moisture: 40,
mode: PlantWateringMode::OFF,
target_moisture: 40.,
pump_time_s: 30,
pump_cooldown_min: 60,
pump_hour_start: 9,
@@ -108,11 +109,3 @@ impl Default for PlantConfig {
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum Mode {
OFF,
TargetMoisture,
TimerOnly,
TimerAndDeadzone,
}