Skip to content

Commit

Permalink
Implement heating state
Browse files Browse the repository at this point in the history
  • Loading branch information
acodili-jg committed May 11, 2024
1 parent fc11529 commit d8082a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ constants! {
DEFAULT_SHORT = Millis(250);

DRAINING = DEFAULT_LONG;
HEATING = DEFAULT_LONG;
LOCKING = DEFAULT_SHORT;
SOAK_WATER_PUMPING = DEFAULT_LONG;
SEPARATOR_TRANSITION = DEFAULT;
SOAK_WATER_PUMPING = DEFAULT_LONG;
}
18 changes: 17 additions & 1 deletion src/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Sketch {
pub fn invoke(&mut self) {
let curr_ms = millis();
let delta_ms = curr_ms.wrapping_sub(self.last_ms);
let _stop = self.stop.is_low();
let stop = self.stop.is_low();

macro_rules! transition_to {
($state:ident) => {
Expand Down Expand Up @@ -132,13 +132,29 @@ impl Sketch {
self.water_pump.set_high();
}

State::SoakWaterPumping if stop => {
transition_to!(SoakWaterDraining);
self.upper_drain_pump.set_high();
self.water_pump.set_low();
}
State::SoakWaterPumping if delta_ms < duration::SOAK_WATER_PUMPING => {}
State::SoakWaterPumping => {
transition_to!(SoakWaterHeating);
self.water_pump.set_low();
self.heater.set_high();
}

State::SoakWaterHeating if stop => {
transition_to!(SoakWaterDraining);
self.heater.set_low();
self.upper_drain_pump.set_high();
}
State::SoakWaterHeating if delta_ms < duration::HEATING => {}
State::SoakWaterHeating => {
transition_to!(SoakWaterHeatedMixing);
self.mixer.set_high();
}

_ => { /* TODO */ }
}
}
Expand Down

0 comments on commit d8082a6

Please sign in to comment.