Skip to content

PARLIO variable-timing: compress/expand waveN encoding for non-800kHz chipsets #3561

Closed

Description

@zackees

Context

Follow-up from #3526 Phase 2e review on the classic-ESP32 I2S engine, where the modern I2S peripheral (i2s_peripheral_esp32dev_esp.cpp.hpp) was updated to accept a variable mPixelClockHz in its config so the engine can drive non-800kHz chipsets (e.g., WS2811 at 400 kHz, SK6812 with different T1/T2/T3, etc.). PARLIO's engine should mirror this pattern.

Current PARLIO behavior

parlio_engine.cpp.hpp selects wave3 when canUseWave3(timing) is true (per-chipset via wave3ClockFrequencyHz(timing)) or wave8 with FL_ESP_PARLIO_CLOCK_FREQ_HZ (a compile-time constant). Wave8's clock is effectively fixed at that constant across all wave8-eligible chipsets.

For chipsets whose bit rate isn't 800 kHz (e.g., WS2811 at 400 kHz), the wave8 clock should scale accordingly (400 kHz × 8 pulses/bit = 3.2 MHz, not 8 MHz). Otherwise the encoded pulse widths don't match the target chipset timing.

Proposal

Investigate whether PARLIO's clockless engine should:

  1. Compute wave8 clock from chipset timing (clock_hz = 8 * data_rate_hz where data_rate = 1 / (T1+T2+T3)) instead of using the fixed FL_ESP_PARLIO_CLOCK_FREQ_HZ compile-time constant.

  2. Fall back to wave3 or a higher-oversampling encoder for chipsets whose target clock exceeds PARLIO's max programmable rate on the specific SoC (P4 / C6 / H2 / C5 all have different upper bounds).

  3. Match the I2S impl's variable-timing pattern (see the solveI2sClockDivider follow-up issue for hoisting that helper to a shared location).

Acceptance

  • Design decision: does PARLIO recompute clock per-chipset, or does the existing fixed clock cover the practical chipset set (WS2812, WS2812B, SK6812, WS2811, APA104, TM1809, etc.)?
  • If per-chipset: parlio_engine.cpp.hpp computes clock at configureTiming() time, mClockFreqHz is chipset-derived.
  • Regression tests: verify that a WS2812B strip still gets the correct 8 MHz clock (backward compat), and that a WS2811 strip gets ~3.2 MHz (new behavior).

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions