diff --git a/scripts/led-matrix-viz.py b/scripts/led-matrix-viz.py index 92649a7..42c8d95 100755 --- a/scripts/led-matrix-viz.py +++ b/scripts/led-matrix-viz.py @@ -23,9 +23,6 @@ AUDIO_COL = 4 NOTE_ROWS = 7 NOTE_ROW_OFFSET = 1 -AUDIO_SIGNAL_FILE = "/tmp/audio-signal-detect" - - def _check_services(): global STATUS_CACHE, LAST_STATUS_CHECK now = time.monotonic() @@ -37,7 +34,6 @@ def _check_services(): STATUS_CACHE[svc] = r.stdout.strip() == "active" except Exception: STATUS_CACHE[svc] = False - STATUS_CACHE["audio"] = os.path.exists(AUDIO_SIGNAL_FILE) and (time.time() - os.path.getmtime(AUDIO_SIGNAL_FILE) < 5.0) LAST_STATUS_CHECK = now return STATUS_CACHE @@ -68,12 +64,12 @@ def render(active_notes): col = SERVICE_COLS[idx] if status.get(svc): pixels[STATUS_ROW][col] = 1 - if status.get("audio"): + if len(active_notes) > 0: pixels[STATUS_ROW][AUDIO_COL] = 1 return pack_frame(pixels) -def _diag_frame(): +def _diag_frame(active_notes): pixels = [[0] * COLS for _ in range(ROWS)] status = _check_services() for idx, svc in enumerate(SERVICES): @@ -81,7 +77,7 @@ def _diag_frame(): if status.get(svc): for r in range(ROWS): pixels[r][col] = 1 - if status.get("audio"): + if len(active_notes) > 0: for r in range(ROWS): pixels[r][AUDIO_COL] = 1 return pack_frame(pixels) @@ -166,7 +162,7 @@ def main(): diag_start = now pre_diag_params = last_sent_params msg_id = (msg_id + 1) % 65535 - router, ok = _send_frame(router, packer, _diag_frame(), msg_id) + router, ok = _send_frame(router, packer, _diag_frame(active_notes), msg_id) if ok: frames_sent += 1