From 7706517b886f4547647d70a3ce005029fedae182 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Wed, 24 Jun 2026 02:39:37 -0700 Subject: [PATCH] fix: initialize stats_last_write inside main() to avoid UnboundLocalError --- scripts/led-matrix-viz.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/led-matrix-viz.py b/scripts/led-matrix-viz.py index 818df6c..2134d4e 100644 --- a/scripts/led-matrix-viz.py +++ b/scripts/led-matrix-viz.py @@ -94,6 +94,7 @@ def main(): frames_sent = 0 frames_dropped = 0 router_errors = 0 + stats_last_write = time.monotonic() while True: now = time.monotonic() @@ -193,9 +194,9 @@ def main(): last_frame = frame # Write stats periodically (every 2s) - if now - _stats_last_write >= 2.0: + if now - stats_last_write >= 2.0: _write_stats(frames_sent, frames_dropped, pending_frames) - _stats_last_write = now + stats_last_write = now _stats_last_write = 0.0