display errors

This commit is contained in:
John Pickup 2023-06-21 21:43:49 +01:00
parent 31f352ed49
commit b0307f2e07
2 changed files with 12 additions and 3 deletions

View File

@ -269,7 +269,6 @@ class Oven(threading.Thread):
self.start_time = datetime.datetime.now() - datetime.timedelta(milliseconds = self.runtime * 1000) self.start_time = datetime.datetime.now() - datetime.timedelta(milliseconds = self.runtime * 1000)
def update_runtime(self): def update_runtime(self):
runtime_delta = datetime.datetime.now() - self.start_time runtime_delta = datetime.datetime.now() - self.start_time
if runtime_delta.total_seconds() < 0: if runtime_delta.total_seconds() < 0:
runtime_delta = datetime.timedelta(0) runtime_delta = datetime.timedelta(0)
@ -578,6 +577,8 @@ class Profile():
return (prev_point, next_point) return (prev_point, next_point)
def get_target_temperature(self, time): def get_target_temperature(self, time):
#log.info("time = " + str(time))
#log.info("duration = " + str(self.get_duration()))
if time > self.get_duration(): if time > self.get_duration():
return 0 return 0
@ -620,12 +621,15 @@ class PID():
output = 0 output = 0
out4logs = 0 out4logs = 0
dErr = 0 dErr = 0
status = ''
if error < (-1 * config.pid_control_window): if error < (-1 * config.pid_control_window):
status = "kiln outside pid control window, max cooling"
log.info("kiln outside pid control window, max cooling") log.info("kiln outside pid control window, max cooling")
output = 0 output = 0
# it is possible to set self.iterm=0 here and also below # it is possible to set self.iterm=0 here and also below
# but I dont think its needed # but I dont think its needed
elif error > (1 * config.pid_control_window): elif error > (1 * config.pid_control_window):
status = "kiln outside pid control window, max heating"
log.info("kiln outside pid control window, max heating") log.info("kiln outside pid control window, max heating")
output = 1 output = 1
else: else:
@ -659,6 +663,7 @@ class PID():
'kd': self.kd, 'kd': self.kd,
'pid': out4logs, 'pid': out4logs,
'out': output, 'out': output,
'status': status,
} }
return output return output

View File

@ -106,16 +106,20 @@ class OvenDisplay(threading.Thread):
displayhatmini.set_led(1.0, 0.0, 0.0) displayhatmini.set_led(1.0, 0.0, 0.0)
else: else:
displayhatmini.set_led(0.0, 0.0, 1.0) displayhatmini.set_led(0.0, 0.0, 1.0)
message = ''
if (oven_state['totaltime'] is not None and oven_state['runtime'] is not None): if (oven_state['totaltime'] is not None and oven_state['runtime'] is not None):
total_time = oven_state['totaltime'] total_time = oven_state['totaltime']
run_time = oven_state['runtime'] run_time = oven_state['runtime']
time_left = total_time - run_time time_left = total_time - run_time
time_left_str = str(datetime.timedelta(seconds=round(time_left))) time_left_str = str(datetime.timedelta(seconds=round(time_left)))
self.text('Remaining: ' + time_left_str, (10, 195), fnt25, (255, 255, 255)) message = 'Remaining: ' + time_left_str;
if (oven_state['pidstats'] is not None and oven_state['pidstats']['status'] is not None):
message = 'ERROR: ' + oven_state['pidstats']['status']
self.text(message, (10, 195), fnt25, (255, 255, 255))
displayhatmini.display() displayhatmini.display()
def send(self,oven_state_json): def send(self,oven_state_json):
log.info(oven_state_json) #log.info(oven_state_json)
oven_state = json.loads(oven_state_json) oven_state = json.loads(oven_state_json)
self.update_display(oven_state) self.update_display(oven_state)