From d82ae4223a5e36bdb09f4a442034e50a68ef42df Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Nov 2026 09:06:19 +0000 Subject: [PATCH] Fix simple-receiver example for short frames and row layout The example indexed data.values directly, so it panicked as soon as a source sent fewer than 273 slots. It also used a row stride of 16 with 32 columns, so rows overlapped and only slots 1 to 272 were shown. Show all 512 slots in 16 rows of 32, treating missing trailing slots as 0. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KzaQVPkrkczgX2g7wGkip5 --- examples/simple-receiver.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/simple-receiver.rs b/examples/simple-receiver.rs index d27b314b..069bd7c5 100644 --- a/examples/simple-receiver.rs +++ b/examples/simple-receiver.rs @@ -81,12 +81,15 @@ fn display_data(stdout: &mut Stdout, remaining: &Duration, data: &DMXData) { let cursor_y = y + 1; queue!(stdout, cursor::MoveTo(0, cursor_y), Print("|")).unwrap(); for x in 0..32 { - let data_index = ((y * 16 + x) + 1) as usize; + // 16 rows of 32 slots shows all 512 slots. Index 0 is the START code, so slots start at 1. + let data_index = ((y * 32 + x) + 1) as usize; let cursor_x = x * 4 + 1; + // Sources may send fewer than 512 slots; the missing trailing slots are 0. + let value = data.values.get(data_index).copied().unwrap_or(0); queue!( stdout, cursor::MoveTo(cursor_x, cursor_y), - Print(format!("{:03}|", data.values[data_index])) + Print(format!("{value:03}|")) ) .unwrap(); }