Repository navigation
refactor(fl/fled): focus on header/json/blob/objects + FledBuilder + full FLED_FORMAT.md spec coverage (#3311) - #3334
Conversation
…er + full FLED_FORMAT.md spec coverage (#3311) Per follow-up direction, the v1 fl/fled subsystem is restructured around four concrete responsibilities and nothing else: 1. Header info - version(), pixelFormat(), bytesPerLed() 2. JSON envelope - json(), sectionCount(), videoFps() 3. Raw blob ranges - blob("frame_payload", &n) for video bytes 4. Fully constructed objects - screenMap(), channels() (stub) Plus a new FledBuilder for imperative assembly of a bundle from header + optional screenmap JSON + optional channels JSON + optional payload. Removals (gone entirely): - CFastLED::load / loadChannels / loadScreenMap and their per-method TUs (src/fl/fled/load/, load_channels/, load_screen_map/ directories + the matching src/fl/build/fl.fled.load*+.cpp wrappers + UNITY allowlist entries). These were half-baked stubs that contributed nothing real. - fl::FledScript, fl::ScriptKind - scripting types purged from code; the scripting roadmap stays only in src/fl/fled/*.md as future-v2 doc. - src/fl/fled/fwd.h - only existed for the now-deleted CFastLED methods. - Video::fromFled, ScreenMap::fromFled, MultiChannelConfig::fromFled - bidirectional forwarders did not belong on those types; removed along with the fl::Fled forward decls in fl/fx/video.h, fl/math/screenmap.h, fl/channels/config.h. - Fled::video(), Fled::script() accessors - replaced by blob() + json() for video; script removed entirely. Namespace + layout rule: - fl::Fled (the public API type) stays at top-level fl::. - All auxiliary types and free functions live in fl::fled, with files under src/fl/fled/detail/. - fl::fled::FledImpl (PIMPL) moved to src/fl/fled/detail/fled_impl.hpp - fl::fled::ParsedHeader + parseHeaderAndEnvelope + sectionNameIsPayload in src/fl/fled/detail/parser.{h,cpp.hpp} - fl::fled::PixelFormat enum + bytesPerLed() in src/fl/fled/detail/pixel_format.{h,cpp.hpp} - fl::fled::FledBuilder in src/fl/fled/builder.{h,cpp.hpp} fled.cpp.hpp is now a thin facade - the parser internals were lifted out into fl::fled::parseHeaderAndEnvelope; the factories just call into that free function and construct FledImpl. FLED_FORMAT.md spec coverage (new): - All five v1 pixel formats (0x00 rgb8, 0x01 gray8, 0x02 rgba8, 0x03 rgbw8, 0x04 rgb565le) map to their canonical bytes-per-LED. - Reserved pixel formats (0x05..0xff) return 0 bpp so callers can reject before reading frame bytes per spec. - frameCount(ledCount) implements the spec's frame_count = payload_bytes / (led_count * bytes_per_led) formula. - videoFps(default=30) reads envelope.video.fps with a default fallback per the spec's "consumers may use an application default" clause. Tests (tests/fl/fled/): - fled.cpp - keep + extend the existing header/blob/screenMap cases. - fled_format.cpp NEW - 17 cases walking the FLED_FORMAT.md spec point-by-point: all five pixel formats x bytes-per-LED, frame-count derivation including truncation + reserved-format zero, video.fps reader with all fallback paths, envelope passthrough, screenMap parse from the spec's example envelope, led_count-driven frameCount. - fled_builder.cpp - 5 cases covering header-only / setVersion+pixel fmt / + screenmap json / + payload / end-to-end. - fled_filesystem.cpp - unchanged (MemoryFs mock integration test). - fled_load.cpp, fled_from_fled.cpp - deleted (tested the removed surface). Refs #3311 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughRemoves ChangesFled subsystem refactor
Sequence Diagram(s)sequenceDiagram
rect rgba(135, 180, 220, 0.5)
Note over Client,FledBuilder: Build path (new)
Client->>FledBuilder: setVersion(1), setPixelFormat(0x01), setScreenMapJson(...), setPayload(bytes)
FledBuilder->>FledBuilder: buildJsonEnvelope(screenMapJson, channelsJson)
FledBuilder->>FledBuilder: serialize 12-byte header + JSON + payload → buf
FledBuilder->>Fled: loadFromVector(move(buf))
end
rect rgba(180, 220, 135, 0.5)
Note over Fled,FledImpl: Parse path (revised)
Fled->>parseHeaderAndEnvelope: data, len
parseHeaderAndEnvelope->>parseHeaderAndEnvelope: validate magic, version, JSON length bounds
parseHeaderAndEnvelope-->>Fled: ParsedHeader{version, pixelFormat, payloadOffset}, envelope JSON
Fled->>FledImpl: construct(owned, version, pixelFormat, payloadOffset, envelope)
Fled-->>Client: Fled handle with pixelFormat(), bytesPerLed(), frameCount(), videoFps(), screenMap(), blob()
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 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 |
Summary
Per follow-up direction, the v1
fl/fledsubsystem is restructured around four concrete responsibilities and nothing else:version(),pixelFormat(),bytesPerLed()json(),sectionCount(),videoFps()blob(\"frame_payload\", &n)for video bytesscreenMap(),channels()(stub)Plus a new
fl::fled::FledBuilderfor imperative assembly: header + optional screenmap JSON + optional channels JSON + optional payload.Removed entirely
src/fl/fled/load/,load_channels/,load_screen_map/directories + matchingsrc/fl/build/fl.fled.load*+.cppwrappers +UNITY_EXPECTED_BUILD_FILESallowlist entries). These were half-baked stubs that contributed nothing real.fl::FledScript,fl::ScriptKind— scripting types purged from code; the scripting roadmap stays only insrc/fl/fled/*.mdas future-v2 doc.src/fl/fled/fwd.h— only existed for the now-deleted CFastLED methods.Video::fromFled,ScreenMap::fromFled,MultiChannelConfig::fromFled— bidirectional forwarders did not belong on those types; removed along with thefl::Fledforward decls infl/fx/video.h,fl/math/screenmap.h,fl/channels/config.h.Fled::video(),Fled::script()— replaced byblob()+json()for video; script removed entirely.Namespace + layout rule
fl::Fled(the public API type) stays at top-levelfl::.fl::fled, with files undersrc/fl/fled/detail/.fl::fled::FledImpl(PIMPL) moved tosrc/fl/fled/detail/fled_impl.hppfl::fled::ParsedHeader+parseHeaderAndEnvelope+sectionNameIsPayloadinsrc/fl/fled/detail/parser.{h,cpp.hpp}fl::fled::PixelFormatenum +bytesPerLed()insrc/fl/fled/detail/pixel_format.{h,cpp.hpp}fl::fled::FledBuilderinsrc/fl/fled/builder.{h,cpp.hpp}fled.cpp.hppis now a thin facade — parser internals were lifted out intofl::fled::parseHeaderAndEnvelope; the factories just call the free function and constructFledImpl.FLED_FORMAT.md spec coverage (new)
frameCount(ledCount)implementsframe_count = payload_bytes / (led_count * bytes_per_led).videoFps(default=30)reads envelopevideo.fpswith default fallback per the spec's "consumers may use an application default" clause.Tests
tests/fl/fled/fled.cpp— kept + extended header/blob/screenMap cases (~20 cases)tests/fl/fled/fled_format.cppNEW — 17 cases walking FLED_FORMAT.md point-by-point: all five pixel formats × bytes-per-LED, frame-count derivation including truncation + reserved-format zero, video.fps reader with all fallback paths, envelope passthrough, screenMap parse from the spec's example envelope, led_count-driven frameCounttests/fl/fled/fled_builder.cpp— 5 cases covering header-only / setVersion+pixelFormat / + screenmap json / + payload / end-to-endtests/fl/fled/fled_filesystem.cpp— unchanged (MemoryFs mock integration test)tests/fl/fled/fled_load.cpp,fled_from_fled.cpp— deleted (tested removed surface)Test plan
bash test fled --debug— greenbash lint --cpp— greenRefs #3311
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Breaking Changes
.fledbundle loading APIs (load,loadChannels,loadScreenMap) from FastLEDvideo()andscript()typed accessors from FLED bundlesNew Features
FledBuilderfor programmatic v1 FLED bundle constructionpixelFormat(),bytesPerLed(),payloadBytes(),frameCount(),videoFps()Tests