Skip to content

feat(screenmap): flip remaining ledmapper emitters to v2 (Bucket A+B+C for #143) - #144

Merged
zackees merged 1 commit into
mainfrom
feat/143-v2-ledmapper
Jun 15, 2026
Merged

zackees merged 1 commit into
mainfrom
feat/143-v2-ledmapper

Conversation

@zackees

@zackees zackees commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Addresses the ledmapper side of #143. (FastLED side lands in a separate PR — ScreenMap::toJson flip + sample data re-emission.)

Summary

  • Bucket B (emitters): buildScreenmapMultiStripJson and saveScreenmapPoints now write the v2 shape ({ version: 2, groups, segments: [...] }). This is the canonical emitter that backs Save As, shapeeditor autosave, AND the JSON embedded in every recorded .fled. Each strip gets its own group keyed by name with a palette color; pin is unconditional (defaults to pin1 to match v1's implicit default).
  • Bucket C (bilingual readers): _countMap() in screenmap-store.ts now detects v2 before the v1 .map fallback (silently returning 0 LEDs on v2 input was the blocker). scripts/inspect-fled.mjs walks v2 segments when present — verified against FastLED's freshly-converted examples/Fx/FxSdCard/data/video.fled which previously reported LED count: 0.
  • Bucket A (fixtures): tests/fixtures/test-screenmap.json and test-screenmap-multi.json re-emitted as v2. Test code didn't need to change — parseScreenmapMultiStrip is bilingual.
  • Round-trip fix: ScreenmapV2Segment optionally carries video_offset + video_offset_override (ledmapper-specific extension, not part of canonical v2). The v2→strips adapter (v2ToMultiStripResult) reads them so an override strip round-trips cleanly.
  • Lock-in CI test: new tests/unit/shipped-json-is-v2.test.ts scans public/screenmaps/ and tests/fixtures/ and asserts every shipped *.json screenmap is v2. Prevents v1 drift in future PRs.

Tests

  • npm run lint — clean
  • npm test — 448/448 pass (one new lock-in test). Existing buildScreenmapMultiStripJson + pin-emission assertions rewritten against v2 shape (parsed.version, parsed.segments) and v2 semantics ("pin is unconditional" replaces "pin omitted when default").
  • npm run build — succeeds.

What is NOT in this PR

🤖 Generated with Claude Code

Partial close of #143 (ledmapper side; FastLED side lands separately).

Bucket B — emitters now write v2:
- `src/screenmap-store.ts::buildScreenmapMultiStripJson()` — the canonical
  emitter that backs Save As, shapeeditor autosave, and the JSON embedded
  in every recorded .fled video. Now writes
  `{ version: 2, groups, segments: [...] }`. Each strip gets its own
  group keyed by name with a color from a small palette; `pin` is
  unconditional (defaults to 'pin1' to match v1's implicit default).
- `saveScreenmapPoints()` — routed through the canonical emitter so the
  single-strip persistence path also emits v2.

Bucket C — bilingual readers:
- `_countMap()` in screenmap-store.ts now detects v2 (segments / version)
  before the v1 `.map` fallback, so backup-meta stays correct as the
  store transitions from v1 to v2 content.
- `scripts/inspect-fled.mjs` now walks v2 segments when present,
  reporting "screenmap shape: v2" and the correct LED count. Verified
  against FastLED's freshly-converted examples/Fx/FxSdCard/data/video.fled
  which was reporting "0 LEDs" before this change.

Bucket A — fixtures:
- `tests/fixtures/test-screenmap.json` and `test-screenmap-multi.json`
  re-emitted as v2. Callers go through `parseScreenmapMultiStrip` which
  is bilingual, so no test-code changes were required for the format
  flip itself.

Round-trip fix:
- `src/screenmap-v2.ts` + `src/types/domain.ts`: `ScreenmapV2Segment`
  now optionally carries `video_offset` + `video_offset_override` (a
  ledmapper-specific extension — not part of canonical v2). The
  v2→strips adapter (`v2ToMultiStripResult`) honours them so a
  videoOffsetOverride strip round-trips cleanly through the emitter and
  parser.

Lock-in:
- New `tests/unit/shipped-json-is-v2.test.ts` scans
  `public/screenmaps/` and `tests/fixtures/` and asserts every shipped
  *.json screenmap is v2. Prevents v1 drift in future PRs.

Test assertions updated:
- The buildScreenmapMultiStripJson + pin-emission test suites in
  `tests/unit/multistrip-parsing.test.ts` now assert against the v2
  shape (`parsed.version`, `parsed.segments`) and the v2 semantics
  ("pin is unconditional" replaces "pin omitted when default").

Verification:
- npm run lint — clean
- npm test — 448/448 pass (one new lock-in test)
- npm run build — succeeds

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit f7abff9 into main Jun 15, 2026
4 checks passed
@zackees
zackees deleted the feat/143-v2-ledmapper branch June 15, 2026 19:52
zackees added a commit to FastLED/FastLED that referenced this pull request Jun 15, 2026
…1 samples (#3100)

Closes ledmapper#143 on the FastLED side. (Ledmapper-side emitter +
fixture migration shipped in zackees/ledmapper#144.)

ScreenMap::toJson / toJsonStr now emit the v2 shape (`{ version: 2,
groups, segments: [...] }`) instead of `{ map: { name: {...} } }`.
ScreenMap::ParseJson is already bilingual, so:

  - C++ → JS WASM bridge keeps working (ledmapper reads v2 natively).
  - Round-trip test (toJson → ParseJson same flat_map) still passes:
    the parser dispatches on shape, the JSON shape just changed.
  - Any existing on-disk v1 JSON continues to load via the v1 path —
    we are not breaking third-party files in the wild.

Sample data converted:

  - examples/Fx/FxSdCard/data/screenmap.json — the legacy sidecar
    fallback path. The FLED happy path was already embedding v2 since
    PR #3074; this just makes the .rgb fallback exercise v2 too.
  - examples/Chromancer/screenmap.json.h — 4-segment inline JSON
    literal that the sketch feeds to ScreenMap::ParseJson at setup.
  - examples/Chromancer/output.json — output blob, same 4 segments.

Out of scope:

  - examples/Chromancer/gary_woos_wled_port/gary_woos_wled_ledmap.h
    uses `{"map": [array of indices]}` which is the WLED ledmap
    format, not a v1 ScreenMap. Coincidentally shares the "map" key
    name but the value type is wrong for a screenmap — left untouched.

Verification:

  bash test --cpp screenmap          → 1/1 pass
  bash test --cpp fx_video           → 1/1 pass
  bash test --examples FxSdCard      → compiles clean
  bash test --examples Chromancer    → compiles clean

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jul 8, 2026
#234)

multistrip-compat.spec.ts still read the v1 `map` key from the
multi-strip fixture at module scope; the fixture moved to the v2
`segments` schema in #144, so loading the file threw and killed the
entire Playwright run before any test executed - including the first
gpu-nightly dispatch, which failed at collection without running a
single @gpu spec.

Extract a shared v2-or-v1 counting helper (tests/helpers/
screenmap-count.ts), use it for the fixture read and the two
store-round-trip assertions, and dedupe moviemaker-recording.spec.ts's
local copy onto it.

Deeper rot remains in multistrip-compat.spec.ts (movieplayer
#btn_upload_screenmap no longer exists, .rgb uploads were removed in
#133, shapeeditor save assertions still expect v1) - runtime-only
failures outside the @gpu grep, left for a dedicated cleanup.

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant