diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 89fd150..642f881 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -143,7 +143,7 @@ Plans: Plans: - [ ] 07-01: Firmware scaffold — MicroPython UDP socket listener, packet type discriminator, device config (LED count, strip type) -- [ ] 07-02: Animation command renderer — parse animation+params packets, run animations on LED strip +- [x] 07-02: Animation command renderer — parse animation+params packets, run animations on LED strip - [ ] 07-03: Frame mode renderer — parse DRGB/DRGBW frames, handle multi-packet reassembly, output to physical strip ## Progress @@ -159,4 +159,4 @@ Phases execute in numeric order: 1 → 2 → 3 → 4 → 5 → 6 → 7 | 4. Timeline Editor | 4/4 | Complete | 2026-04-06 | | 5. Live Show Execution | 4/4 | Complete | 2026-04-07 | | 6. AI Sync | 3/3 | Complete | 2026-04-07 | -| 7. Microcontroller Firmware | 0/3 | Not started | - | +| 7. Microcontroller Firmware | 1/3 | In Progress| | diff --git a/.planning/STATE.md b/.planning/STATE.md index 69e4769..980cd6a 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -2,15 +2,15 @@ gsd_state_version: 1.0 milestone: v1.0 milestone_name: milestone -status: verifying -stopped_at: Completed 06-ai-sync/06-03-PLAN.md -last_updated: "2026-04-07T11:53:10.483Z" +status: executing +stopped_at: Completed 07-microcontroller-firmware/07-02-PLAN.md +last_updated: "2026-04-07T15:42:39.463Z" last_activity: 2026-04-07 progress: total_phases: 7 completed_phases: 6 - total_plans: 21 - completed_plans: 21 + total_plans: 24 + completed_plans: 22 percent: 0 --- @@ -21,13 +21,13 @@ progress: See: .planning/PROJECT.md (updated 2026-04-05) **Core value:** Load a song, build a synchronized light show, play it back live — with precise control over every effect on every device. -**Current focus:** Phase 06 — ai-sync +**Current focus:** Phase 07 — microcontroller-firmware ## Current Position -Phase: 7 -Plan: Not started -Status: Phase complete — ready for verification +Phase: 07 (microcontroller-firmware) — EXECUTING +Plan: 2 of 3 +Status: Ready to execute Last activity: 2026-04-07 Progress: [░░░░░░░░░░] 0% @@ -73,6 +73,7 @@ Progress: [░░░░░░░░░░] 0% | Phase 06-ai-sync P01 | 8 | 3 tasks | 6 files | | Phase 06-ai-sync P02 | 8 | 2 tasks | 7 files | | Phase 06-ai-sync P03 | 8 | 2 tasks | 5 files | +| Phase 07 P02 | 155 | 3 tasks | 3 files | ## Accumulated Context @@ -132,6 +133,9 @@ Recent decisions affecting current work: - [Phase 06-ai-sync]: Heuristic always available as baseline; LLM opt-in via use_llm flag (D-04) - [Phase 06-ai-sync]: LLM generates from scratch, not post-processing heuristic output (D-06) - [Phase 06-ai-sync]: anthropic imported lazily inside llm_generate to avoid startup crash without API key +- [Phase 07]: Inline _hsv_to_rgb replaces colorsys (not available in MicroPython) +- [Phase 07]: bytearray for FireAnimation heat buffer avoids GC pressure on device +- [Phase 07]: density field maps to size for chase, cooling for fire, ignored for others ### Pending Todos @@ -145,8 +149,8 @@ None yet. ## Session Continuity -Last session: 2026-04-07T11:48:26.607Z -Stopped at: Completed 06-ai-sync/06-03-PLAN.md +Last session: 2026-04-07T15:42:39.455Z +Stopped at: Completed 07-microcontroller-firmware/07-02-PLAN.md Resume file: None Next action: `/gsd:plan-phase 1` diff --git a/.planning/phases/07-microcontroller-firmware/07-02-SUMMARY.md b/.planning/phases/07-microcontroller-firmware/07-02-SUMMARY.md new file mode 100644 index 0000000..d6f6c50 --- /dev/null +++ b/.planning/phases/07-microcontroller-firmware/07-02-SUMMARY.md @@ -0,0 +1,86 @@ +--- +phase: "07" +plan: "02" +subsystem: firmware +tags: [micropython, animations, led, firmware] +dependency_graph: + requires: [07-01] + provides: [animation-rendering-engine] + affects: [firmware/main.py, firmware/animations.py] +tech_stack: + added: [] + patterns: [MicroPython-compatible Python, bytearray GC optimization, HSV inline conversion] +key_files: + created: + - firmware/animations.py + - tests/test_firmware_animations.py + modified: + - firmware/main.py +decisions: + - "Inline _hsv_to_rgb replaces colorsys (not available in MicroPython)" + - "bytearray for FireAnimation heat buffer avoids GC pressure on device" + - "create_animation() factory centralizes cmd dict to instance mapping" + - "density field maps to size for chase, cooling for fire, ignored for others" +metrics: + duration: "155 seconds" + completed: "2026-04-07" + tasks: 3 + files: 3 +--- + +# Phase 07 Plan 02: Animation Command Renderer Summary + +All 7 LightSync animations ported to MicroPython-compatible firmware with a complete test suite — 26 tests passing with full server-to-firmware round-trip verification. + +## Tasks Completed + +| # | Task | Commit | Files | +|---|------|--------|-------| +| 1 | Create firmware/animations.py | 053e1ab | firmware/animations.py | +| 2 | Update firmware/main.py with render wiring | 8e521e5 | firmware/main.py | +| 3 | Create test suite + re-apply main.py | 49f0b0f | tests/test_firmware_animations.py, firmware/main.py | + +## What Was Built + +`firmware/animations.py` contains all 7 animation classes ported from `lightsync/animations/*.py` with these MicroPython adaptations: +- `_hsv_to_rgb()` inline function replaces `colorsys.hsv_to_rgb` (not in MicroPython) +- `bytearray` for `FireAnimation._heat` buffer (avoids GC pressure on device) +- No type hints, no `abc` ABC, no `lightsync` imports +- `create_animation(cmd)` factory maps parsed command dicts to animation instances + +`firmware/main.py` updated to: +- Import `create_animation` from `animations` +- Add `current_anim_instance` global +- Create animation instance on `anim_cmd` packet receipt +- Render animation using `ticks_diff()` timing in the render loop + +`tests/test_firmware_animations.py` provides 26 host-side tests covering: +- `_hsv_to_rgb` primary colors and edge cases +- All 7 animation classes: length, value ranges, behavior +- `create_animation()` factory for all types + unknown fallback +- Full round-trip: `encode_animation_cmd` -> `parse_animation_cmd` -> `create_animation` -> `render` + +## Verification + +- `uv run pytest tests/test_firmware_animations.py -v` — 26 passed in 0.05s +- `_hsv_to_rgb` correct: red=(255,0,0), green=(0,255,0), blue=(0,0,255) +- `FireAnimation` uses `bytearray` confirmed by `test_uses_bytearray` +- Round-trip test passes for all 7 animation types +- No `colorsys`, `abc`, or `lightsync` imports in any `firmware/` file + +## Deviations from Plan + +### Auto-fixed Issues + +**1. [Rule 3 - Blocking] Re-applied main.py changes after 07-01 parallel agent overwrite** +- **Found during:** Task 3 (after test file creation) +- **Issue:** Agent 07-01 (running in parallel) committed `firmware/main.py` with the scaffold version, reverting the animation wiring committed in Task 2 +- **Fix:** Re-applied all animation changes to main.py via Edit tool after detecting the revert in system notification +- **Files modified:** firmware/main.py +- **Commit:** 49f0b0f (included with test file commit) + +## Known Stubs + +None — plan goal fully achieved. All 7 animations render correctly, tests pass. + +## Self-Check: PASSED