FastLED 3.9.15
Loading...
Searching...
No Matches

◆ calculate_max_brightness_for_power_mW() [1/2]

uint8_t calculate_max_brightness_for_power_mW ( const CRGB * ledbuffer,
uint16_t numLeds,
uint8_t target_brightness,
uint32_t 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.

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.

Definition at line 95 of file power_mgt.cpp.

95 {
96 uint32_t total_mW = calculate_unscaled_power_mW( ledbuffer, numLeds);
97
98 uint32_t requested_power_mW = ((uint32_t)total_mW * target_brightness) / 256;
99
100 uint8_t recommended_brightness = target_brightness;
101 if(requested_power_mW > max_power_mW) {
102 recommended_brightness = (uint32_t)((uint8_t)(target_brightness) * (uint32_t)(max_power_mW)) / ((uint32_t)(requested_power_mW));
103 }
104
105 return recommended_brightness;
106}
uint32_t calculate_unscaled_power_mW(const CRGB *ledbuffer, uint16_t numLeds)
Determines how many milliwatts the current LED data would draw at max brightness (255)
Definition power_mgt.cpp:61

References calculate_unscaled_power_mW().

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: