This commit is contained in:
2026-07-05 19:12:54 +02:00
parent f614f75153
commit 134004fce9
3 changed files with 33 additions and 8 deletions

View File

@@ -40,11 +40,13 @@ STATUS_RE = re.compile(
r"spread=(?P<spread>[\d.]+)C\s+"
r"heatlim=(?P<heatlim>\d+)%\s+"
r"heater=(?P<heater>[\d.]+)%\s+"
r"fan=(?P<fan>\d+)(?P<fan_note>\([^)]*\))?\s+"
r"htop=(?P<htop>\S+)\s+"
r"hblk=(?P<hblk>\S+)\s+"
r"ssr=(?P<ssr>on|off)\s+"
r"fan=(?P<fan>\S+)\s+"
r"cutoff=(?P<cutoff_active>\S+)\s+"
r"failsafe=(?P<failsafe>\S+)\s+"
r"mode=(?P<mode>\S+)\s+"
r"sensors=\[(?P<sensors>.*)\]"
r"mode=(?P<mode>.+?)\s+sensors=\[(?P<sensors>.*)\]"
)
SENSOR_RE = re.compile(r"ch(\d+):([\d.]+)C/(\d+)%|ch(\d+):ERR")
@@ -60,6 +62,9 @@ class DryerState:
spread: str = ""
heatlim: str = ""
heater: str = ""
htop: str = ""
hblk: str = ""
ssr: str = ""
fan: str = ""
fan_note: str = ""
cutoff_active: str = "no"
@@ -91,7 +96,6 @@ def parse_status(line: str) -> dict | None:
else:
sensors.append((m.group(1), m.group(2), m.group(3)))
data["sensor_list"] = sensors
data["fan_note"] = data.get("fan_note") or ""
return data
@@ -116,8 +120,14 @@ def apply_status(state: DryerState, data: dict) -> None:
state.spread = data["spread"]
state.heatlim = data["heatlim"]
state.heater = data["heater"]
state.fan = data["fan"]
state.fan_note = data["fan_note"]
state.htop = data["htop"].removesuffix("C") if data["htop"].endswith("C") else data["htop"]
state.hblk = data["hblk"]
state.ssr = data["ssr"]
fan_raw = data["fan"]
state.fan = fan_raw
state.fan_note = ""
if fan_raw.endswith("(off)") or fan_raw.endswith("(cooldown)") or " TEST" in fan_raw:
state.fan_note = fan_raw[fan_raw.find("(") :] if "(" in fan_raw else ""
state.cutoff_active = data["cutoff_active"]
state.failsafe = data["failsafe"]
state.mode = data["mode"]
@@ -206,6 +216,10 @@ class SerialWorker:
apply_status(self.state, parsed)
continue
if line.startswith("target="):
self._note("WARN: could not parse status line")
continue
if line.startswith("OK") or line.startswith("ERR") or line.startswith("WARN"):
self._note(line)
@@ -324,8 +338,16 @@ def _draw_dashboard(stdscr, state: DryerState) -> None:
_safe_addstr(stdscr, row, 2, f"Avg: {state.avg} °C Min: {state.min_temp} °C Max: {state.max_temp} °C Spread: {state.spread} °C")
row += 1
fan_text = f"{state.fan} %{state.fan_note}"
_safe_addstr(stdscr, row, 2, f"Heater: {state.heater} % Fan: {fan_text} Limit: {state.heatlim} %")
fan_text = state.fan if state.fan_note == "" else state.fan
_safe_addstr(
stdscr,
row,
2,
f"Heater: {state.heater} % SSR: {state.ssr} Fan: {fan_text} Limit: {state.heatlim} %",
)
row += 1
_safe_addstr(stdscr, row, 2, f"Heat stop: {state.htop} °C Block: {state.hblk}")
row += 2
_draw_box(stdscr, row, 1, 5, width - 2, "Sensors")
@@ -403,6 +425,9 @@ def _curses_main(stdscr, ser, log_dir: Path, auto_log_on: bool) -> int:
spread=state.spread,
heatlim=state.heatlim,
heater=state.heater,
htop=state.htop,
hblk=state.hblk,
ssr=state.ssr,
fan=state.fan,
fan_note=state.fan_note,
cutoff_active=state.cutoff_active,