`workspace/` is runtime state (per-user folders, no-auth dev's `code/`) and shouldn't be in git. The same files were previously committed under both `workspace/code/` and `src/static/bundled-demos/`, which forced a Docker `diff -q` sync check and leaked user-scoped paths into version control. - /workspace/ added to .gitignore; all previously tracked files removed via `git rm --cached`. - src/static/bundled-demos/ becomes the single source of truth: panel16 demos, led_tutorial, led_patterns, neopixel demos, and main.py move here alongside the existing canonical demos. - New BUNDLED_DEMOS_DIR config; user_workspace seeders read from it. - main.py lifespan seeds WORKSPACE_ROOT/code/ on startup so a fresh clone running `pipenv run dev` still gets the full sample set (existing files never overwritten — user edits survive restarts). - Dockerfile drops `COPY workspace` and the diff sanity check. - README/LED_TUTORIAL repointed at the new canonical paths. - test_led_patterns loads led_patterns.py from bundled-demos. - test_api uses mkdir(exist_ok=True) for `code/` (startup pre-creates). Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
884 B
Python
38 lines
884 B
Python
"""16x16 matrix-style rain animation."""
|
|
|
|
from machine import Pin
|
|
import neopixel
|
|
import random
|
|
import time
|
|
|
|
from panel16_utils import PANEL_H, PANEL_W, clamp8, xy_to_index
|
|
|
|
|
|
np = neopixel.NeoPixel(Pin(4), PANEL_W * PANEL_H)
|
|
rng = random.Random(42)
|
|
|
|
heads = [rng.randrange(-PANEL_H, 0) for _ in range(PANEL_W)]
|
|
|
|
for _frame in range(320):
|
|
for y in range(PANEL_H):
|
|
for x in range(PANEL_W):
|
|
np[xy_to_index(x, y)] = (0, 0, 0)
|
|
|
|
for x in range(PANEL_W):
|
|
heads[x] += 1
|
|
if heads[x] > PANEL_H + 6:
|
|
heads[x] = rng.randrange(-PANEL_H, 0)
|
|
|
|
head_y = heads[x]
|
|
for tail in range(8):
|
|
y = head_y - tail
|
|
if 0 <= y < PANEL_H:
|
|
brightness = clamp8(255 - tail * 36)
|
|
np[xy_to_index(x, y)] = (0, brightness, 0)
|
|
|
|
np.write()
|
|
time.sleep(0.045)
|
|
|
|
np.fill((0, 0, 0))
|
|
np.write()
|