Repository navigation
feat(video): add fl::PatternPlayer high-level mapped video file player - #3292
davidcreated wants to merge 2 commits into
Conversation
|
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 (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds ChangesPatternPlayer Feature
Sequence Diagram(s)sequenceDiagram
participant Sketch
participant PatternPlayer
participant FileSystem
participant Video
rect rgba(70, 130, 180, 0.5)
Note over Sketch,Video: setup()
Sketch->>PatternPlayer: begin(CHIP_SELECT_PIN, NUM_LEDS, 30fps)
PatternPlayer->>FileSystem: open SD session
PatternPlayer->>Video: open("data/video.fled")
Video-->>PatternPlayer: success
PatternPlayer->>Video: attempt embedded screenmap JSON
alt has embedded map
Video-->>PatternPlayer: ScreenMap
else no embedded map
PatternPlayer->>FileSystem: read "screenmap.json"
FileSystem-->>PatternPlayer: ScreenMap
end
PatternPlayer-->>Sketch: true + optional ScreenMap
Sketch->>Sketch: FastLED.addLeds (with/without screenmap)
end
rect rgba(60, 179, 113, 0.5)
Note over Sketch,Video: loop()
Sketch->>PatternPlayer: hasNewFrame()
PatternPlayer-->>Sketch: true (FPS elapsed)
Sketch->>PatternPlayer: drawFrame(leds, NUM_LEDS)
PatternPlayer->>Video: draw(span<leds>)
Video-->>PatternPlayer: frame rendered
Sketch->>Sketch: FastLED.show()
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/fl/video/pattern_player.cpp.hpp`:
- Around line 25-28: In the PatternPlayer::begin() method, add validation to
check that the fps parameter is greater than 0 before proceeding with any
initialization. Since hasNewFrame() divides by mFps, invalid values (fps <= 0)
will cause incorrect frame gating behavior. Insert a guard clause at the start
of begin() that returns false (or handles the error) if fps <= 0 is detected,
preventing invalid cadence behavior and rejecting the invalid input.
- Around line 25-50: The PatternPlayer::begin() method does not reset the
mHasScreenMap member variable at entry, causing stale state from previous
invocations to persist. Add a single initialization statement at the very
beginning of the PatternPlayer::begin() method to set mHasScreenMap to false
before any screen map loading logic is performed. This ensures that if neither
an embedded screen map nor a sidecar file is found in the current invocation,
the flag correctly reflects the absence of a valid map rather than retaining a
true value from a previous successful load.
In `@src/fl/video/pattern_player.h`:
- Line 22: The drawFrame method currently uses a raw pointer and integer length
pair (CRGB* leds, int numLeds) which violates the repository's API guidelines
for header parameters. Replace these two parameters with a single fl::span<CRGB>
parameter named leds. This change improves type safety and enforces the repo's
coding standard of using fl::span<T> for function parameters instead of raw
pointer and length pairs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e2b4732b-3ff8-47b4-b6c2-4d85660da34e
📒 Files selected for processing (4)
examples/PatternPlayer/PatternPlayer.inosrc/fl/video/_build.cpp.hppsrc/fl/video/pattern_player.cpp.hppsrc/fl/video/pattern_player.h
|
Well, you are obviously a special ai augmented engineer because fled format wasn't even a week old and you found it and tried to stream line it. Let me contemplate on how i want this integrated properly. I see what you are trying to do. |
Overview
This PR introduces a new high-level utility class
fl::PatternPlayerto simplify the loading, mapping, and playback of WLED-compatible.fledand legacy.rgbfiles from SD cards or flash memory.fl::PatternPlayerwraps the existingfl::FileSystemandfl::Videocomponents under the hood, significantly reducing boilerplate code for lightweight sketches and visual art installations.Key Features
begin()anddrawFrame().ScreenMapdirectly from WLED.fledfiles at runtime.screenmap.jsonconfigurations when fallback headerless.rgbfiles are used.hasNewFrame) decouple visual update ticks from loop speed.Code Structure Changes
src/fl/video/pattern_player.h: Declaresfl::video::PatternPlayerand exports it to thefl::namespace.src/fl/video/pattern_player.cpp.hpp: Implements initialization, sidecar mapping paths, and frame rate calculation.examples/PatternPlayer/PatternPlayer.ino: Shows a full playback workflow using the player.src/fl/video/_build.cpp.hpp: Addedpattern_player.cpp.hppto the Meson/Ninja unity build list.Verification
bash test --cpp- all 332 tests passed, including compilation and execution ofexample-PatternPlayer).bash lint.Summary by CodeRabbit
Release Notes
New Features
Examples