Add Docker deployment support, richer Selenium/LED pattern tests, in-browser diagnostics, responsive UI improvements, and 16x16 panel simulation tooling to speed iteration and hardware-style prototyping. Made-with: Cursor
42 lines
844 B
Python
42 lines
844 B
Python
"""16x16 bouncing pixel with fading trail."""
|
|
|
|
from machine import Pin
|
|
import neopixel
|
|
import time
|
|
|
|
from panel16_utils import PANEL_H, PANEL_W, clamp8, xy_to_index
|
|
|
|
|
|
np = neopixel.NeoPixel(Pin(4), PANEL_W * PANEL_H)
|
|
|
|
trail = [[0 for _ in range(PANEL_W)] for _ in range(PANEL_H)]
|
|
x = 0
|
|
y = 0
|
|
vx = 1
|
|
vy = 1
|
|
|
|
for _frame in range(420):
|
|
for yy in range(PANEL_H):
|
|
for xx in range(PANEL_W):
|
|
trail[yy][xx] = max(0, trail[yy][xx] - 14)
|
|
|
|
trail[y][x] = 255
|
|
|
|
for yy in range(PANEL_H):
|
|
for xx in range(PANEL_W):
|
|
v = trail[yy][xx]
|
|
np[xy_to_index(xx, yy)] = (clamp8(v), clamp8(v // 2), clamp8(30))
|
|
|
|
np.write()
|
|
time.sleep(0.02)
|
|
|
|
x += vx
|
|
y += vy
|
|
if x <= 0 or x >= PANEL_W - 1:
|
|
vx *= -1
|
|
if y <= 0 or y >= PANEL_H - 1:
|
|
vy *= -1
|
|
|
|
np.fill((0, 0, 0))
|
|
np.write()
|