Repository navigation
Description
Parent: #3244 (Phase 3 burn-down).
Goal
Introduce a ClocklessControllerRuntime concrete class that holds chipset timing (T1, T2, T3, RESET) and color order as runtime values instead of compile-time template parameters. Preserves the user-facing FastLED.addLeds<CHIPSET, PIN, ORDER>(...) API. Per-chipset vtable + per-EOrder PixelController specialization collapses to a single concrete class for any (chipset × order) combination on platforms where runtime dispatch is acceptable.
Reproduction (baseline)
Build a Blink-style sketch with multiple chipsets active:
bash bloat teensy40 --example Blink --top 15
# Look for fl::Channel::showPixels<PixelController<EOrder, lanes, mask>> entries.
# On Teensy 4 / AutoResearch (single chipset, GRB) the single instance is ~5.6 KB.
# A 4-chipset sketch (WS2812 + APA102 + SK9822 + WS2811) would pay 4× that = ~22 KB.
Acceptance
- PR introduces
fl::ClocklessControllerRuntimeinfl/channels/-- a non-templatedCLEDControllersubclass that:- Holds
ChipsetTiming(runtime u32 T1/T2/T3/RESET) andEOrder(runtime u8) members. - Implements
show()/showColor()/init()as non-template virtual overrides. - Routes the actual transmission through the existing
IChannelDriversingleton (fl::ChannelManager).
- Holds
- User-facing
FastLED.addLeds<CHIPSET, PIN, ORDER>(...)API surface is unchanged. Internally it forwards toClocklessControllerRuntime(pin, to_runtime_timing<TIMING>(), ORDER). - Gated via
FL_USE_RUNTIME_CLOCKLESS(or similar). On ESP32/Teensy/RP2040/WASM the runtime variant becomes the default. AVR / LPC8xx / ESP8266 keep the existing template path (cycle-tight bit-banging requires compile-time timing -- seesrc/platforms/avr/clockless_avr.h:_dc<N>andsrc/platforms/arm/common/m0clockless_c.h's explicit instantiations). - Measured savings on at least one production sketch with ≥ 3 chipset specializations on Teensy 4 or ESP32-S3: ≥ 5 KB net flash drop.
- No regression on single-chipset benchmarks for frame rate (the indirect call per pixel adds < 60 ns on Cortex-M7; should be invisible against WS2812's 30 µs per pixel).
Design reference
The FastLED rendering-side bloat audit run during #3235 documented:
- 32 distinct
TIMING_*structs insrc/fl/chipsets/led_timing.h. - 29 user-facing
*Controllertemplate subclasses insrc/chipsets.h. - The post-feat(channels): compile-time Bus binding via templated ChannelConfig (eliminates Channel API binary bloat) #2428
IChannelDriver+Busenum layer already provides the right type-erasure seam. - AVR / LPC M0 explicit-instantiation blockers (cycle-counted asm needs constant timing).
Worst-case codegen examples in the repo: examples/Blink/Blink.ino and examples/RGBCalibrate/RGBCalibrate.ino instantiate ~40 chipset types each (most guarded by #if FORCE_SOFTWARE_PINS, but the compiler still sees them).
Risk
- AVR —
_dc<N>template-specialized cycle delays require compile-time constants. Mitigation: AVR keeps the legacy template path; runtime variant is opt-in. - LPC M0 / Cortex-M0+ —
showLedData<HI_OFFSET, LO_OFFSET, TIMING, ORDER, WAIT_TIME>(inm0clockless_c.h) constexpr-folds timing into the cycle-tight loop. Same mitigation as AVR. - ESP8266 / older ARM — similar story for cycle-tight bit-bangers. Same mitigation.
- RGBW emulation —
RGBWEmulatedController/setRgbw()plumbing operates onCLEDController*and is unaffected.
Out of scope
- The 32-TIMING-struct catalog in
led_timing.h-- keep them asTIMING_*types and addto_runtime_timing<TIMING>()consumers (already exists per the audit). - ESP32 RMT5 internals (already nearly fully type-erased post feat(channels): compile-time Bus binding via templated ChannelConfig (eliminates Channel API binary bloat) #2428).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity
zackees commentedon Jun 19, 2026
What is going wrong
Tier 2F (
ClocklessControllerRuntime) is a multi-PR architectural change touching every chipset family. The rendering-side bloat audit catalogued the constraints:TIMING_*structs insrc/fl/chipsets/led_timing.h.*Controllertemplate subclasses insrc/chipsets.h._dc<N>template-specialized cycle delays) and LPC8xx (m0clockless_c.hshowLedData<HI, LO, TIMING, ORDER, WAIT>explicit instantiations) require compile-time timing — runtime variant must be opt-in.PixelControllerspecialization on cycle-counted platforms.The PR would need to:
ClocklessControllerRuntimenon-template class.FastLED.addLeds<CHIPSET, PIN, ORDER>(...)to forward to it on opt-in platforms.That's not a single session-sized PR. The audit explicitly called it "medium-hard, different leverage axis (per-chipset, not per-Sig)."
Reproduction status
Baseline measurement command in the issue body works:
Symptom is falsifiable. Only "small, well-bounded feature" criterion fails.
Planned fix (what would unblock this sub-issue)
Decompose into phases:
ClocklessControllerRuntimeas a standalone new class (no integration). Single new file. Bounded.FL_USE_RUNTIME_CLOCKLESSmacro + addLeds dispatch fork. Single header touch + one platform's chipset.h. Bounded.Each phase is small enough to pass intake independently.
Recommendation
Skip this sub-issue in the current /clud-fix run. When ready:
zackees commentedon Jun 19, 2026
What is going wrong
#3248 is a well-specified issue (concrete repro, falsifiable ≥5 KB target, explicit acceptance checklist) but it fails the
/clud-fix"scope sanity" intake bullet: the ask is a multi-day architectural refactor, not a small well-bounded change. Trying to one-shot it in a single agent session would either:None of those are acceptable per the project's "No half-finished implementations" rule (
CLAUDE.md→ Core Principles).Scope breakdown — why this is multi-PR work
The acceptance checklist composes five separable PRs:
fl::ClocklessControllerRuntime(non-templatedCLEDControllersubclass) holdingChipsetTiming+EOrderas runtime members. Route through existingIChannelDriver(the post-#2428 seam exists). GatedFL_USE_RUNTIME_CLOCKLESS=0by default. Host-only unit tests.to_runtime_timing<TIMING>()consumers +FastLED.addLeds<CHIPSET,PIN,ORDER>forwarding path. Keep template path as the active default. Cross-platform compile verification._dc<N>inclockless_avr.h,showLedData<...>inm0clockless_c.h). Per-platform compile matrix verification.That's a Tier 2F sub-meta in its own right.
Touched surface (per-file count, approx)
src/chipsets.h— 29*Controllertemplate subclasses; each needs a forwarder to the runtime variant when flag is set.src/fl/chipsets/led_timing.h— 32TIMING_*structs; theto_runtime_timing<TIMING>()helper already exists per the audit, but consumer wiring is missing.src/FastLED.h—addLeds<>template forwarders.src/platforms/{avr,arm/lpc,arm/common,esp/8266}/...— keep template path intact (5-6 files touched only to gate the runtime variant out).src/platforms/{esp/32,arm/common/m4,arm/common/m7,rp2040,wasm}/...— opt into the runtime variant on flag-on (5-6 files).src/fl/channels/clockless_controller_runtime.{h,cpp.hpp}.tests/fl/channels/clockless_controller_runtime.hpp.Touching ~30 files per phase × 5 phases × keeping the cross-platform compile matrix green is the work, not the design.
Reproduction status
Baseline reproduction works:
Expected hot symbol:
fl::Channel::showPixels<PixelController<EOrder, lanes, mask>>(~5.6 KB single-instance, scales linearly with distinct (chipset × order) combinations). Issue body documents this from prior audit.Planned fix — recommended ordering for whoever picks this up
ClocklessControllerRuntimeskeleton with the gateFL_USE_RUNTIME_CLOCKLESS=0by default, host-side unit tests, and zero changes to the existing template path. This is a low-risk infrastructure-only PR that creates the seam.to_runtime_timing<TIMING>()and theFastLED.addLeds<>forwarders behind the same off-by-default gate. Cross-platform compile matrix is the verification.bash profile <function>per project tooling) on a single-chipset sketch. Acceptance requires showing the indirect-call overhead is below the WS2812 per-pixel budget.Each phase is its own merge-able PR and each verifies independently.
Open questions for the next agent or maintainer
/clud-fix(or a human) iterate through them.#if-guarded chipsets; whether the compiler sees them all in a single build is the actual question.FL_USE_RUNTIME_CLOCKLESSflag name acceptable, or should it use the existingFL_PLATFORM_HAS_LARGE_MEMORYfamily? Acceptance bullet says "or similar" — clarification needed before Phase A.What I'm NOT doing in this pass
Meta loop state
Continuing the #3244 meta loop on the easier sub-issues this iteration. #3248 stays open as-is for a focused multi-PR followup.
Refs #3244, #3235.
zackees commentedon Aug 20, 2026
Deferred under the active bug-burn-down policy after re-validating the implementation surface against current
master.Current evidence:
src/fl/chipsets/led_timing.hstill providesto_runtime_timing<TIMING>(), but the tree contains noClocklessControllerRuntimeimplementation and noFL_USE_RUNTIME_CLOCKLESSintegration gate.This is therefore a genuine multi-PR architecture and hardware-benchmark program, not a bounded bug-fix PR. The issue remains open and is excluded from the actionable burn-down until the
deferredlabel is deliberately removed.Restart criteria:
deferredonly when those prerequisites are available.