Skip to content

fix(spi): legacy addLeds SK9822/APA102 controllers use all-ones end clocks - #3684

Merged
zackees merged 1 commit into
masterfrom
fix/sk9822-legacy-end-frame
Jul 16, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/sk9822-legacy-end-frame

Conversation

@zackees

@zackees zackees commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

Closes #3682

Summary

Commit 34a86a7 (#3669) fixed the channel-engine encoders (fl/chipsets/encoders/{apa102,sk9822}.h) to emit all-ones (0xFFFFFFFF per DWord) end-clock frames, matching the vendor datasheet requirement — these clocks shift the final LED frame through a long cascade, and a zero/partial end frame is not a substitute because it can be misread as a new start frame.

The legacy addLeds<> controller templates in src/fl/chipsets/apa102.h were never updated and still emitted mostly-zero end clocks:

  • APA102Controller base default: END_FRAME = 0xFF000000
  • APA102ControllerHD, SK9822Controller, SK9822ControllerHD, HD107Controller: END_FRAME = 0x00000000

On a long cascade (>32 LEDs) driven through the classic FastLED.addLeds<SK9822, ...> path, this meant the final LED frame wasn't fully shifted through, and the wrong end frame could be misread as a new start frame — the same failure #3669 already fixed on the newer channel-engine path.

Changes

  • src/fl/chipsets/apa102.h: align all five END_FRAME defaults with the encoder contract (0xFFFFFFFF). HD107HDController inherits the fix transitively through APA102ControllerHD (no explicit override needed).
  • Dropped the now-stale "different END_FRAME" doc-comment claim on SK9822Controller/SK9822ControllerHD — after this fix, END_FRAME is identical between APA102 and SK9822; only the default SPI_SPEED differs.
  • Added getStartFrame()/getEndFrame() public static accessors to APA102Controller so the wire-protocol contract is directly unit-testable without needing hardware or SPI byte capture.
  • tests/fl/chipsets/spi_frame_protocol.cpp: new test case asserting getEndFrame() == 0xFFFFFFFF / getStartFrame() == 0x00000000 for every affected legacy controller template.

This is a maintainer-authorized wire-protocol default change per the issue's own note ("changing shipped wire output needed your sign-off rather than a drive-by fix") — filed and directed by the repo admin.

Testing

  • bash test spi_frame_protocol --cpp — RED before the header fix (6 assertions failing with the old END_FRAME values), GREEN after.
  • bash test spi_frame_protocol --debug — sanitizer pass, clean.
  • bash test fastled_core --cpp — sanity check for existing APA102 addLeds usage, still passing.
  • bash lint --cpp <changed files> — clean (both changed files pass all C++ lint checks).

Summary by CodeRabbit

  • Bug Fixes

    • Corrected APA102-family LED frame termination to use the required all-ones end frame.
    • Updated APA102, SK9822, and HD107 variants for consistent protocol behavior.
  • New Features

    • Added compile-time accessors for retrieving controller start and end frame values.
  • Tests

    • Added coverage validating framing behavior across supported legacy controller variants.

…locks

Commit 34a86a7 (#3669) fixed the channel-engine encoders
(fl/chipsets/encoders/{apa102,sk9822}.h) to emit all-ones (0xFFFFFFFF
per DWord) end-clock frames, matching the vendor datasheet requirement
that end clocks be all-ones so the final LED frame fully shifts through
a long cascade. The legacy addLeds<> controller templates in
fl/chipsets/apa102.h were never updated and still emitted mostly-zero
end clocks (APA102Controller: 0xFF000000; APA102ControllerHD,
SK9822Controller, SK9822ControllerHD, HD107Controller: 0x00000000),
which on long cascades can be misread as a new start frame.

Align all APA102-family legacy controller defaults with the encoder
contract, drop the now-stale "different END_FRAME" doc comments on
SK9822Controller/SK9822ControllerHD, and add public getStartFrame()/
getEndFrame() accessors so the wire-protocol contract is unit
testable without hardware.

Closes #3682
@coderabbitai

coderabbitai Bot commented Jul 16, 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: 37d5ae49-d10c-4e74-8343-66237cc0a15b

📥 Commits

Reviewing files that changed from the base of the PR and between 214d499 and 5f4f88d.

📒 Files selected for processing (2)
  • src/fl/chipsets/apa102.h
  • tests/fl/chipsets/spi_frame_protocol.cpp

📝 Walkthrough

Walkthrough

APA102-family legacy controllers now use all-ones end frames. Public constexpr accessors expose start and end frame values, and SPI protocol tests verify these values across APA102, SK9822, and HD107 variants.

Changes

APA102 end-frame alignment

Layer / File(s) Summary
Controller end-frame contract
src/fl/chipsets/apa102.h
The APA102 default and derived controller end frames change to 0xFFFFFFFF; getStartFrame() and getEndFrame() expose the configured framing constants.
Legacy controller framing validation
tests/fl/chipsets/spi_frame_protocol.cpp
Tests verify start-frame 0x00000000 and end-frame 0xFFFFFFFF for APA102, SK9822, and HD107 controller variants.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • FastLED/FastLED issue 3660: Addresses the same all-ones APA102/SK9822 end-frame contract and its validation.

Possibly related PRs

  • FastLED/FastLED#3669: Updates the corresponding APA102/SK9822 encoder framing to use all-ones end clocks.
  • FastLED/FastLED#3683: Updates APA102/SK9822 framing expectations and end-frame documentation.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: legacy APA102/SK9822 controllers now use all-ones end clocks.
Linked Issues check ✅ Passed The PR satisfies #3682 by switching legacy APA102/SK9822 end frames to 0xFFFFFFFF and adding protocol coverage.
Out of Scope Changes check ✅ Passed The changes stay within the protocol fix, comment cleanup, API accessors, and tests; no unrelated edits are evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 fix/sk9822-legacy-end-frame

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.

@zackees
zackees merged commit a5f021c into master Jul 16, 2026
11 of 12 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 16, 2026
@zackees
zackees deleted the fix/sk9822-legacy-end-frame branch July 16, 2026 07:07
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.

SK9822Controller (legacy addLeds path) still emits all-zero end clocks that #3669 declared invalid

1 participant