You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
api(rgbw): encapsulate Rgbw/Rgbww activation so the RGBW encoder can be link-on-use (prereq for #4795) #4815
Prerequisite for #4795 (about 2 KB of RGBW/RGBWW code linked into every RGB-only ESP32 sketch). Split out from #4801 because it is a public API change.
Problem
RGBW can't be link-on-use today because there is no single point where it becomes active:
A default-constructed fl::Rgbw is active (RGBW_MODE::kRGBWExactColors), and RgbwInvalid derives from Rgbw.
rgbw_mode (and the Rgbww equivalent) is a public field, so RGBW can be switched on by assignment.
Activation also arrives through Channel options and LegacySettings, not only CLEDController::setRgbw().
As a result PixelIterator takes the address of the per-type RGBW/RGBWW thunks for every source type, and writeWS2812() keeps ScaledPixelIteratorRGBW(W)::advance, rgb_2_rgbw_* and rgbw(w)_partial_reorder reachable.
Measured on master 50c99f0210, esp32dev Blink:
loadAndScaleRGBW 296 B, loadAndScaleRGBWW 219 B;
ScaledPixelIteratorRGBW(W)::advance 175 / 219 B;
rgb_2_rgbw_* modes and the reorder helpers.
The total is about 2.0 KB.
Proposal
Encapsulate activation: make the mode private behind a setter/getter. Keep a deprecated compatibility path for one release, since user code may assign rgbw_mode directly.
Thinner per-type code: replace the per-type RGBW/RGBWW thunks with one small "raw pixel + premixed scale" thunk, and do the conversion plus reorder in the type-erased layer.
Acceptance
Byte-exact golden tests across all colour orders, W placements and RGBW modes, before and after.
RGB-only esp32dev/esp32s3 Blink drops about 2 KB flash; RGBW examples are unchanged.
The migration note covers direct rgbw_mode assignment.
Resolved by #4819 without the public API change this issue proposed. Active Rgbw/Rgbww constructors, plus setRgbw()/setRgbww() and Channel::syncLegacySettings(), install the type-erased conversion. The inactive sentinels use a non-hooking tag constructor. rgbw_mode stays public; the one remaining hole (an active value made by assigning rgbw_mode and placed in a variant without any of those entry points) takes the inactive fallback, as noted in #4819.
Activity
perf(rgbw): type-erased, link-on-use RGBW/RGBWW in PixelIterator (~1 …
zackees commentedon Oct 9, 2026
Resolved by #4819 without the public API change this issue proposed. Active
Rgbw/Rgbwwconstructors, plussetRgbw()/setRgbww()andChannel::syncLegacySettings(), install the type-erased conversion. The inactive sentinels use a non-hooking tag constructor.rgbw_modestays public; the one remaining hole (an active value made by assigningrgbw_modeand placed in a variant without any of those entry points) takes the inactive fallback, as noted in #4819.