From 615a97bcf7a430668444eb2f7b3dea05a118f90f Mon Sep 17 00:00:00 2001 From: cdez Date: Sat, 22 Nov 2025 21:03:11 -0700 Subject: [PATCH] Add new logic for checking the kiln state and displaying a new message based on that. --- kiln-logger.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/kiln-logger.py b/kiln-logger.py index 9a1e22d..a82973a 100755 --- a/kiln-logger.py +++ b/kiln-logger.py @@ -73,6 +73,10 @@ def logger(hostname, csvfile, noprofilestats, pidstats, stdout): # end setup seven segment display + # store the current state, default to IDLE + prev_kiln_state = "IDLE" + kiln_state = "IDLE" + while True: try: msg = json.loads(status_ws.recv()) @@ -88,6 +92,18 @@ def logger(hostname, csvfile, noprofilestats, pidstats, stdout): if msg.get('type') == 'backlog': continue + # get the current state, if the state changes from RUNNING to IDLE + if msg.get('state') == 'RUNNING': + if kiln_state == 'IDLE': + kiln_state = 'RUNNING' + prev_kiln_state = 'IDLE' + continue + if msg.get('state') == 'IDLE': + if kiln_state == 'RUNNING': + kiln_state = 'IDLE' + prev_kiln_state = 'RUNNING' + continue + if not noprofilestats: msg['stamp'] = time.time() if pidstats and 'pidstats' in msg: @@ -125,15 +141,15 @@ def logger(hostname, csvfile, noprofilestats, pidstats, stdout): temp = round(msg['temperature']) # time remaining for the display, calculated for rounded seconds time_rem = msg['totaltime'] - msg['runtime'] - if time_rem == -1 or msg['state'] == "IDLE": - if msg['state'] == "IDLE": - seg.text = f"READY...TEMP{temp:4.0f}" + if time_rem == -1 or kiln_state == 'IDLE': + if prev_kiln_state == 'IDLE': + seg.text = f"READY....TEMP{temp:4.0f}" else: seg.text = f"DONE....TEMP{temp:4.0f}" else: hours = round(time_rem // 3600) minutes = round((time_rem - (hours * 3600)) // 60) - seconds = round((time_rem - (hours * 3600) - (minutes * 60))) + seconds = round((time_rem - (hours * 3600) - (minutes * 60))) - 1 seg.text = f"{hours:2.0f}-{minutes:2.0f}-{seconds:2.0f}TEMP{temp:4.0f}" # END ADD TEMP