Skip to content

fix(spi): make SK9822 framing datasheet-conformant - #3669

Merged
zackees merged 1 commit into
masterfrom
feat/rp2040-phase7-spi-protocol
Jul 15, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/rp2040-phase7-spi-protocol

Conversation

@zackees

@zackees zackees commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

Implements the Phase 7 software framing correction for #3660 / #3648.\n\n- Replaces SK9822's incorrect all-zero end frame with all-one end clocks in normal, HD, and auto-brightness encoders.\n- Makes APA102 and SK9822 auto-brightness zero-LED frames complete (start + end), matching their normal encoders.\n- Adds golden tests for 0/1/31/32/33/257 LEDs, brightness boundaries, BGR byte order, exact size, and every end-clock byte.\n\nValidated locally:\n- �ash test spi_frame_protocol --debug\n- �ash test spi_frame_protocol --cpp\n- �ash test fl_channels_channel --cpp\n- uv run --no-sync python ci/lint_cpp/run_all_checkers.py --no-rust\n\nThe attached-board Phase 7 public-API and loopback evidence remains tracked by #3660 and hardware gate #3631.\n\nCloses #3660

Summary by CodeRabbit

  • Bug Fixes

    • Corrected SK9822 frame termination to use the required all-ones end frame.
    • Ensured empty APA102 and SK9822 inputs produce complete frames.
    • Improved reliability for brightness handling while preserving pixel data.
  • Tests

    • Added coverage for APA102 and SK9822 framing, cascade boundaries, brightness clamping, and empty inputs.

@zackees
zackees merged commit 34a86a7 into master Jul 15, 2026
8 of 11 checks passed
@zackees
zackees deleted the feat/rp2040-phase7-spi-protocol branch July 15, 2026 13:08
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bec8b287-1129-45fc-8e5c-63ff8c1b3167

📥 Commits

Reviewing files that changed from the base of the PR and between 0c64dc4 and 8611ba6.

📒 Files selected for processing (4)
  • src/fl/chipsets/encoders/apa102.h
  • src/fl/chipsets/encoders/pixel_iterator.h
  • src/fl/chipsets/encoders/sk9822.h
  • tests/fl/chipsets/spi_frame_protocol.cpp

📝 Walkthrough

Walkthrough

APA102 and SK9822 encoders now use complete all-ones end frames, including zero-LED auto-brightness cases. Documentation and golden tests were updated for framing boundaries, brightness clamping, payload preservation, and exact output bytes.

Changes

SPI frame conformance

Layer / File(s) Summary
All-ones end-frame encoding
src/fl/chipsets/encoders/sk9822.h, src/fl/chipsets/encoders/pixel_iterator.h
SK9822 documentation and encoder paths now describe and emit all-ones end clocks.
Complete empty-input frames
src/fl/chipsets/encoders/apa102.h, src/fl/chipsets/encoders/sk9822.h
Auto-brightness encoders emit both start and end frames for zero-LED ranges.
Golden framing validation
tests/fl/chipsets/spi_frame_protocol.cpp
Tests cover cascade boundaries, brightness clamping, BGR payloads, end clocks, and empty-input frames.

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

Possibly related issues

✨ 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/rp2040-phase7-spi-protocol

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.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jul 15, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 15, 2026
zackees added a commit that referenced this pull request Jul 16, 2026
…uty fix + lint/test debt cleanup (#3683)

* feat(examples): add HydroPack dual EL-panel beat visualizer

Dual EL-panel audio-reactive example for ESP32-C3 that is also a valid
FastLED WASM sketch. INMP441 audio is normalized (signal conditioning,
mic profile, self-normalizing vibe analysis), then bass beats are split
by loudness: the inner panel fires on sensitive beats, the outer panel
only on loud ones. Panels are gated with low-frequency 50 Hz PWM
(LEDC, 12-bit) as required by EL inverter hardware. A ScreenMap disc +
ring preview renders the panels in the browser.

Refs #3681

Co-Authored-By: Claude Fable 5 <[email protected]>

* refactor(channels): move UART waveN encoder to the channel layer

The encoder is platform-neutral (inverted UART frame model plus
ChipsetTimingConfig only) but lived under platforms/esp/32 and was
pulled into the RP build through a forbidden cross-directory _build
include. Move the implementation to fl/channels/uart_wave_encoder.*,
compile it once via fl/channels/_build.cpp.hpp, keep the ESP-path
header as a forwarder, sort rpcommon/_build.cpp.hpp alphabetically,
and drop the banned *.cpp.hpp includes from the RP engine host tests
(the engines are already compiled into the library on every platform).

Clears the CppHppIncludes, PlatformIncludes, PlatformTrampoline,
IwyuPragmaBlock, and UnityBuild lint violations that were failing
`bash lint --cpp` on every PR.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(lint): clear RP driver and CI lint debt

- Add missing platforms/arm/rp/is_rp.h includes to the RP peripheral
  impls that gate on FL_IS_RP2040/FL_IS_RP2350
- uint32_t -> u32 in RP DMA transfer-count casts
- Annotate the deliberate ProgramStorage new/delete pair, the PIO
  instruction reinterpret_cast, and the static DMA capture buffer with
  the sanctioned lint suppressions
- Replace the tuple[int, int, int] return in test_rp_spi_loopback.py
  with a frozen slotted SpiPins dataclass (DCT002)
- ruff-format autofixes in five ci/ files

Together with the encoder move this returns `bash lint` to green.

Co-Authored-By: Claude Fable 5 <[email protected]>

* test(chipsets): align SK9822/APA102 tests with all-ones end clocks

Commit 34a86a7 (#3669) switched the SK9822 encoders to the
datasheet-required all-ones end clock frames and gave the zero-LED
paths a complete start+end frame, but left the unit tests asserting
the old 0x00 end frames. Update the expectations, helper, and test
names to the actual contract; fl_chipsets_encoders passes again.

Co-Authored-By: Claude Fable 5 <[email protected]>

* refactor(examples): drive HydroPack EL panels through the fl pin PWM facade

Code-review follow-up: replace the hand-rolled LEDC wrapper (with its
Arduino core 2.x/3.x fork) with fl::setPwmFrequency + fl::analogWrite,
the same 50 Hz EL-inverter gating path examples/ElPanelReactive uses.
Also dedupe the inner/outer beat handler into firePanel(), cache the
last written duty (50 Hz PWM only latches once per 20 ms period), pace
the frame loop for battery use, fix the millis-wrap first-frame
sentinel, and cross-reference ElPanelReactive.

Refs #3681

Co-Authored-By: Claude Fable 5 <[email protected]>

* refactor(channels): finish UART encoder move, drop ESP forwarding header

All includers of the legacy ESP-path header were repo-internal, so
update them to fl/channels/uart_wave_encoder.h and delete the
forwarder instead of keeping permanent indirection. Move the encoder
unit test to tests/fl/channels/ to mirror the source location (and
update the placement example in agents/tests.md). Replace the
non-ASCII doc glyphs the moved files inherited with ASCII per
cpp-standards.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(rp): drop no-op reinterpret_cast in PIO RX program setup

pio_instr is a typedef of fl::u16 and mProgramInstructions is already
u16[16], so plain pointer decay compiles without any cast; keeping the
reinterpret_cast (even suppressed) would silently reinterpret the
buffer if pio_instr ever changed width.

Co-Authored-By: Claude Fable 5 <[email protected]>

* docs(chipsets): correct SPI end-frame formula and SK9822 end-clock docs

The encoders write (num_leds / 32) + 1 end DWords, not ceil(num_leds/32)
as the doc comments claimed (they differ at 0 and exact multiples of
32), and SK9822 no longer has a different end frame from APA102 since
the #3669 all-ones fix. Also replaces the non-ASCII ceiling glyphs.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(esp32): route analogWrite/setPwm16 duty writes to the LEDC channel

The ESP32 native pin backend left analogWrite() and setPwm16() as
no-op stubs, so the documented setPwmFrequency() + analogWrite() PWM
flow configured the LEDC timer and then never updated the duty - the
output stayed at 0 (this silently broke the ElPanelReactive example
hardware path, and hydropack would have hit the same wall). Duty
writes now scale onto the LEDC channel allocated by
setPwmFrequencyNative(), with the full-on duty quirk handled.

Also clamp the pre-IDF-5.3 duty-resolution fallback to the SoC LEDC
timer width (14 bits on C3/S2/S3) instead of a fixed 16, which made
low frequencies like 50 Hz fail ledc_timer_config on those parts.

Found by the multi-agent code review for #3681.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(tests): restore UTF-8 bytes mangled during the encoder test move

The include-swap edits were applied through a PowerShell 5.1
Get-Content/Set-Content round trip, which added a UTF-8 BOM and
double-encoded the existing multibyte comment glyphs into mojibake.
Restore both files byte-for-byte from master and reapply only the
intended include swap.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[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