FastLED 3.10.8
Loading...
Searching...
No Matches

◆ toRGB()

PowerModelRGB PowerModelRGBWW::toRGB ( ) const
inlineconstexpr

Convert to RGB model (folds W/WW power back into RGB so the brightness limiter doesn't under-budget).

Issue #2558 update: the white-channel mW values are no longer dropped. They're distributed evenly across the three RGB channels, which:

  • matches the brightness limiter's assumption that each RGB byte has a fixed mW cost at full drive (the limiter caps total predicted mW against a budget),
  • over-estimates rather than under-estimates when only white channels are on (safer for power-limited supplies),
  • accepts that a fully RGBWW-aware brightness limiter (per-channel accounting using all 5 mW values directly) is the right long-term fix — see Phase G in issue #2558.

Definition at line 142 of file power_mgt.h.

142 {
143 // Distribute white-channel mW evenly across R/G/B. Clamp to 255 (u8
144 // max) on overflow — a wrapping static_cast<u8> here would make the
145 // brightness limiter *less* conservative on the highest-draw configs
146 // (where it most needs to be conservative). The worst-case
147 // under-budget per channel from the floor division is 2 mW.
148 return PowerModelRGB(
149 static_cast<fl::u8>(
150 (red_mW + (white_mW + warm_white_mW) / 3) > 255
151 ? 255 : (red_mW + (white_mW + warm_white_mW) / 3)),
152 static_cast<fl::u8>(
153 (green_mW + (white_mW + warm_white_mW) / 3) > 255
154 ? 255 : (green_mW + (white_mW + warm_white_mW) / 3)),
155 static_cast<fl::u8>(
156 (blue_mW + (white_mW + warm_white_mW) / 3) > 255
157 ? 255 : (blue_mW + (white_mW + warm_white_mW) / 3)),
158 dark_mW,
159 exponent);
160 }
unsigned char u8
Definition stdint.h:131
fl::u8 white_mW
Cool white channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:103
float exponent
Brightness-to-power response exponent (1.0 = linear)
Definition power_mgt.h:106
fl::u8 green_mW
Green channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:101
fl::u8 warm_white_mW
Warm white channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:104
fl::u8 red_mW
Red channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:100
fl::u8 blue_mW
Blue channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:102
fl::u8 dark_mW
Dark LED baseline power consumption, in milliwatts.
Definition power_mgt.h:105

References blue_mW, dark_mW, exponent, FL_NO_EXCEPT, green_mW, red_mW, warm_white_mW, and white_mW.