Use active_notes for audio indicator instead of separate file
Validate and Test / validate-patches (push) Failing after 13s

This commit is contained in:
2026-06-24 17:41:02 -07:00
parent 3db6b5904c
commit 61be770746
+4 -8
View File
@@ -23,9 +23,6 @@ AUDIO_COL = 4
NOTE_ROWS = 7 NOTE_ROWS = 7
NOTE_ROW_OFFSET = 1 NOTE_ROW_OFFSET = 1
AUDIO_SIGNAL_FILE = "/tmp/audio-signal-detect"
def _check_services(): def _check_services():
global STATUS_CACHE, LAST_STATUS_CHECK global STATUS_CACHE, LAST_STATUS_CHECK
now = time.monotonic() now = time.monotonic()
@@ -37,7 +34,6 @@ def _check_services():
STATUS_CACHE[svc] = r.stdout.strip() == "active" STATUS_CACHE[svc] = r.stdout.strip() == "active"
except Exception: except Exception:
STATUS_CACHE[svc] = False 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 LAST_STATUS_CHECK = now
return STATUS_CACHE return STATUS_CACHE
@@ -68,12 +64,12 @@ def render(active_notes):
col = SERVICE_COLS[idx] col = SERVICE_COLS[idx]
if status.get(svc): if status.get(svc):
pixels[STATUS_ROW][col] = 1 pixels[STATUS_ROW][col] = 1
if status.get("audio"): if len(active_notes) > 0:
pixels[STATUS_ROW][AUDIO_COL] = 1 pixels[STATUS_ROW][AUDIO_COL] = 1
return pack_frame(pixels) return pack_frame(pixels)
def _diag_frame(): def _diag_frame(active_notes):
pixels = [[0] * COLS for _ in range(ROWS)] pixels = [[0] * COLS for _ in range(ROWS)]
status = _check_services() status = _check_services()
for idx, svc in enumerate(SERVICES): for idx, svc in enumerate(SERVICES):
@@ -81,7 +77,7 @@ def _diag_frame():
if status.get(svc): if status.get(svc):
for r in range(ROWS): for r in range(ROWS):
pixels[r][col] = 1 pixels[r][col] = 1
if status.get("audio"): if len(active_notes) > 0:
for r in range(ROWS): for r in range(ROWS):
pixels[r][AUDIO_COL] = 1 pixels[r][AUDIO_COL] = 1
return pack_frame(pixels) return pack_frame(pixels)
@@ -166,7 +162,7 @@ def main():
diag_start = now diag_start = now
pre_diag_params = last_sent_params pre_diag_params = last_sent_params
msg_id = (msg_id + 1) % 65535 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: if ok:
frames_sent += 1 frames_sent += 1