Skip to content

Is waiting in esp32 i2s really needed? #1384

Closed

Description

@psy0rz

at

// -- Wait here while the rest of the data is sent. The interrupt handler

it seems its waiting to send all the data.

i would to do some processing and to receive data packets from the network.

cant i just omit the delay? (or make a pull request to enable it via a #define perhaps)

Activity

  1. added
    platform: esp32
    area: drivers
    status: stale
    status: triage
    on Apr 16, 2026
  2. zackees commented on Jul 1, 2026

    @zackees
    Member

    Rolled up under meta #3516 — classic-ESP32 I2S parallel-out driver dev umbrella. Will be addressed as part of #3512 Phase 4: legacy addLeds<> keeps blocking behavior for compat, but users who want async can move to FastLED.add<Channel::create<>>() which uses the non-blocking IChannelDriver::poll() surface.

  3. zackees commented on Jul 1, 2026

    @zackees
    Member

    Status (2026-07-01) — async surface arrives via modern channel-manager

    The i2s_wait() blocking semaphore-take in clockless_i2s_esp32.h:355 where this request lives is scheduled for deletion per FastLED#3526 Phase 2e. Rather than adding a #define to gate the wait in the Yves path, the async surface arrives cleanly via the modern channel-manager API:

    • FastLED.setExclusiveDriver<fl::Bus::FLEX_IO, 0>() selects the modern engine at runtime.
    • IChannelDriver::poll() returns DriverState::BUSY while DMA is in flight and DriverState::READY when done — non-blocking, polled from the main loop.
    • Users who want to interleave network I/O during LED transmission poll from their own event loop instead of blocking on the semaphore.

    Blocking behavior stays on the legacy addLeds<WS2812, PIN, GRB>() path (via -DFASTLED_ESP32_I2S=1) during rollout for backward compat, until Phase 2e removes the Yves driver entirely.

    Tracking under FastLED#3516 rollup. Once Phase 4 of #3512 rewires ClocklessI2S through the modern engine (with the async poll() surface), this issue closes.

  4. added a commit that references this issue on Jul 1, 2026
  5. zackees commented on Jul 1, 2026

    @zackees
    Member

    Closed by #3526 Phase 2c (PR #3544/#3545) — modern engine has non-blocking poll() API

    The Yves showPixels() blocked on xSemaphoreTake(gTX_semaphore, portMAX_DELAY) at the end of every frame, forcing the CPU to sit idle while DMA drained — preventing network I/O interleaving, exactly the pain point this issue reported.

    The modern engine (landed via #3526 Phase 2c and finalised at Phase 2e — PR #3564) provides a non-blocking poll() surface through IChannelDriver:

    auto ch = fl::Channel::create<fl::Bus::FLEX_IO, 0, WS2812, GRB>(leds, N, /*pin=*/18);
    FastLED.add(ch);
    
    // Frame loop:
    ch->show();       // returns immediately, DMA + ISR run in background
    while (ch->poll() == fl::DriverState::BUSY) {
        handleNetworkIO();   // <-- runs while pixels are being clocked out
    }

    State machine: READY → enqueue → READY → show → BUSY → poll* → READY. The peripheral's DMA-done ISR flips the completion flag; poll() reads it, so no semaphore-take is needed — the caller polls at their own cadence.

    The Yves driver itself is deleted at Phase 2e (2026-07-01) — showPixels()'s blocking behavior is gone with the file. Users on legacy addLeds<> on classic ESP32 now route through RMT by default (unaffected by this issue's original symptom). Users who want the modern I2S1 engine explicitly:

    FastLED.setExclusiveDriver<fl::Bus::FLEX_IO, 0>();
    FastLED.addLeds<WS2812, 18, GRB>(leds, N);

    Legacy FastLED.show() on the modern engine still blocks for backward compatibility. Non-blocking is opt-in via the Channel::create<>() + poll() surface — deliberate choice so the legacy API stays predictable.

    See src/platforms/esp/32/drivers/i2s/README.md → "Modern channel API (async, non-blocking)" for the full pattern.

  6. moved this from Triage to Done in FastLED Trackeron Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: driversplatform: esp32status: stalestatus: triage

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions