From 3410a271fd8c1dbbbeaf48a4976e751d35d8b213 Mon Sep 17 00:00:00 2001 From: linuswck Date: Mon, 22 Jul 2024 10:53:52 +0800 Subject: [PATCH] thermostat: rst pid_state at pwr_up --- src/thermostat/thermostat.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/thermostat/thermostat.rs b/src/thermostat/thermostat.rs index 58cd346..bc222b5 100644 --- a/src/thermostat/thermostat.rs +++ b/src/thermostat/thermostat.rs @@ -213,12 +213,14 @@ impl Thermostat { } pub fn power_up(&mut self) { - self.max1968.power_up(); + if !self.max1968.is_powered_on() { + self.max1968.power_up(); + self.pid_ctrl_ch0.reset_pid_state(); + } } pub fn power_down(&mut self) { self.max1968.power_down(); - self.pid_ctrl_ch0.reset_pid_state(); } fn set_center_pt(&mut self, value: ElectricPotential) {