Skip to content

feat(uart): waveN frame geometries — wave4 alongside wave10 with per-chipset selection (fixes #3574) - #3575

Merged
zackees merged 1 commit into
masterfrom
feat/uart-waven-geometry-3574
Jul 2, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/uart-waven-geometry-3574

Conversation

@zackees

@zackees zackees commented Jul 2, 2026 •

Copy link
Copy Markdown
Member

Fixes #3574. Follow-up to #3573 per bench review: wave10 (8 UART data bits = two LED bits × 4 controllable pulses, start/stop as fixed H/L bookends) is one point in a geometry family — this PR adds the wave4 sibling and picks per chipset.

What fits (investigated)

Geometry Frame Data bits Pulses/LED-bit Baud @ 800 kHz Verdict
wave10 (current) 10 8 5 4.0 M default
wave8-frame (new) 8 6 4 3.2 M second grid + faster-chipset coverage
9-bit frame 9 7 3 (×3 bits) 2.4 M rejected — wave3-eligible timings only
7-bit frame 7 5 7 (×1 bit) 5.6 M rejected — over the 5 Mbps cap

Concrete wins

  • SK6812: T0H=300/T1H=900 are exact multiples of period/4 — 0 ns quantization error (vs 120 ns total at wave10). Auto-selected.
  • LPD1886-class 1250 kHz (period 800 ns): infeasible at wave10 (6.25 Mbps > 5 M cap) → now representable at wave4, exactly 5.0 Mbps with 0 ns error.
  • Stability: 50 ns selection hysteresis prefers wave10, so WS2812 / WS2812B-V5 / WS2811-400 keep their long-proven shapes bit-for-bit.

Mechanics

Shared fitUartWave(timing, P) judges each geometry (baud cap, pulse range [1, P−1], distinctness, the #3572 400 ns minimum symbol separation, quantization tolerance); buildWave10Lut() and canRepresentTiming() both use it so admission and construction can't drift. Wave10Lut carries the selected pulses_per_bit; baud and UART word length derive from it; the driver re-inits the peripheral on geometry change; UartPeripheralEsp maps 5–8 data bits.

Verification

  • Host: 344/344 green (new tests pin SK6812→wave4 exact fit, LPD1886→wave4 @5.0 M, WS2812/V5/WS2811-400→wave10 unchanged); lint clean.
  • Bench (WROOM COM11, GPIO33→34): UART+WS2812B-V5 (wave10) 4/4 byte-exact; UART+SK6812 (wave4, 6 data bits @ 3.33 Mbps) 4/4 byte-exact — first wire-verified wave8-frame transmission. I2S and SPI regression 4/4 each.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved ESP32 UART support to better match LED timing requirements, including automatic selection of the most suitable waveform geometry.
    • Added support for additional UART data-bit settings so more timing profiles can be configured correctly.
  • Bug Fixes

    • Fixed timing handling for SK6812-based setups so they now use the correct timing and encoding path.
    • Reduced cases where compatible chipsets would be misdetected as unsupported.
  • Tests

    • Expanded coverage for waveform selection and timing compatibility across multiple chipset configurations.

…set selection (#3574)

Generalize the UART clockless encoder from fixed wave10 (10-bit frame,
8 data bits, 5 pulses/LED-bit) to a geometry family selected per
chipset timing. New wave8-frame geometry: 6 data bits + start/stop =
8-bit frame = 4 pulses/LED-bit at 20% lower baud.

- Shared fitUartWave(timing, P) helper judges each geometry (baud cap,
  [1, P-1] pulse range, distinctness, 400 ns minimum symbol separation
  from #3572, quantization tolerance) — buildWave10Lut and
  canRepresentTiming can no longer drift apart.
- Selection: lower total quantization error wins, with 50 ns
  hysteresis preferring wave10 so proven chipset shapes are stable:
  WS2812 / WS2812B-V5 / WS2811-400 unchanged; SK6812 upgrades to wave4
  (T0H/T1H exact multiples of period/4 — 0 ns error vs 120 ns);
  LPD1886-class 1250 kHz chipsets become REPRESENTABLE (wave10 needs
  6.25 Mbps > cap; wave4 fits at exactly 5.0 Mbps, 0 ns error).
- Wave10Lut carries pulses_per_bit; baudRate()/dataBits() derive from
  the selected geometry. Driver re-inits the peripheral on word-length
  change; UartPeripheralConfig gains mDataBits (default 8);
  UartPeripheralEsp maps 5-8 data bits to UART_DATA_x_BITS.
- AutoResearch: "SK6812" timing name added to runSingleTest resolution
  so the wave4 path is bench-testable.

Bench (WROOM COM11, GPIO33->34): UART+WS2812B-V5 (wave10) 4/4
byte-exact; UART+SK6812 (wave4, 6 data bits @ 3.33 Mbps) 4/4
byte-exact — first wire-verified wave8-frame transmission. I2S/SPI
regression 4/4 each. Host: 344/344, lint clean.

Co-Authored-By: Claude Fable 5 <[email protected]>
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jul 2, 2026
@zackees
zackees merged commit 3c6ba9e into master Jul 2, 2026
10 of 11 checks passed
@coderabbitai

coderabbitai Bot commented Jul 2, 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: cb3f32cd-3d1a-42e7-a0a1-3c88bd3b13a2

📥 Commits

Reviewing files that changed from the base of the PR and between 6644120 and 10d2d34.

📒 Files selected for processing (8)
  • examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp
  • src/platforms/esp/32/drivers/uart/channel_driver_uart.cpp.hpp
  • src/platforms/esp/32/drivers/uart/channel_driver_uart.h
  • src/platforms/esp/32/drivers/uart/iuart_peripheral.h
  • src/platforms/esp/32/drivers/uart/uart_peripheral_esp.cpp.hpp
  • src/platforms/esp/32/drivers/uart/wave8_encoder_uart.cpp.hpp
  • src/platforms/esp/32/drivers/uart/wave8_encoder_uart.h
  • tests/platforms/esp/32/drivers/uart/wave8_encoder_uart.cpp

📝 Walkthrough

Walkthrough

Generalizes the ESP32 UART clockless encoder from a fixed wave10 (P=5) frame geometry to support a second wave8-frame (P=4) geometry, selecting between them per-chipset via a shared feasibility/error-fitting helper. Propagates the selected UART data-bit width through the channel driver and peripheral, adds an SK6812 timing branch in an example, and updates tests.

Estimated code review effort: 4 (Complex) | ~60 minutes

Changes

UART waveN geometry generalization

Layer / File(s) Summary
Wave geometry fitting core and LUT builder
src/platforms/esp/32/drivers/uart/wave8_encoder_uart.h, wave8_encoder_uart.cpp.hpp
Wave10Lut gains pulses_per_bit, dataBits(), and geometry-aware baudRate(); a new fitUartWave()/UartWaveFit helper centralizes feasibility checks, and buildWave10Lut()/canRepresentTiming() now select between P=5 and P=4 geometries with a 50ns hysteresis.
UART driver and peripheral data-bits wiring
channel_driver_uart.h, channel_driver_uart.cpp.hpp, iuart_peripheral.h, uart_peripheral_esp.cpp.hpp
Adds mCurrentDataBits tracking, derives required baud/data-bits from the LUT, extends reinit conditions to cover data-bits changes, adds mDataBits to UartPeripheralConfig, and configures UART word length (5/6/7/8 bits) accordingly.
Unit tests for geometry selection
tests/platforms/esp/32/drivers/uart/wave8_encoder_uart.cpp
Adds a P=4 frame measurement helper and updates WS2812/WS2812B-V5/SK6812/LPD1886 tests to verify geometry selection, pulse counts, data bits, and baud rates.
Example SK6812 timing selection
examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp
Adds explicit handling for the "SK6812" timing name to resolve the SK6812 timing config and encoder.

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/uart-waven-geometry-3574

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.

UART clockless: generalize wave10 to waveN frame geometries (wave4/wave5) with per-chipset selection

1 participant