Skip to content

feat(channels): RenderingHint enum — Auto/Sync/Async (default Auto=0) on Channel #3184

Closed as not planned

Description

@zackees

Goal

Add a per-channel RenderingHint enum that lets sketches say whether they want FastLED.show() (or the underlying channel.show()) to block until the wire is done or return as soon as DMA is enqueued.

API

namespace fl {

// 0 = auto. Driver picks whichever mode is best for the current
// platform + transport choice. On platforms / transports that support
// async (DMA-backed peripherals), auto resolves to Async; on
// platforms without DMA / where async is meaningless, auto resolves
// to Sync.
enum class RenderingHint : u8 {
    Auto  = 0,  // default — let the driver choose
    Sync  = 1,  // show() blocks until transmission is complete
    Async = 2,  // show() returns as soon as DMA is enqueued
};

}  // namespace fl

Setter on Channel:

class Channel {
public:
    void setRenderingHint(RenderingHint hint) FL_NOEXCEPT;
    RenderingHint getRenderingHint() const FL_NOEXCEPT;
    // ...
};

Default: Auto (numerically zero — uninitialized members get the right default automatically).

Why an enum and not strings

  • Compile-time check — bad values are caught at the call site, not at runtime.
  • Smaller binary — no string table, no comparison machinery.
  • Self-documenting — `IDE autocomplete shows the three options instantly.
  • 0 = Auto makes default-construction the right answer everywhere.

Behavior contract

Hint show() semantics Frame-rate cost
Auto Driver picks. On DMA peripherals → Async. On bitbang / CPU-polled → Sync. best for platform
Sync show() does not return until the wire transmission is done. possibly slower (CPU stalls during transmission)
Async show() returns immediately after enqueueing DMA. Caller responsible for not calling show() again before the previous frame finishes (driver returns false if too early). best, but requires the caller to space frames sensibly

Why this is separate from transport-hint

RenderingHint controls when show() returns to the caller.
TransportHint (separate issue) controls which DMA/CPU path the driver uses to actually deliver bytes to the peripheral.

The two are orthogonal: you can have Sync + IsrStream (rare — block on a streaming transmission) just as much as Async + OneShot (common — DMA-backed driver returns immediately after enqueueing).

Acceptance

  • fl::RenderingHint enum defined with Auto = 0, Sync = 1, Async = 2.
  • Channel::setRenderingHint(...) + getter; default-constructed channels report Auto.
  • Each driver's show() honors the hint:
    • Auto: driver picks based on transport choice.
    • Sync: block until transmission complete.
    • Async: return after DMA enqueue.
  • Drivers that can't honor Async (bitbang, CPU-polled) silently treat Async as Sync — document this behavior in the header.
  • Drivers that can't honor Sync efficiently (some streaming peripherals) document the cost.
  • Test in tests/fl/channels/ confirms: with Async set, a sketch can do non-LED work between show() calls and the LED frames complete on the wire correctly.
  • bash autoresearch <board> for at least one DMA-backed driver per platform exercises both Sync and Async paths.

Out of scope

  • The transport-hint API (one_shot vs isr_stream vs cpu_poll) — separate issue filed alongside this one.
  • Multi-frame queueing — only one outstanding Async frame at a time for now. Multi-frame queue is a future enhancement.

Cross-references

Activity

  1. zackees commented on Jun 16, 2026

    @zackees
    MemberAuthor

    Closing — premature. Per user direction, the sync vs async rendering decision should not be locked in right now. Re-file when the trade-offs around async ordering, frame queueing, and per-driver completion semantics are settled.

  2. moved this from Triage to Done in FastLED Trackeron Jun 16, 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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions