diff --git a/__init__.py b/__init__.py index 227e575..67e55c1 100644 --- a/__init__.py +++ b/__init__.py @@ -26,10 +26,17 @@ def run(self): heat_percent = pid.calc(self.get_temp(), self.get_target_temp()) heating_time = sampleTime * heat_percent / 100 wait_time = sampleTime - heating_time - self.heater_on(100) - self.sleep(heating_time) - self.heater_off() - self.sleep(wait_time) + if heating_time == sampleTime: + self.heater_on(100) + self.sleep(heating_time) + elif wait_time == sampleTime: + self.heater_off() + self.sleep(wait_time) + else: + self.heater_on(100) + self.sleep(heating_time) + self.heater_off() + self.sleep(wait_time) # Based on Arduino PID Library # See https://github.com/br3ttb/Arduino-PID-Library