FastLED 3.10.8
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 271 of file power_mgt.cpp.hpp.

272 {
273 if (emitter_count < 3 || emitter_count > 5 ||
274 codes.size() % emitter_count != 0) {
275 return 0;
276 }
277 fl::u8 weights[5];
278 emitter_power_weights(emitter_count, weights);
279 fl::u32 sums[5] = {};
280 for (fl::size i = 0; i < codes.size(); i += emitter_count) {
281 for (fl::u8 channel = 0; channel < emitter_count; ++channel) {
282 sums[channel] += map_power_value(codes[i + channel]);
283 }
284 }
285 fl::u32 total = static_cast<fl::u32>(gPowerModel().dark_mW) *
286 (codes.size() / emitter_count);
287 for (fl::u8 channel = 0; channel < emitter_count; ++channel) {
288 total += (sums[channel] * weights[channel]) >> 8;
289 }
290 return total;
291}
constexpr fl::size size() const FL_NO_EXCEPT
Definition span.h:483
unsigned char u8
Definition stdint.h:131
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 LED baseline power consumption, in milliwatts.
Definition power_mgt.h:34

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: