Skip to content

refactor(rx/decode_ws2812): apply CodeRabbit follow-ups from #3036 (ASCII + header/impl split) - #3037

Merged
zackees merged 1 commit into
masterfrom
feat/3036-cr-cleanup
Jun 14, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/3036-cr-cleanup

Conversation

@zackees

@zackees zackees commented Jun 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #3036 (squash-merged as b99cc8e3c). #3036 was merged before I had a chance to push the CodeRabbit responses, so the two coding-standard violations CR flagged are sitting in master now. This PR addresses them.

CR findings addressed

  1. ASCII-only source-encoding rule for src/fl/channels/rx/decode_ws2812.h. The header used Unicode glyphs (->, --, <=, etc.) in comments. Replaced with ASCII equivalents.
  2. No function definitions in plain .h files under src/fl/channels/rx/. Moved decodeWs2812Edges() from the header to a new src/fl/channels/rx/decode_ws2812.cpp.hpp companion (matches the existing channel.h / channel.cpp.hpp pair in the same directory) and wired it into src/fl/channels/rx/_build.cpp.hpp so it compiles exactly once into libfastled.

CR findings explicitly deferred (see PR #3036 inline replies)

CodeRabbit also flagged two latent semantic bugs in the consolidated decoder — reset-pulse detection firing before gap-tolerance evaluation, and the error-rate denominator missing partial-bit residue. Both behaviours are preserved verbatim from the original Native + LPC decoders that #3036 consolidated. Faithful consolidation has to match prior behaviour byte-for-byte; correcting these would silently change shipped behaviour for two backends under a refactor-named PR. They are now explicitly documented in the new header's "Preserved-from-original quirks" block and queued for a follow-up under #3035 Phase 3.

Test plan

  • tests/fl_channels_rx_sct_capture — 5/5 pass on the rebuilt host stub
  • tests/fl_channels_rx — 15/15 pass
  • Build green after the header/impl split (LPC + Native both resolve decodeWs2812Edges() via the FastLED unity-build link)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Reorganized WS2812 decoder implementation for improved code structure and maintainability.

…pp definition

Addresses two CodeRabbit findings on #3036:

1. **ASCII-only header.** The previous header used Unicode glyphs (->, --,
   <=) in comments. Per the path-specific source-encoding rule for
   `src/fl/channels/rx/decode_ws2812.h`, that header must be 7-bit ASCII.
   Replaced all Unicode characters with ASCII equivalents.

2. **No function definitions in plain .h files.** The previous
   implementation defined `decodeWs2812Edges()` inline in the .h. Per the
   project convention used throughout fl/channels/rx (see channel.h
   <-> channel.cpp.hpp), function definitions go in a .cpp.hpp companion
   compiled exactly once into the FastLED unity build, while the .h
   carries only the declaration. Created
   `src/fl/channels/rx/decode_ws2812.cpp.hpp` and added the include
   to `src/fl/channels/rx/_build.cpp.hpp`.

Behaviour unchanged: this is purely a file-layout split. The two
CodeRabbit findings that flagged latent semantic bugs in the
gap-tolerance ordering and the error-rate denominator are preserved
from the original Native + LPC decoders and explicitly documented in
the header's "Preserved-from-original quirks" block; fixing them is
out of scope for the consolidation PR and tracked under #3035 follow-ups.

Verification:
  * tests/fl_channels_rx_sct_capture (5 cases) -- pass
  * tests/fl_channels_rx (15 cases) -- pass
  * bash lint --cpp -- clean

Refs #3035.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 35b5a3fd-55ae-4f42-b509-a841dc6056db

📥 Commits

Reviewing files that changed from the base of the PR and between b99cc8e and e55359e.

📒 Files selected for processing (3)
  • src/fl/channels/rx/_build.cpp.hpp
  • src/fl/channels/rx/decode_ws2812.cpp.hpp
  • src/fl/channels/rx/decode_ws2812.h

📝 Walkthrough

Walkthrough

decodeWs2812Edges is moved from an inline definition in decode_ws2812.h to a new decode_ws2812.cpp.hpp Unity-build translation unit. The header retains only a forward declaration and gains an expanded documentation block. The new .cpp.hpp file is registered in _build.cpp.hpp.

Changes

WS2812 Decoder Extraction to Translation Unit

Layer / File(s) Summary
Header declaration and updated docs
src/fl/channels/rx/decode_ws2812.h
The inline implementation of decodeWs2812Edges is removed; only a forward declaration remains. Documentation is expanded to enumerate preserved quirks (reset/gap evaluation ordering and error-rate denominator).
New decode_ws2812.cpp.hpp implementation
src/fl/channels/rx/decode_ws2812.cpp.hpp
New file containing the full decodeWs2812Edges implementation: edge-pair polarity validation, timing-threshold bit classification, reset/gap frame termination, byte accumulation, BUFFER_OVERFLOW return on undersized output, and post-decode HIGH_ERROR_RATE rejection.
Unity build registration
src/fl/channels/rx/_build.cpp.hpp
Adds #include of decode_ws2812.cpp.hpp so the new translation unit is compiled as part of the Unity build.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • FastLED/FastLED#3036: Directly related — NativeRxDevice::decode and LpcSctRxChannel::decode delegate to decodeWs2812Edges, the exact function being extracted here into its own translation unit.
  • FastLED/FastLED#3016: The LPC SCT capture backend's LpcSctRxChannel::decode calls decodeWs2812Edges, which is what this PR moves to a dedicated .cpp.hpp.
  • FastLED/FastLED#2769: The FlexIO RX loopback pipeline depends on decodeWs2812Edges to decode captured WS2812 edges into bytes, directly consuming the function being reorganized here.

Poem

🐇 A header once bloated with logic inline,
Now sleeps in its own .cpp.hpp shrine.
The Unity build adds a single new line,
And the decoder hops free — oh, how divine!
Less clutter in headers, the code feels so fine. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: a refactoring to apply CodeRabbit follow-ups from PR #3036, including ASCII encoding fixes and a header/implementation file split for the WS2812 decoder.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3036-cr-cleanup

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 14, 2026
@zackees
zackees merged commit 952cbea into master Jun 14, 2026
7 of 9 checks passed
@zackees
zackees deleted the feat/3036-cr-cleanup branch June 14, 2026 20:51
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 14, 2026
zackees added a commit that referenced this pull request Jun 14, 2026
… sketch retirement) (#3043)

Phase 3 of FastLED #3035 (decoder consolidation across the four
EdgeTime-based RX backends + AutoResearchLpc.ino retirement) is now
shipped end-to-end:

  * #3037 split the shared 4-phase WS2812 decoder into
    `src/fl/channels/rx/decode_ws2812.{h,cpp.hpp}` so the LPC SCT-RX
    and native paths share one implementation.
  * #3041 folded `examples/AutoResearchLpc/AutoResearchLpc.ino` into
    the main `examples/AutoResearch/AutoResearch.ino` low-memory mode
    (auto-engaged on FL_PLATFORM_HAS_LARGE_MEMORY == 0).
  * The `ci/autoresearch/phases.py` orchestrator dispatch updated to
    point at the unified sketch as part of #3041.

What remains in #3035 are Phases 1, 2a, 2b -- the hardware bench
validation work that needs real LPC845-BRK silicon + scope. That
hardware sign-off is shared with the #2880 checklist now in
`src/platforms/arm/lpc/README.md`.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant