FastLED 3.10.10
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 149 of file power_mgt.h.

149 {
150 // Distribute white-channel mW evenly across R/G/B. Clamp to 255 (u8
151 // max) on overflow — a wrapping static_cast<u8> here would make the
152 // brightness limiter *less* conservative on the highest-draw configs
153 // (where it most needs to be conservative). The worst-case
154 // under-budget per channel from the floor division is 2 mW.
155 return PowerModelRGB(
156 static_cast<fl::u8>(
157 (red_mW + (white_mW + warm_white_mW) / 3) > 255
158 ? 255 : (red_mW + (white_mW + warm_white_mW) / 3)),
159 static_cast<fl::u8>(
160 (green_mW + (white_mW + warm_white_mW) / 3) > 255
161 ? 255 : (green_mW + (white_mW + warm_white_mW) / 3)),
162 static_cast<fl::u8>(
163 (blue_mW + (white_mW + warm_white_mW) / 3) > 255
164 ? 255 : (blue_mW + (white_mW + warm_white_mW) / 3)),
165 dark_mW,
166 exponent);
167 }
unsigned char u8
Definition stdint.h:132
fl::u8 white_mW
Cool white channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:110
float exponent
Brightness-to-power response exponent (1.0 = linear)
Definition power_mgt.h:113
fl::u8 green_mW
Green channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:108
fl::u8 warm_white_mW
Warm white channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:111
fl::u8 red_mW
Red channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:107
fl::u8 blue_mW
Blue channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:109
fl::u8 dark_mW
Dark LED baseline power consumption, in milliwatts.
Definition power_mgt.h:112

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