FastLED 3.10.8
Loading...
Searching...
No Matches

◆ calculate_max_brightness_for_power_mW() [1/2]

fl::u8 calculate_max_brightness_for_power_mW ( const CRGB * ledbuffer,
fl::u16 numLeds,
fl::u8 target_brightness,
fl::u32 max_power_mW )

Determines the highest brightness level you can use and still stay under the specified power budget for a given set of LEDs.

What the budget bounds, stated rather than implied (#4156 R4):

  • The baseline is not scalable. PowerModel::dark_mW is drawn per LED at every brightness including zero, so it is subtracted from the budget first and only the remainder is divided among the emitters. A budget at or below the baseline returns 0: no brightness meets it, and a lit strip would be promising a bound that cannot be held at any setting.
  • The bound is on the pre-dither frame. Demand is computed from the CRGB values, and BINARY_DITHER adds its offset afterwards, inside the encoder. That offset is shared across the frame, so a dithered frame can exceed the budgeted demand by up to one native code per channel per pixel – about 0.8 mW per LED on the default WS2812 model. The multi-frame mean is what the budget holds; a single latched frame can sit that much above it.
Parameters
ledbufferthe LED data to check
numLedsthe number of LEDs in the data array
target_brightnessthe brightness you'd ideally like to use
max_power_mWthe max power draw desired, in milliwatts
Returns
a limited brightness value. No higher than the target brightness, but may be lower depending on the power limit. Zero when the budget is at or below the unscalable baseline.

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

464 {
465 const fl::u32 total_mW = calculate_unscaled_power_mW( ledbuffer, numLeds);
466 const fl::u32 fixed_mW = fixed_power_mW(numLeds);
467 const fl::u32 controllable_mW = total_mW > fixed_mW ? total_mW - fixed_mW : 0;
468
469 return brightness_within_budget(fixed_mW, controllable_mW, target_brightness,
470 max_power_mW);
471}
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)
static fl::u32 fixed_power_mW(fl::u32 led_count) FL_NO_EXCEPT
static fl::u8 brightness_within_budget(fl::u32 fixed_mW, fl::u32 controllable_mW, fl::u8 target_brightness, fl::u32 max_power_mW) FL_NO_EXCEPT

References brightness_within_budget(), calculate_unscaled_power_mW(), fixed_power_mW(), and FL_NO_EXCEPT.

Referenced by calculate_max_brightness_for_power_vmA(), and CFastLED::setMaxPowerInMilliWatts().

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