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

570 {
571 if (controller.getDither() != BINARY_DITHER) {
572 return 0;
573 }
574#if FL_COLOR_PIPELINE_SHARED
575 // A managed channel never takes the legacy offsets (C5); with
576 // BINARY_DITHER it runs the pipeline's temporal dither instead, which
577 // emits floor(x) or floor(x) + 1 of the exact code -- at most one code
578 // above the rounded code its estimate charges. The solve can light a
579 // channel the source left dark, so every channel of every lit pixel is
580 // reserved one code.
581 if (fl::channelColorPipeline(controller)) {
583 static_cast<fl::size>(controller.size()));
584 fl::u32 lit = 0;
585 for (fl::size i = 0; i < leds.size(); ++i) {
586 lit += (leds[i].r | leds[i].g | leds[i].b) != 0 ? 1u : 0u;
587 }
588 const fl::u8 emitters = controller.getRgbww().active()
589 ? 5 : (controller.getRgbw().active() ? 4 : 3);
590 fl::u8 weights[5];
591 emitter_power_weights(emitters, weights);
592 fl::u32 sum_weights = 0;
593 for (fl::u8 i = 0; i < emitters; ++i) {
594 sum_weights += weights[i];
595 }
596 const fl::u64 per_code = static_cast<fl::u64>(lit) * sum_weights;
597 const fl::u64 reserve = (per_code * max_power_step() + 255) >> 8;
598 return reserve > 0xFFFFFFFFu ? 0xFFFFFFFFu
599 : static_cast<fl::u32>(reserve);
600 }
601#endif
602#if !defined(FL_IS_AVR)
603 // Legacy RGBW and RGBWW conversions read the raw pixel, not the
604 // dithered one. Managed channels have already returned above.
605 if (controller.getRgbw().active() || controller.getRgbww().active()) {
606 return 0;
607 }
608#endif
610 controller.leds(), static_cast<fl::size>(controller.size())));
611}
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) FL_NO_EXCEPT
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() FL_NO_EXCEPT
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]) FL_NO_EXCEPT

References BINARY_DITHER, controller, dither_reserve_mW(), emitter_power_weights(), FL_NO_EXCEPT, 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: