From 583bfb72e227660e8f83b3bedcc285fe2aeccd70 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 30 Mar 2026 08:47:23 -0600 Subject: [PATCH] feat: auto-off display after 60s idle in meshcore_rx.py, wake on RX activity --- examples/meshcore/meshcore_rx.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/examples/meshcore/meshcore_rx.py b/examples/meshcore/meshcore_rx.py index 4ded82e0..9e0686a3 100755 --- a/examples/meshcore/meshcore_rx.py +++ b/examples/meshcore/meshcore_rx.py @@ -896,6 +896,9 @@ def _format_rssi_snr(rssi: int, snr: int) -> str: return line +DISPLAY_IDLE_TIMEOUT = 60 # seconds — turn display off when no activity + + def configure_and_listen(ser: serial.Serial): send_cmd(ser, {"type": "Ping"}, "Ping") send_cmd(ser, {"type": "SetConfig", "config": RADIO_CONFIG}, "SetConfig 910.525/62.5k/SF7/CR4/5") @@ -904,18 +907,33 @@ def configure_and_listen(ser: serial.Serial): print(f"\n{BWHT}Listening for packets{RST} {DIM}(Ctrl+C to stop){RST}\n") ser.timeout = 1 + last_activity = time.monotonic() + display_off = False + while True: try: _aggregator.maybe_report(ser) except Exception as e: print(f" {RED}[report error: {e}]{RST}") + # Auto-off display after idle timeout + now = time.monotonic() + if not display_off and now - last_activity > DISPLAY_IDLE_TIMEOUT: + send_cmd(ser, {"type": "DisplayOff"}, "DisplayOff (idle)") + display_off = True + data = read_frame(ser) if data is None: continue try: resp = decode_response(data) if resp["type"] == "RxPacket": + # Wake display on activity + if display_off: + send_cmd(ser, {"type": "DisplayOn"}, "DisplayOn (activity)") + display_off = False + last_activity = time.monotonic() + payload = resp["payload"] decoded = decode_meshcore_packet(payload) rssi_snr = _format_rssi_snr(resp["rssi"], resp["snr"])