FastLED 3.9.15
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 134 of file power_mgt.h.

134 {
135 // Distribute white-channel mW evenly across R/G/B. Clamp to 255 (u8
136 // max) on overflow — a wrapping static_cast<u8> here would make the
137 // brightness limiter *less* conservative on the highest-draw configs
138 // (where it most needs to be conservative). The worst-case
139 // under-budget per channel from the floor division is 2 mW.
140 return PowerModelRGB(
141 static_cast<fl::u8>(
142 (red_mW + (white_mW + warm_white_mW) / 3) > 255
143 ? 255 : (red_mW + (white_mW + warm_white_mW) / 3)),
144 static_cast<fl::u8>(
145 (green_mW + (white_mW + warm_white_mW) / 3) > 255
146 ? 255 : (green_mW + (white_mW + warm_white_mW) / 3)),
147 static_cast<fl::u8>(
148 (blue_mW + (white_mW + warm_white_mW) / 3) > 255
149 ? 255 : (blue_mW + (white_mW + warm_white_mW) / 3)),
150 dark_mW,
151 exponent);
152 }
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:95
float exponent
Brightness-to-power response exponent (1.0 = linear)
Definition power_mgt.h:98
fl::u8 green_mW
Green channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:93
fl::u8 warm_white_mW
Warm white channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:96
fl::u8 red_mW
Red channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:92
fl::u8 blue_mW
Blue channel power at full brightness (255), in milliwatts.
Definition power_mgt.h:94
fl::u8 dark_mW
Dark LED baseline power consumption, in milliwatts.
Definition power_mgt.h:97

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

Referenced by set_power_model().

+ Here is the caller graph for this function: