From f496712c04267353ad100f7263df89d9827d0ba3 Mon Sep 17 00:00:00 2001 From: Tanaes Date: Sat, 8 Jan 2022 22:15:01 -0500 Subject: [PATCH] fixed errors --- config.py | 12 ++++++------ lib/display.py | 43 +++++++++++++++++++++++-------------------- lib/ovenWatcher.py | 19 +++++++++---------- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/config.py b/config.py index 3126e32..0dda021 100644 --- a/config.py +++ b/config.py @@ -44,13 +44,13 @@ gpio_fan = 22 # pin 15 ## Display outputs -time_disp = {'type': 'TMC1637', - 'pins': {'clock': 16, # pin 36 - 'data': 26}} # pin 37 +temp_disp = {'type': 'TMC1637', + 'pins': {'clock': 16, + 'data': 26}} # pin 36, pin 37 time_disp = {'type': 'TMC1637', - 'pins': {'clock': 20, # pin 38 - 'data': 21}} # pin 40 + 'pins': {'clock': 20, + 'data': 21}} # pin 38, pin 40 gpio_dotstar_clk = 19 # pin 35 gpio_dotstar_dat = 13 # pin 33 @@ -67,7 +67,7 @@ max31855 = 0 max31856 = 1 # see lib/max31856.py for other thermocouple_type, only applies to max31856 # uncomment this if using MAX-31856 -thermocouple_type = MAX31856.MAX31856_K_TYPE +# thermocouple_type = MAX31856.MAX31856_K_TYPE ### Thermocouple Connection (using bitbang interfaces) gpio_sensor_cs = 8 # pin 24 diff --git a/lib/display.py b/lib/display.py index e4e00ae..5f6d498 100644 --- a/lib/display.py +++ b/lib/display.py @@ -1,27 +1,30 @@ class TM1637(object): - def __init__(self, - clk_pin, - dat_pin): + def __init__(self, + clk_pin, + dat_pin): - self.clk_pin = clock_pin - self.dat_pin = dat_pin + self.clk_pin = clock_pin + self.dat_pin = dat_pin - try: - import tm1637 - self.tm = tm1637.TM1637(clk=clk_pin, - dio=dat_pin) - def temp(self, - t): - self.tm.number(t) + try: + import tm1637 + self.tm = tm1637.TM1637(clk=clk_pin, + dio=dat_pin) + except ImportError: + print('import failure') - def time(self, - h, - m): - self.tm.numbers(h, m, True) + def temp(self, + t): + self.tm.number(t) - def text(self, - text): - self.tm.show(text[0:4]) + def time(self, + h, + m): + self.tm.numbers(h, m, True) + + def text(self, + text): + self.tm.show(text[0:4]) def off(self): - self.tm.write([0, 0, 0, 0]) + self.tm.write([0, 0, 0, 0]) diff --git a/lib/ovenWatcher.py b/lib/ovenWatcher.py index 991ce16..4506cbb 100644 --- a/lib/ovenWatcher.py +++ b/lib/ovenWatcher.py @@ -12,7 +12,7 @@ class Display(object): pins): if type == "TMC1637": - self.disp = TM1637(pins['clock'] + self.disp = TM1637(pins['clock'], pins['data']) def temp(self, t): @@ -35,24 +35,23 @@ class OvenWatcher(threading.Thread): self.started = None self.recording = False self.observers = [] - threading.Thread.__init__(self) - self.daemon = True - self.oven = oven - self.start() - self.time_disp = None - self.temp_disp = None try: self.time_disp = Display(config.time_disp['type'], config.time_disp['pins']) except NameError: - self.time_disp = None + self.time_disp = False try: self.temp_disp = Display(config.temp_disp['type'], config.temp_disp['pins']) - except NameErro: - self.temp_disp = None + except NameError: + self.temp_disp = False + + threading.Thread.__init__(self) + self.daemon = True + self.oven = oven + self.start() # FIXME - need to save runs of schedules in near-real-time