FastLED 3.10.10
Loading...
Searching...
No Matches

◆ calculate_unscaled_emitter_power_mW()

fl::u32 calculate_unscaled_emitter_power_mW ( fl::span< const fl::u8 > codes,
fl::u8 emitter_count )

Charge already-solved physical output bytes in source emitter order: RGB, RGBW, or RGB + warm white + cool white.

Used by the managed pipeline's power hook; it must not apply legacy RGB-to-RGBW conversion a second time.

Definition at line 293 of file power_mgt.cpp.hpp.

294 {
295 if (emitter_count < 3 || emitter_count > 5 ||
296 codes.size() % emitter_count != 0) {
297 return 0;
298 }
299 fl::u8 weights[5];
300 emitter_power_weights(emitter_count, weights);
301 fl::u32 sums[5] = {};
302 for (fl::size i = 0; i < codes.size(); i += emitter_count) {
303 for (fl::u8 channel = 0; channel < emitter_count; ++channel) {
304 sums[channel] += map_power_value(codes[i + channel]);
305 }
306 }
307 fl::u32 total = static_cast<fl::u32>(gPowerModel().dark_mW) *
308 (codes.size() / emitter_count);
309 for (fl::u8 channel = 0; channel < emitter_count; ++channel) {
310 total += (sums[channel] * weights[channel]) >> 8;
311 }
312 return total;
313}
constexpr fl::size size() const FL_NO_EXCEPT
Definition span.h:483
unsigned char u8
Definition stdint.h:132
static PowerModelRGB & gPowerModel() FL_NO_EXCEPT
Global RGB power model (initialized to WS2812 @ 5V defaults, linear response)
static void emitter_power_weights(fl::u8 count, fl::u8(&weights)[5]) FL_NO_EXCEPT
static fl::u8 map_power_value(fl::u8 brightness) FL_NO_EXCEPT
fl::u8 dark_mW
Dark (all channels off) draw per LED IC, in milliwatts, charged as an undimmable baseline.
Definition power_mgt.h:41

References PowerModelRGB::dark_mW, emitter_power_weights(), FL_NO_EXCEPT, gPowerModel(), and map_power_value().

Referenced by controller_unscaled_power_mW().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: