Skip to content

Commit 5b6c639

Browse files
committed
Update animation UI
1 parent ed29e30 commit 5b6c639

File tree

1 file changed

+6
-4
lines changed
  • examples/led-matrix-painter/python

1 file changed

+6
-4
lines changed

examples/led-matrix-painter/python/main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,13 @@ def play_animation(payload: dict):
304304
animation_bytes = bytearray()
305305
for frame in frames:
306306
hex_values = frame.to_animation_hex()
307-
# Convert hex strings to uint32_t integers, then to bytes
308-
for hex_str in hex_values:
309-
value = int(hex_str, 16)
310-
# Pack as 4 bytes, little-endian
307+
# First 4 are hex pixel data
308+
for i in range(4):
309+
value = int(hex_values[i], 16)
311310
animation_bytes.extend(value.to_bytes(4, byteorder='little'))
311+
# 5th is duration in ms
312+
duration = int(hex_values[4])
313+
animation_bytes.extend(duration.to_bytes(4, byteorder='little'))
312314

313315
logger.debug(f"Animation data prepared: {len(animation_bytes)} bytes ({len(animation_bytes)//20} frames)")
314316

0 commit comments

Comments
 (0)