Repository navigation
Description
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.mdpriority table gains row 7 with the flag,
constraint, and PR link.agents/docs/binary-size-analysis.mdpriority table mirrors.
Acceptance
FASTLED_DISABLE_UCS7604=1build flag gates the UCS7604 cases.bash lint --cpppasses.- Default behavior (flag unset) unchanged — existing UCS7604-using
sketches continue to work. - 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=1build of NEOPIXEL Blink should be
~400-600 B lower. Default-flag build should be unchanged within
±50 B (regression-gate baseline does NOT change). docs/SLIM_ESP32S3.mdgains row 7.
Out of scope
- Auto-detecting WS2812-only usage at compile time. That requires
the template-trait static dispatch refactor in Meta: ESP32-S3 binary-size reduction — Batch 3 (successor to #2773) #2856 item 3.1. - Combining with the SPI gate into a single "clockless-only" or
"WS2812-only" flag. Keep them independent — users may want to gate
one without the other.
Related
- Meta: ESP32-S3 Blink bloat reduction (file:line concrete plan) — supersedes #2885 #2886 — parent meta + the audit cycle this PR continues.
- perf(esp32): gate SPI dispatch in Channel::showPixels behind FASTLED_DISABLE_SPI_CHIPSETS #2914 — SPI dispatch gate (the immediate pattern this mirrors).
- perf(esp32): gate emit* cold helpers on FASTLED_LOG_RUNTIME_ENABLED (~800 B) #2918 — emit-helper gate (the prior algorithmic win).
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
perf(esp32): gate UCS7604 clockless cases in Channel::showPixels behi…