don't change the GPIO unless we actually need to

pull/27/head
Andrew de Quincey 2021-05-15 18:44:56 +01:00
rodzic 6f92021f09
commit 225e591f35
1 zmienionych plików z 9 dodań i 3 usunięć

Wyświetl plik

@ -30,10 +30,10 @@ class Output(object):
def heat(self,sleepfor):
self.GPIO.output(config.gpio_heat, self.GPIO.HIGH)
time.sleep(sleepfor)
self.GPIO.output(config.gpio_heat, self.GPIO.LOW)
def cool(self,sleepfor):
'''no active cooling, so sleep'''
self.GPIO.output(config.gpio_heat, self.GPIO.LOW)
time.sleep(sleepfor)
# FIX - Board class needs to be completely removed
@ -383,6 +383,10 @@ class RealOven(Oven):
# start thread
self.start()
def reset(self):
super().reset()
self.output.cool(0)
def heat_then_cool(self):
pid = self.pid.compute(self.target,
self.board.temp_sensor.temperature +
@ -395,8 +399,10 @@ class RealOven(Oven):
if heat_on > 0:
self.heat = 1.0
self.output.heat(heat_on)
self.output.cool(heat_off)
if self.output.heat_on:
self.output.heat(heat_on)
if heat_off:
self.output.cool(heat_off)
time_left = self.totaltime - self.runtime
log.info("temp=%.2f, target=%.2f, pid=%.3f, heat_on=%.2f, heat_off=%.2f, run_time=%d, total_time=%d, time_left=%d" %
(self.board.temp_sensor.temperature + config.thermocouple_offset,