From b0bdb6a9752d91b7881347b13c4b6a2b57bca7cc Mon Sep 17 00:00:00 2001 From: Nareshkumar Rao Date: Fri, 3 May 2024 00:18:53 +0200 Subject: [PATCH] wip --- src/actuators.rs | 1 + src/state.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/actuators.rs b/src/actuators.rs index ef862ec..966eb58 100644 --- a/src/actuators.rs +++ b/src/actuators.rs @@ -57,6 +57,7 @@ pub fn pump_water(water_mass_g: u16, program_state: &mut ProgramState) -> Generi .history .watering_records .push(WateringRecord::new(water_mass_g.into())); + program_state.history.save()?; Ok(()) } diff --git a/src/state.rs b/src/state.rs index 9458dd4..7c49982 100644 --- a/src/state.rs +++ b/src/state.rs @@ -11,7 +11,7 @@ pub struct ProgramState { pub fn init_state(config: Configuration) -> GenericResult { let relay = io::Relay::new(&config)?; - let history = History::load()?; + let history = History::load().unwrap_or_default(); Ok(Arc::new(Mutex::new(ProgramState { config, relay,