FastLED 3.10.6
Loading...
Searching...
No Matches

◆ controller_dither_reserve_mW()

fl::u32 controller_dither_reserve_mW ( const fl::CLEDController & controller)

dither_reserve_mW() for a controller that dithers, and zero for one that does not: a mode other than BINARY_DITHER, or an active RGBW/RGBWW conversion (which reads the raw pixel on every non-AVR target).

A colour-managed channel never takes the legacy offsets (C5); with BINARY_DITHER it runs the pipeline's temporal dither instead, and is reserved one code on every channel of every lit pixel.

On the TINY memory tier (FL_PLATFORM_HAS_TINY_MEMORY) both of these are compiled out and the reserve is zero: the 64-bit arithmetic the bound needs costs 468 B of an ATtiny85's 8 KiB, which is what pushed TwinkleFox over the flash region (#4478). Every tier that can afford it keeps the reserve.

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

507 {
508 if (controller.getDither() != BINARY_DITHER) {
509 return 0;
510 }
511#if FL_COLOR_PIPELINE_SHARED
512 // A managed channel never takes the legacy offsets (C5); with
513 // BINARY_DITHER it runs the pipeline's temporal dither instead, which
514 // emits floor(x) or floor(x) + 1 of the exact code -- at most one code
515 // above the rounded code its estimate charges. The solve can light a
516 // channel the source left dark, so every channel of every lit pixel is
517 // reserved one code.
518 if (controller.colorPipeline()) {
520 static_cast<fl::size>(controller.size()));
521 fl::u32 lit = 0;
522 for (fl::size i = 0; i < leds.size(); ++i) {
523 lit += (leds[i].r | leds[i].g | leds[i].b) != 0 ? 1u : 0u;
524 }
525 const fl::u8 emitters = controller.getRgbww().active()
526 ? 5 : (controller.getRgbw().active() ? 4 : 3);
527 fl::u8 weights[5];
528 emitter_power_weights(emitters, weights);
529 fl::u32 sum_weights = 0;
530 for (fl::u8 i = 0; i < emitters; ++i) {
531 sum_weights += weights[i];
532 }
533 const fl::u64 per_code = static_cast<fl::u64>(lit) * sum_weights;
534 const fl::u64 reserve = (per_code * max_power_step() + 255) >> 8;
535 return reserve > 0xFFFFFFFFu ? 0xFFFFFFFFu
536 : static_cast<fl::u32>(reserve);
537 }
538#endif
539#if !defined(FL_IS_AVR)
540 // Legacy RGBW and RGBWW conversions read the raw pixel, not the
541 // dithered one. Managed channels have already returned above.
542 if (controller.getRgbw().active() || controller.getRgbww().active()) {
543 return 0;
544 }
545#endif
547 controller.leds(), static_cast<fl::size>(controller.size())));
548}
CRGB leds[1]
CLEDController * controller
#define BINARY_DITHER
Enable dithering using binary dithering (only option)
Definition dither_mode.h:16
fl::u32 dither_reserve_mW(fl::span< const CRGB > leds)
The most BINARY_DITHER can add to one latched frame of leds, in mW (#4342, contract R4: "quantization...
unsigned char u8
Definition stdint.h:131
static fl::u8 max_power_step()
What one output code can cost at the steepest point of the response, in the 0-255 scaled units calcul...
static void emitter_power_weights(fl::u8 count, fl::u8(&weights)[5])

References BINARY_DITHER, controller, dither_reserve_mW(), emitter_power_weights(), leds, and max_power_step().

Referenced by calculate_max_brightness_for_power_mW(), and CFastLED::getEstimatedPowerInMilliWatts().

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