Skip to content

feat(i2s): wave3 sibling encoder for I2S1 modern driver (#3526 Phase 2a) - #3554

Merged
zackees merged 2 commits into
masterfrom
feat/i2s-wave3-encoder-3526
Jul 1, 2026
Merged

zackees merged 2 commits into
masterfrom
feat/i2s-wave3-encoder-3526

Conversation

@zackees

@zackees zackees commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds encodeChannelWave3_i2s1 alongside encodeChannelWave8_i2s1 — satisfies the #3526 acceptance criterion "Wave3 fallback path exercised for a three-slot chipset".

Wave3 saves 2.67x memory vs wave8 for chipsets whose T1/T2/T3 rounds to 1/2/N ticks per 3-tick period (e.g., WS2812 canonical timing). Gated by fl::canUseWave3(timing); per-chipset clock via fl::wave3ClockFrequencyHz(timing) instead of wave8's fixed 8 MHz.

Anti-drift + no-inline-bloat

Encoder reuses the shared fl::wave3Transpose_16 kernel from fl/channels/wave3.h (same anti-drift rule as the wave8 sibling — if the shared kernel changes, we inherit it). Host tests verify byte-exact output against a direct-kernel-call reference using canonical WS2812 timing.

Drops fl/channels/detail/wave3.hpp / detail/wave8.hpp force-inline includes from this .cpp.hpp — the unity build pulls this file across multiple TUs and the force-inline kernels would emit in each. Public .h declarations resolve at link time to the single out-of-line definitions in wave3.cpp.hpp / wave8.cpp.hpp.

Test plan

  • bash test wave8_encoder_i2s1 — passes
  • bash test --cpp — 344/344 tests pass
  • bash lint --cpp — clean

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added Wave3 I2S1 encoding support alongside the existing Wave8 path.
    • Introduced frame-size helpers and validation for Wave3-encoded output.
  • Bug Fixes

    • Improved setup stability by extending watchdog coverage during startup and serial attachment waits.
    • Prevents unintended reboots when the device takes longer to connect over serial.
  • Tests

    • Added coverage for Wave3 encoding output and invalid input handling.

zackees and others added 2 commits July 1, 2026 13:50
…e COM port

Previously the unified WDT was armed lazily by FL_WATCHDOG_AUTO() at
the top of loop(). If setup() hung (RPC bind null-deref, stalled
static-init, wedged serial handshake), no WDT was armed and the COM
port stayed owned by a dead sketch until manual power-cycle.

Arm the WDT with a 20 s window at the very top of setup() so a hang
here auto-reboots. Feed the WDT in the serial-monitor wait loop
because on classic ESP32 (non-USB-CDC) that loop can span up to
AUTORESEARCH_SERIAL_WAIT_MS = 120 s, well past the setup WDT window.

FL_WATCHDOG_AUTO() at loop() top re-arms with the shorter loop-scoped
timeout once setup() has finished.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds `encodeChannelWave3_i2s1` alongside the existing `encodeChannelWave8_i2s1`
to satisfy the meta-issue acceptance criterion "Wave3 fallback path
exercised for a three-slot chipset".

Wave3 saves 2.67x memory vs wave8 for chipsets whose T1/T2/T3 timing
rounds to 1/2/N ticks per 3, gated by `fl::canUseWave3(timing)`. Pixel
clock is per-chipset via `fl::wave3ClockFrequencyHz(timing)` instead of
the fixed 8 MHz wave8 rate.

The encoder reuses the shared `fl::wave3Transpose_16` kernel from
`fl/channels/wave3.h` — same anti-drift rule as the wave8 sibling. Host
tests verify byte-exact output against a direct-kernel-call reference
using canonical WS2812 timing (verified wave3-eligible).

Drops the `fl/channels/detail/wave3.hpp` and `detail/wave8.hpp`
force-inline includes from this .cpp.hpp — the unity build pulls this
file across multiple TUs and the force-inline kernels would emit in
each. The public `.h` declarations resolve at link time to the single
out-of-line definitions in `wave3.cpp.hpp` / `wave8.cpp.hpp`, avoiding
double-inline bloat.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit 73b845b into master Jul 1, 2026
12 checks passed
@coderabbitai

coderabbitai Bot commented Jul 1, 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: d945622b-d4ad-4329-a757-ee2c30ab01bf

📥 Commits

Reviewing files that changed from the base of the PR and between 2ffc318 and 9c58a45.

📒 Files selected for processing (4)
  • examples/AutoResearch/AutoResearch.ino
  • src/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.cpp.hpp
  • src/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.h
  • tests/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.cpp

📝 Walkthrough

Walkthrough

This PR makes two unrelated changes: it updates AutoResearch.ino to arm the unified watchdog earlier in setup() with a longer timeout and feeds the watchdog during the serial-ready wait; and it adds a new Wave3 sibling encoder (encodeChannelWave3_i2s1) to the ESP32 I2S1 driver, with sizing constants, declarations, implementation, and tests.

Changes

AutoResearch Watchdog Setup

Layer / File(s) Summary
Setup watchdog arming and serial-wait feeding
examples/AutoResearch/AutoResearch.ino
Adds AUTORESEARCH_SETUP_WATCHDOG_TIMEOUT_MS, arms the watchdog at the start of setup(), and feeds the watchdog in a loop while waiting for fl::serial_ready() instead of a single polling line.

Wave3 I2S1 Encoder Addition

Layer / File(s) Summary
Wave3 encoder API declarations
src/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.h
Includes fl/channels/wave3.h, adds kWave3I2s1BytesPerBytePosition, wave3I2s1EncodedFrameSize, and declares encodeChannelWave3_i2s1.
Wave3 encoder implementation
src/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.cpp.hpp
Replaces direct wave8.hpp inclusion with a comment noting reliance on out-of-line definitions, and implements encodeChannelWave3_i2s1 with bounds validation, lane packing, and wave3Transpose_16 dispatch.
Wave3 encoder tests
tests/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.cpp
Adds tests verifying byte-exact output against wave3Transpose_16 and rejection of invalid lane counts and undersized buffers.

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

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#3528: Extends the same wave8_encoder_i2s1 module and tests introduced there with the new Wave3 encoder.
  • FastLED/FastLED#2534: Modifies the underlying wave3_transpose_16 implementation that the new encodeChannelWave3_i2s1 depends on.
  • FastLED/FastLED#2532: Rewrites wave3_transpose_16 with equivalence tests, directly connected via the shared transpose kernel used by the new encoder.
✨ 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/i2s-wave3-encoder-3526

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.

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