From 5ae5916400ff8c492a062a67563139e64235ad8c Mon Sep 17 00:00:00 2001 From: Tanaes Date: Sat, 5 Feb 2022 11:31:30 -0500 Subject: [PATCH] moved display code to oven --- lib/oven.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ lib/ovenWatcher.py | 40 ---------------------------------------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/lib/oven.py b/lib/oven.py index 380010b..4b56716 100644 --- a/lib/oven.py +++ b/lib/oven.py @@ -46,6 +46,30 @@ class Output(object): time.sleep(sleepfor) + +class Display(object): + def __init__(self, + type, + pins): + + if type == "TMC1637": + self.disp = TM1637(pins['clock'], + pins['data']) + + def temp(self, t): + self.disp.temp(t) + + def time(self, h, m): + self.disp.time(h, m) + + def off(self): + self.disp.off() + + def text(self, text): + self.disp.text(text) + + + # FIX - Board class needs to be completely removed class Board(object): def __init__(self): @@ -399,6 +423,26 @@ class RealOven(Oven): # start thread self.start() + + try: + self.time_disp = Display(config.time_disp['type'], + config.time_disp['pins']) + self.time_disp.show('TIME') + except NameError: + self.time_disp = False + + try: + self.temp_disp = Display(config.temp_disp['type'], + config.temp_disp['pins']) + self.time_disp.show('TEMP') + except NameError: + self.temp_disp = False + + # if self.time_disp: + # self.time_disp.time(oven_state['runtime']) + # if self.temp_disp: + # self.temp_disp.temp(oven_state['temperature']) + def reset(self): super().reset() self.output.safety_on() diff --git a/lib/ovenWatcher.py b/lib/ovenWatcher.py index 9eb1a16..aa9e1fa 100644 --- a/lib/ovenWatcher.py +++ b/lib/ovenWatcher.py @@ -6,28 +6,6 @@ import config log = logging.getLogger(__name__) -class Display(object): - def __init__(self, - type, - pins): - - if type == "TMC1637": - self.disp = TM1637(pins['clock'], - pins['data']) - - def temp(self, t): - self.disp.temp(t) - - def time(self, h, m): - self.disp.time(h, m) - - def off(self): - self.disp.off() - - def text(self, text): - self.disp.text(text) - - class OvenWatcher(threading.Thread): def __init__(self,oven): self.last_profile = None @@ -36,20 +14,6 @@ class OvenWatcher(threading.Thread): self.recording = False self.observers = [] - try: - self.time_disp = Display(config.time_disp['type'], - config.time_disp['pins']) - self.time_disp.show('TIME') - except NameError: - self.time_disp = False - - try: - self.temp_disp = Display(config.temp_disp['type'], - config.temp_disp['pins']) - self.time_disp.show('TEMP') - except NameError: - self.temp_disp = False - threading.Thread.__init__(self) self.daemon = True self.oven = oven @@ -74,10 +38,6 @@ class OvenWatcher(threading.Thread): else: self.recording = False self.notify_all(oven_state) - if self.time_disp: - self.time_disp.time(oven_state['runtime']) - if self.temp_disp: - self.temp_disp.temp(oven_state['temperature']) time.sleep(self.oven.time_step) def lastlog_subset(self,maxpts=50):