Merge pull request #26 from benkrasnow/master

Update oven.py
pull/1/head
chrono 2018-06-10 18:59:47 +00:00 zatwierdzone przez GitHub
commit db303ed921
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 15 dodań i 6 usunięć

Wyświetl plik

@ -101,6 +101,7 @@ class Oven (threading.Thread):
def run(self):
temperature_count = 0
last_temp = 0
pid = 0
while True:
self.door = self.get_door_state()
@ -132,8 +133,11 @@ class Oven (threading.Thread):
self.reset()
else:
temperature_count = 0
#Capture the last temperature value. This must be done before set_heat, since there is a sleep in there now.
last_temp = self.temp_sensor.temperature
self.set_heat(pid > 0)
self.set_heat(pid)
#if self.profile.is_rising(self.runtime):
# self.set_cool(False)
@ -150,19 +154,24 @@ class Oven (threading.Thread):
if self.runtime >= self.totaltime:
self.reset()
#Capture the last temperature value
last_temp = self.temp_sensor.temperature
time.sleep(self.time_step)
if pid > 0:
time.sleep(self.time_step * (1 - pid))
else:
time.sleep(self.time_step)
def set_heat(self, value):
if value:
if value > 0:
self.heat = 1.0
if gpio_available:
if config.heater_invert:
GPIO.output(config.gpio_heat, GPIO.LOW)
time.sleep(self.time_step * value)
GPIO.output(config.gpio_heat, GPIO.HIGH)
else:
GPIO.output(config.gpio_heat, GPIO.HIGH)
time.sleep(self.time_step * value)
GPIO.output(config.gpio_heat, GPIO.LOW)
else:
self.heat = 0.0
if gpio_available: