Nareshkumar Rao 7 months ago
parent
commit
b0bdb6a975
  1. 1
      src/actuators.rs
  2. 2
      src/state.rs

1
src/actuators.rs

@ -57,6 +57,7 @@ pub fn pump_water(water_mass_g: u16, program_state: &mut ProgramState) -> Generi
.history .history
.watering_records .watering_records
.push(WateringRecord::new(water_mass_g.into())); .push(WateringRecord::new(water_mass_g.into()));
program_state.history.save()?;
Ok(()) Ok(())
} }

2
src/state.rs

@ -11,7 +11,7 @@ pub struct ProgramState {
pub fn init_state(config: Configuration) -> GenericResult<ProgramStateShared> { pub fn init_state(config: Configuration) -> GenericResult<ProgramStateShared> {
let relay = io::Relay::new(&config)?; let relay = io::Relay::new(&config)?;
let history = History::load()?;
let history = History::load().unwrap_or_default();
Ok(Arc::new(Mutex::new(ProgramState { Ok(Arc::new(Mutex::new(ProgramState {
config, config,
relay, relay,

Loading…
Cancel
Save