Skip to content

Gate UCS7604 clockless cases in Channel::showPixels behind FASTLED_DISABLE_UCS7604 (~500 B) (#2886) #2920

Closed

Description

@zackees

Goal

Gate the UCS7604 clockless cases in Channel::showPixels behind an opt-in FASTLED_DISABLE_UCS7604=1 build flag — same pattern as PR #2914's SPI dispatch gate. For WS2812-only sketches (the stock Blink case), users opt in and the linker dead-strips the two encodeUCS7604_16bit_RGB / encodeUCS7604_16bit_RGBW template instantiations plus the writeUCS7604 wrapper.

Parent: #2886 — sixth algorithmic-bloat reduction in the audit cycle. Tactical opt-in (won't move the default-flag baseline).

Why this is concrete (but small)

fl::Channel::showPixels at src/fl/channels/channel.cpp.hpp:486-499 has a clockless dispatch:

if (mChipset.is<ClocklessChipset>()) {
    const ClocklessChipset* clockless = mChipset.ptr<ClocklessChipset>();
    switch (clockless->encoder) {
        case ClocklessEncoder::CLOCKLESS_ENCODER_WS2812:
            pixelIterator.writeWS2812(&data);
            break;
        case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_8BIT:
        case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_16BIT:
        case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_16BIT_1600:
            writeUCS7604(&data, pixelIterator, clockless->encoder,
                         mSettings, mRgbOrder);
            break;
    }
}

For a stock NEOPIXEL (WS2812) Blink sketch, the UCS7604 branch is dynamically unreachable, but every reference inside it is statically reachable — the linker keeps writeUCS7604 and its transitive closure (encodeUCS7604_16bit_RGB / encodeUCS7604_16bit_RGBW) alive.

Measured baseline (post-#2918 ELF, master @ ded5eea93f)

UCS7604 encoder symbols currently linked into a stock NEOPIXEL Blink:

Symbol Size
fl::encodeUCS7604_16bit_RGBW<ScaledPixelIteratorRGBW, ...> 184 B
fl::encodeUCS7604_16bit_RGB<ScaledPixelIteratorRGB, ...> 152 B
writeUCS7604(...) (anon-ns wrapper, size estimated) ~100-200 B
Estimated total ~400-500 B

Plus the inline switch-case footprint inside showPixels (~50-100 B for the 3 case labels + dispatch).

Conservative projected saving: ~400-600 B on NEOPIXEL Blink builds with the flag enabled.

Deliverable

src/fl/channels/channel.cpp.hpp — gate the UCS7604 cases

 if (mChipset.is<ClocklessChipset>()) {
     const ClocklessChipset* clockless = mChipset.ptr<ClocklessChipset>();
     switch (clockless->encoder) {
         case ClocklessEncoder::CLOCKLESS_ENCODER_WS2812:
             pixelIterator.writeWS2812(&data);
             break;
+#if !defined(FASTLED_DISABLE_UCS7604) || !FASTLED_DISABLE_UCS7604
         case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_8BIT:
         case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_16BIT:
         case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_16BIT_1600:
             writeUCS7604(&data, pixelIterator, clockless->encoder,
                          mSettings, mRgbOrder);
             break;
+#endif
     }
 }

Behavior when the flag is set

If a user sketch sets FASTLED_DISABLE_UCS7604=1 AND uses
FastLED.addLeds<UCS7604, ...>, the UCS7604 case falls through to the
switch's implicit default — calling showPixels() on that channel
silently emits nothing. Same trade-off shape as PR #2914 (SPI gate)
and PR #2894 (boot-banner shim).

Documentation

  • docs/SLIM_ESP32S3.md priority table gains row 7 with the flag,
    constraint, and PR link.
  • agents/docs/binary-size-analysis.md priority table mirrors.

Acceptance

  1. FASTLED_DISABLE_UCS7604=1 build flag gates the UCS7604 cases.
  2. bash lint --cpp passes.
  3. Default behavior (flag unset) unchanged — existing UCS7604-using
    sketches continue to work.
  4. Measured against the post-perf(esp32): gate emit* cold helpers on FASTLED_LOG_RUNTIME_ENABLED (~800 B) #2918 ELF baseline (344,769 B), a
    -DFASTLED_DISABLE_UCS7604=1 build of NEOPIXEL Blink should be
    ~400-600 B lower. Default-flag build should be unchanged within
    ±50 B (regression-gate baseline does NOT change).
  5. docs/SLIM_ESP32S3.md gains row 7.

Out of scope

Related

🤖 Generated with Claude Code

Activity

  1. added a commit that references this issue on Jun 7, 2026
    9f9abd9
  2. moved this from Triage to Done in FastLED Trackeron Jun 7, 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