Same, for a strip driven through the RGBW conversion.
The overloads above read the source CRGB triple, which is what the sketch wrote – not what the strip is driven with. A controller in RGBW mode converts every pixel with rgb_2_rgbw before latching, and the resulting four drives are neither bounded by nor proportional to the source triple. Measured on the shipped default PowerModelRGBW at full white, in units of the sum below: source-triple 249 against a true 348 under kRGBWMaxBrightness, 266 under kRGBWBoostedWhite, 99 under kRGBWExactColors. The first two are the budget being under-spent against; the third is a strip dimmed for no reason.
This runs the same conversion the encoder will and charges all four emitters. It needs white_mW, so it falls back to the three-emitter figure – and says so once – when the caller declared only an RGB model.
- Parameters
-
| leds | span of LED data to check |
| rgbw | the controller's RGBW setting; an inactive one delegates to the three-emitter overload |
Definition at line 317 of file power_mgt.cpp.hpp.
317 {
319
320
321
322
323
324
325
326
327
328 if (!
rgbw.active() || white_mW == 0) {
330 FL_WARN_ONCE(
"power: controller is in RGBW mode but the power model "
331 "declares no white emitter, so the budget covers three "
332 "of its four diodes. Call "
333 "FastLED.setPowerModel(PowerModelRGBW(...)) to fix it.");
334 }
336 }
337
338 fl::u32 red32 = 0, green32 = 0, blue32 = 0, white32 = 0;
339 for (fl::size i = 0; i <
leds.size(); i++) {
340 fl::u8 r = 0,
g = 0, b = 0, w = 0;
342 &r, &g, &b, &w);
347 }
348
352 white32 *= white_mW;
353
354 red32 >>= 8;
355 green32 >>= 8;
356 blue32 >>= 8;
357 white32 >>= 8;
358
359 return red32 + green32 + blue32 + white32 +
361}
fl::u32 calculate_unscaled_power_mW(fl::span< const CRGB > leds) FL_NO_EXCEPT
Determines how many milliwatts the current LED data would draw at max brightness (255)
#define FL_WARN_ONCE(...)
FASTLED_FORCE_INLINE void rgb_2_rgbw(const Rgbw &cfg, u8 r, u8 g, u8 b, u8 r_scale, u8 g_scale, u8 b_scale, u8 *out_r, u8 *out_g, u8 *out_b, u8 *out_w) FL_NO_EXCEPT
Converts RGB to RGBW using one of the functions.
static PowerModelRGB & gPowerModel() FL_NO_EXCEPT
Global RGB power model (initialized to WS2812 @ 5V defaults, linear response)
static fl::u8 map_power_value(fl::u8 brightness) FL_NO_EXCEPT
static WhiteEmitterPower & gWhiteEmitterPower() FL_NO_EXCEPT
fl::u8 blue_mW
Blue channel power at full brightness (255), in milliwatts.
fl::u8 dark_mW
Dark LED baseline power consumption, in milliwatts.
fl::u8 red_mW
Red channel power at full brightness (255), in milliwatts.
fl::u8 green_mW
Green channel power at full brightness (255), in milliwatts.
References PowerModelRGB::blue_mW, calculate_unscaled_power_mW(), PowerModelRGB::dark_mW, FL_NO_EXCEPT, FL_WARN_ONCE, gPowerModel(), PowerModelRGB::green_mW, gWhiteEmitterPower(), leds, map_power_value(), WhiteEmitterPower::mW, PowerModelRGB::red_mW, fl::rgb_2_rgbw(), and rgbw.