Repository navigation
feat(screenmap): emit v2 from ScreenMap::toJson + convert remaining v1 samples - #3100
Conversation
…1 samples 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]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthrough
ChangesScreenMap v2 JSON Schema Migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…3322) (#4278) #3322's first complaint is that `pin` is documented in the screen-map envelope and never read. That is true, and deliberate -- the parser says so. What the issue does not say, and what turns this from a missing feature into a defect, is what the *emitter* does with it. `ScreenMap::toJson` wrote the literal `"pin1"` into every segment. That string is the example value from the shape comment directly above the emitter, copied into the code as data; the commit that added it (#3100) does not mention `pin` at all. So the round trip did not drop the field, it rewrote it. Measured on a three-segment file before touching anything: in a -> "pin1" b -> "pin2" c -> 7 out a -> "pin1" b -> "pin1" c -> "pin1" Two of three segments come back on the wrong pin, and a numeric pin comes back as a string. `examples/hydropack/data/*.json` are exactly that shape -- pin1/pin2/pin3 -- so this is a file in the tree, not a hypothetical. Nothing is emitted now. Wrong is worse than absent here: a consumer reading a rewritten pin mis-wires a strip with no way to tell, while a consumer reading a missing optional key can see that it is missing. The parser ignores the key either way, so nothing on this side changes. Carrying the value through is the real fix and is #3322 proper -- it needs somewhere on `ScreenMap` to put it and a decision about the `<int|str>` union, which is what that issue is for. This stops making it worse in the meantime. The test counts `"pin"` occurrences rather than looking for `"pin1"`, so re-introducing a different constant fails it too; both mutations do. One thing left alone and worth recording: the emitter also writes `"diameter":-1.000` for a map with no diameter set, while the field's own comment says "Only serialized if it's not > 0.0f". Same shape of problem, different field, and changing it moves what the parser reads back. Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9 Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Closes the FastLED side of ledmapper#143. (Ledmapper-side emitters + fixtures landed in zackees/ledmapper#144 just now.)
Summary
ScreenMap::toJson/toJsonStrnow emit the v2 shape ({ version: 2, groups, segments: [...] }) instead of v1{ map: { name: {...} } }.ScreenMap::ParseJsonalready accepts both shapes (PR feat(video): FLED v1 container support + FxSdCard accepts both formats #3074), so this is a one-way emitter swap with no parser regression.examples/Fx/FxSdCard/data/screenmap.json— the legacy sidecar fallback inFxSdCard.ino. The FLED happy-path was already embedding v2 (since PR feat(video): FLED v1 container support + FxSdCard accepts both formats #3074); this makes the.rgbfallback path also exercise v2.examples/Chromancer/screenmap.json.h— 4-segment inline JSON literal thatChromancer.ino:191feeds straight intoScreenMap::ParseJsonat setup. Converted to v2.examples/Chromancer/output.json— same 4 segments as the inline literal, converted to v2.Out of scope
examples/Chromancer/gary_woos_wled_port/gary_woos_wled_ledmap.huses{"map": [array of indices]}— that's the WLED ledmap format, not a v1 ScreenMap. Coincidentally shares the"map"key name but the value type is an array, not an object, so it isn't a screenmap at all. Left untouched.Verification
bash test --cpp screenmap→ 1/1 pass (round-triptoJson→ParseJsonis bilingual and still works)bash test --cpp fx_video→ 1/1 passbash test --examples FxSdCard→ compiles cleanbash test --examples Chromancer→ compiles clean🤖 Generated with Claude Code
Summary by CodeRabbit