Determines the highest brightness level you can use and still stay under the specified power budget for all sets of LEDs.
Unlike the other internal power functions which use a pointer to a specific set of LED data, this function uses the CFastLED linked list of LED controllers and their attached data.
211{
213
215 while(pCur) {
218 }
219
220#if POWER_DEBUG_PRINT == 1
221 Serial.print(
"power demand at full brightness mW = ");
222 Serial.println( total_mW);
223#endif
224
227#if POWER_DEBUG_PRINT == 1
228 if( target_brightness != 255 ) {
229 Serial.print(
"power demand at scaled brightness mW = ");
230 Serial.println( requested_power_mW);
231 }
232 Serial.print(
"power limit mW = ");
233 Serial.println( max_power_mW);
234#endif
235
236 if( requested_power_mW < max_power_mW) {
237#if POWER_LED > 0
240 }
241#endif
242#if POWER_DEBUG_PRINT == 1
243 Serial.print(
"demand is under the limit");
244#endif
245 return target_brightness;
246 }
247
248 fl::u8 recommended_scaled = (fl::u32)(target_brightness_scaled * (fl::u32)(max_power_mW)) / ((fl::u32)(requested_power_mW));
250#if POWER_DEBUG_PRINT == 1
251 Serial.print(
"recommended brightness # = ");
252 Serial.println( recommended_brightness);
253
255 Serial.print(
"resultant power demand mW = ");
256 Serial.println( resultant_power_mW);
257
259#endif
260
261#if POWER_LED > 0
264 }
265#endif
266
267 return recommended_brightness;
268}
CLEDController * next() FL_NOEXCEPT
Get the next controller in the linked list after this one.
CRGB * leds() FL_NOEXCEPT
Pointer to the CRGB array for this controller.
virtual int size() const FL_NOEXCEPT
How many LEDs does this controller manage?
static CLEDController * head() FL_NOEXCEPT
Get the first LED controller in the linked list of controllers.
fl::CLEDController CLEDController
fl::u32 scale_power_for_brightness(fl::u32 total_mW, fl::u8 brightness)
Applies the configured power-scaling response to a total power value.
fl::u32 calculate_unscaled_power_mW(fl::span< const CRGB > leds)
static fl::u8 unmap_power_value(fl::u8 scaled_brightness)
static fl::u8 gMaxPowerIndicatorLEDPinNumber
static fl::u8 map_power_value(fl::u8 brightness)
static const fl::u8 gMCU_mW