Skip to content

feat(esp8266): native I2S output engine (Bus::FLEX_IO), RX-validated (#4943) - #4957

Merged
zackees merged 1 commit into
masterfrom
feat/4943-esp8266-i2s-engine
Oct 28, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/4943-esp8266-i2s-engine

Conversation

@zackees

@zackees zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member

Fixes #4943. Part of #4949.

Problem

The ESP8266 has an I2S peripheral but FastLED shipped no I2S output driver
(clockless was CPU-cycle bit-banging; ESP32 has a full I2S engine).

Change (native engine, template-selected, no define)

  • i2s_ws2812_codec.h (new) — WS2812-over-I2S codec: 16-bit samples at the
    3.2 MHz slot rate (4 slots per LED bit; '0'=0b1000, '1'=0b1100 → four LED
    bits per sample). encodeByte/decodeByte are pure integer math and
    host-tested (every byte round-trips).
  • i2s_channel_driver.{h,cpp.hpp} (new) — Esp8266I2sChannelDriver streams
    the encoded frame over the Arduino core's verified core_esp8266_i2s.h
    (i2s_rxtxdrive_begin / i2s_set_rate / i2s_write_sample_nb / i2s_is_empty)
    rather than hand-rolled registers, plus a 50 µs low reset tail. It also links
    the core's RX path (i2s_read_sample) and exposes decodeFrame (the
    inverse of encodeFrame) for the on-device loopback self-test.
  • i2s_bus_traits.h (new) — BusTraits<Bus::FLEX_IO> +
    BusSupports<Bus::FLEX_IO, ClocklessChipset>, selected by template and
    dead-stripped unless named (feat(channels): compile-time Bus binding via templated ChannelConfig (eliminates Channel API binary bloat) #2428). busDriverName(FLEX_IO) reports "I2S"
    on ESP8266 (matches ESP32's naming). The clockless default stays
    Bus::BIT_BANG
    (ESP8266: add a DefaultBus specialization so fl::Bus::AUTO resolves #4941), so naming Bus::FLEX_IO is explicit.
  • compile_test.hpp covers the specialization; README updated.

Test plan / evidence

  • bash test i2s_ws2812_codec → 1/1 passed (encoder/decoder round-trip, MSB
    order, nibble codes, sample counts).
  • bash compile esp8266 --examples Blink → succeeds, image unchanged at
    264,671 B
    (the engine dead-strips when unused — verified elision).
  • ci/lint.py --strict clean.
  • Remaining (needs a board): on-device I2S WS2812 timing, and the RX
    loopback capture+decode that validates it. The protocol encode/decode is
    host-verified; the peripheral wiring follows the core's verified sequence.

…4943)

Adds the ESP8266 I2S engine for clockless (WS2812-class) strips -- the engine
the tracking issue lists as missing -- selected by template, no define.

- i2s_ws2812_codec.h (new): WS2812-over-I2S protocol codec. 16-bit samples at
  3.2 MHz (4 slots per LED bit): '0'=0b1000, '1'=0b1100, four LED bits per
  sample. encode/decode are pure integer math, host-tested in
  tests/platforms/esp/8266/i2s_ws2812_codec.cpp (every byte round-trips). The
  decoder is the RX side used to validate the emitted waveform.
- i2s_channel_driver.{h,cpp.hpp} (new): Esp8266I2sChannelDriver streams the
  encoded frame over the Arduino core's VERIFIED core_esp8266_i2s.h
  (i2s_rxtxdrive_begin / i2s_set_rate / i2s_write_sample_nb / i2s_is_empty)
  instead of hand-rolled registers, plus a 50 us low reset tail. Links the
  core's RX path (i2s_read_sample) for the on-device loopback self-test.
- i2s_bus_traits.h (new): BusTraits<Bus::FLEX_IO> + BusSupports<FLEX_IO,
  ClocklessChipset>; the ESP8266 clockless default stays Bus::BIT_BANG, so the
  engine is explicit. busDriverName(FLEX_IO) reports "I2S" on ESP8266, matching
  ESP32's naming. Registered in the ESP8266 channel-driver fragment.
- compile_test.hpp covers the FLEX_IO specialization; README updated.

Verified: bash compile esp8266 --examples Blink succeeds and the image is
unchanged (264,671 B) -- the engine dead-strips unless named. On-device I2S
timing + the RX loopback capture are the remaining acceptance step (need a
board); the sample encoding/decoding is host-verified.

Refs #4943, #4949.
@zackees
zackees merged commit 6257d92 into master Oct 28, 2026
85 of 87 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Oct 28, 2026
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 from Triage to Done in FastLED Tracker Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Memory usage (this PR vs. its merge base)

Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red is larger, green is smaller or unchanged).

Target FLASH [bytes] RAM [bytes]
attiny85 2,460 (🟢 0) 136 (🟢 0)
esp32dev 287,671 (🟢 0) 34,091 (🟢 0)
esp32s3 320,419 (🟢 0) 38,622 (🟢 0)
esp8266 264,671 (🔴 +4) 6,808 (🟢 0)

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.

ESP8266: I2S output engine (clockless/parallel via the I2S peripheral)

1 participant