fix py
This commit is contained in:
Binary file not shown.
@@ -51,6 +51,21 @@ STATUS_RE = re.compile(
|
||||
|
||||
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
|
||||
class DryerState:
|
||||
@@ -320,8 +335,8 @@ def _preset_menu(stdscr, worker: SerialWorker) -> None:
|
||||
def _draw_dashboard(stdscr, state: DryerState) -> None:
|
||||
stdscr.erase()
|
||||
height, width = stdscr.getmaxyx()
|
||||
if height < 18 or width < 60:
|
||||
_safe_addstr(stdscr, 0, 0, "Terminal too small (need 60x18).")
|
||||
if height < 19 or width < 60:
|
||||
_safe_addstr(stdscr, 0, 0, "Terminal too small (need 60x19).")
|
||||
stdscr.refresh()
|
||||
return
|
||||
|
||||
@@ -329,13 +344,16 @@ def _draw_dashboard(stdscr, state: DryerState) -> None:
|
||||
_safe_addstr(stdscr, 0, 1, title, curses.A_BOLD)
|
||||
|
||||
row = 2
|
||||
_safe_addstr(stdscr, row, 2, f"Target: {state.target:>8} °C", curses.A_BOLD)
|
||||
_safe_addstr(stdscr, row, 28, f"Mode: {state.mode}")
|
||||
_safe_addstr(stdscr, row, 2, f"Target: {state.target:>6} C Limit: {state.cutoff} C", curses.A_BOLD)
|
||||
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
|
||||
_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
|
||||
fan_text = state.fan if state.fan_note == "" else state.fan
|
||||
@@ -347,7 +365,7 @@ def _draw_dashboard(stdscr, state: DryerState) -> None:
|
||||
)
|
||||
|
||||
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
|
||||
_draw_box(stdscr, row, 1, 5, width - 2, "Sensors")
|
||||
|
||||
Reference in New Issue
Block a user