Repository navigation
feat(i2s): wave8 encoder for classic-ESP32 I2S1 (#3526 Phase 2a) - #3528
Conversation
New `wave8_encoder_i2s1` — general clockless byte-stream encoder that dispatches through the SHARED `fl::wave8Transpose_16_bf1` and `fl::wave8Transpose_16x4_bf1_pipe4` kernels. Follows the same shape as PARLIO's wave8 hot loop (`parlio_engine.cpp.hpp:1024-1069`). Does NOT duplicate the transpose implementation or introduce a private LUT builder — reuses `fl::Wave8ByteExpansionLut` via `buildWave8ByteExpansionLUT()` from `src/fl/channels/wave8.h`. ## Rationale Per #3526 (rolled up under #3516 meta): the modern classic-ESP32 I2S driver is being rebuilt as a general clockless driver in the same shape as PARLIO — using wave8/wave3 encoding, NOT delegating to the Yves per-chipset bit-pattern driver. This is the first landable piece of that work: a pure encoder that has no peripheral / DMA / ISR dependencies and can be host-verified against the shared transpose kernels for byte-exact correctness. ## Anti-drift discipline (#3524 post-mortem) The recent #3524 issue documents the parlio_encode.h "facade" pattern where AutoResearch measured a mirror of the production hot loop instead of the real one — silent drift risk. This file deliberately avoids that pattern: - No private transpose kernel — calls `fl::wave8Transpose_16_bf1` / `fl::wave8Transpose_16x4_bf1_pipe4` directly, so this encoder can't diverge from PARLIO's production path. - No private LUT builder — uses `buildWave8ByteExpansionLUT()` from the shared channel LUT surface. - Host tests compare the encoder output against direct calls to those same shared kernels with identical inputs. If a future refactor introduces a subtle behavioural change in the encoder wrapper, the divergence surfaces immediately as a test failure. ## Files - `src/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.h` — public API + docs - `src/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.cpp.hpp` — encoder implementation (~40 LoC of adaptation around the shared transpose calls) - `tests/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.cpp` — 6 host test cases: - Rejects zero / >16 lanes - Rejects undersized input / output - One-lane one-byte byte-exact match against `wave8Transpose_16_bf1` direct call - Four-byte batch byte-exact match against `wave8Transpose_16x4_bf1_pipe4` direct call - Inactive-lane bytes ignored (garbage in lanes 1..15 doesn't pollute the transpose when num_lanes=1) - `src/platforms/esp/32/drivers/i2s/_build.cpp.hpp` — added the new cpp.hpp to the unity build alphabetically ## What this does NOT do - Does NOT wire the encoder into `I2sPeripheralEsp32DevEsp::transmit()` — that's Phase 2b (needs the real DMA descriptor ring + ISR machinery which requires bench validation). - Does NOT include wave3 support — Phase 2a follow-up. - Does NOT touch the classic Yves `i2s_esp32dev.cpp.hpp` driver — that stays untouched until Phase 2e's REQUIRED deletion (per #3526 acceptance criteria). ## Verification - `bash test --cpp`: 345/345 pass — 1 new test file with 6 subcases, all byte-exact against the shared transpose kernels. - `bash lint --cpp`: clean. Part of #3516 meta / #3526 Phase 2a. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds a new classic-ESP32 I2S1 Wave8 encoder consisting of a public header declaring ChangesESP32 I2S1 Wave8 encoder
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant encodeChannelWave8_i2s1
participant wave8Transpose_16x4_bf1_pipe4
participant wave8Transpose_16_bf1
Caller->>encodeChannelWave8_i2s1: input, bytes_per_lane, num_lanes, lut, output
encodeChannelWave8_i2s1->>encodeChannelWave8_i2s1: validate shapes and sizes
alt >=4 byte positions remain and output permits
encodeChannelWave8_i2s1->>wave8Transpose_16x4_bf1_pipe4: gathered 16-lane batch
wave8Transpose_16x4_bf1_pipe4-->>encodeChannelWave8_i2s1: encoded bytes
else single byte position
encodeChannelWave8_i2s1->>wave8Transpose_16_bf1: gathered 16-lane bytes
wave8Transpose_16_bf1-->>encodeChannelWave8_i2s1: encoded bytes
end
encodeChannelWave8_i2s1-->>Caller: true/false
Possibly related issues
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
…se 2b) (#3540) `I2sPeripheralEsp32DevEsp::initialize()` no longer stubs — it now configures the I2S1 peripheral via the tested Yves C-style utilities (`i2s_define_bit_patterns` + `i2s_init` from `i2s_esp32dev.h`) that have been production since #3479. ## Hardware-ownership check Adds `i2s_is_initialized()` guard so the modern peripheral refuses to bind if the classic `ClocklessI2S<>` template on `-DFASTLED_ESP32_I2S=1` already claimed I2S1. First-in-wins prevents the two paths from racing on the shared hardware. ## Timing default Chipset timing defaults to canonical WS2812B (`TIMING_WS2812_800KHZ` via `to_runtime_timing<>`). Per-channel timing dispatch arrives with the modern engine's Phase 2b-encoder integration — for now this matches every previously-working I2S user's configuration. ## Scope - `initialize()` now real (was stub returning true without touching hardware). - `deinitialize()` still no-op — Phase 2b-deinit follow-up will free the ISR handle + DMA descriptors. - `transmit()` still returns synchronous stub — Phase 2b-DMA follow-up wires the wave8 encoder (#3528) output through I2S1 DMA. ## Verification - `bash test --cpp`: 345/345 pass (existing engine tests unchanged — no code path currently invokes `initialize()`). - `bash lint --cpp`: file clean (unrelated pre-existing violations in `platforms/arm/lpc/rx_sct_capture.cpp.hpp` fixed in follow-up). - **Bench**: `bash autoresearch esp32dev` flashes + boots clean on attached WROOM COM11 with new initialize() in the binary. `RESULT: {"type":"ready",...}` at ~2s uptime, ping successful. Since no code path invokes the modern peripheral in this build (`Bus::FLEX_IO, 0` still binds to `I2S_SPI` — Phase 2d does the swap), initialize() is dormant but present. Part of #3516 meta / #3526 Phase 2b. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
New
wave8_encoder_i2s1— general clockless byte-stream encoder for the modern classic-ESP32 I2S1 driver. First landable piece of the #3526 architectural rewrite: wave8/wave3 encoding like PARLIO, NOT delegate to Yves.Anti-drift discipline
Deliberately avoids the mirror-cheat pattern flagged in FastLED#3524:
fl::wave8Transpose_16_bf1/wave8Transpose_16x4_bf1_pipe4kernels directly. No private transpose.buildWave8ByteExpansionLUT()fromsrc/fl/channels/wave8.h. No private LUT builder.Files
src/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.h— public API + docssrc/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.cpp.hpp— ~40 LoC of adaptation around shared callstests/platforms/esp/32/drivers/i2s/wave8_encoder_i2s1.cpp— 6 test cases: input bounds rejection, one-lane byte-exact match, four-byte batch byte-exact match, inactive-lane zero-paddingsrc/platforms/esp/32/drivers/i2s/_build.cpp.hpp— unity build registrationWhat this does NOT do
I2sPeripheralEsp32DevEsp::transmit()— that's Phase 2b (needs real DMA + ISR, bench-blocked).Test plan
bash test --cpp: 345/345 pass (1 new test file, 6 subcases)bash lint --cpp: cleanPart of #3516 meta / #3526 Phase 2a.
Summary by CodeRabbit