This commit is contained in:
2026-07-05 19:14:26 +02:00
parent 134004fce9
commit e1c24d0552
2 changed files with 25 additions and 7 deletions

View File

@@ -51,6 +51,21 @@ STATUS_RE = re.compile(
SENSOR_RE = re.compile(r"ch(\d+):([\d.]+)C/(\d+)%|ch(\d+):ERR") SENSOR_RE = re.compile(r"ch(\d+):([\d.]+)C/(\d+)%|ch(\d+):ERR")
AUTOTUNE_MODE_RE = re.compile(
r"autotune/(?P<phase>\w+) (?P<elapsed>\d+)s (?P<cycles>\d+/\d+)cyc pre>=(?P<pre>\d+)C"
)
def format_mode_line(mode: str) -> str:
match = AUTOTUNE_MODE_RE.match(mode)
if match:
d = match.groupdict()
return (
f"Autotune {d['phase']}: {d['elapsed']}s elapsed, "
f"{d['cycles']} cycles, preheat avg >= {d['pre']} C"
)
return f"Mode: {mode}"
@dataclass @dataclass
class DryerState: class DryerState:
@@ -320,8 +335,8 @@ def _preset_menu(stdscr, worker: SerialWorker) -> None:
def _draw_dashboard(stdscr, state: DryerState) -> None: def _draw_dashboard(stdscr, state: DryerState) -> None:
stdscr.erase() stdscr.erase()
height, width = stdscr.getmaxyx() height, width = stdscr.getmaxyx()
if height < 18 or width < 60: if height < 19 or width < 60:
_safe_addstr(stdscr, 0, 0, "Terminal too small (need 60x18).") _safe_addstr(stdscr, 0, 0, "Terminal too small (need 60x19).")
stdscr.refresh() stdscr.refresh()
return return
@@ -329,13 +344,16 @@ def _draw_dashboard(stdscr, state: DryerState) -> None:
_safe_addstr(stdscr, 0, 1, title, curses.A_BOLD) _safe_addstr(stdscr, 0, 1, title, curses.A_BOLD)
row = 2 row = 2
_safe_addstr(stdscr, row, 2, f"Target: {state.target:>8} °C", curses.A_BOLD) _safe_addstr(stdscr, row, 2, f"Target: {state.target:>6} C Limit: {state.cutoff} C", curses.A_BOLD)
_safe_addstr(stdscr, row, 28, f"Mode: {state.mode}")
cutoff_attr = curses.A_BOLD | curses.color_pair(1) if state.cutoff_active == "YES" else 0 cutoff_attr = curses.A_BOLD | curses.color_pair(1) if state.cutoff_active == "YES" else 0
_safe_addstr(stdscr, row, 48, f"Cutoff: {state.cutoff_active}", cutoff_attr) _safe_addstr(stdscr, row, 36, f"Trip: {state.cutoff_active}", cutoff_attr)
row += 1 row += 1
_safe_addstr(stdscr, row, 2, f"Avg: {state.avg} °C Min: {state.min_temp} °C Max: {state.max_temp} °C Spread: {state.spread} °C") mode_text = format_mode_line(state.mode)
_safe_addstr(stdscr, row, 2, f"{mode_text[: max(0, width - 18)]} FS: {state.failsafe}")
row += 1
_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 row += 1
fan_text = state.fan if state.fan_note == "" else state.fan fan_text = state.fan if state.fan_note == "" else state.fan
@@ -347,7 +365,7 @@ def _draw_dashboard(stdscr, state: DryerState) -> None:
) )
row += 1 row += 1
_safe_addstr(stdscr, row, 2, f"Heat stop: {state.htop} °C Block: {state.hblk}") _safe_addstr(stdscr, row, 2, f"Heat stop: {state.htop} C Block: {state.hblk}")
row += 2 row += 2
_draw_box(stdscr, row, 1, 5, width - 2, "Sensors") _draw_box(stdscr, row, 1, 5, width - 2, "Sensors")