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.
918 {
919
920
922 fl::u32 controllable_mW = 0;
923
925 while(pCur) {
926 const fl::u32 count = pCur->
size();
927
928
931
932
934 controllable_mW += unscaled_mW > dark_mW ? unscaled_mW - dark_mW : 0;
936 }
937
938#if POWER_DEBUG_PRINT == 1
939 Serial.print(
"power demand at full brightness mW = ");
940 Serial.println( fixed_mW + controllable_mW);
941#endif
942
943 const fl::u32 requested_power_mW =
945#if POWER_DEBUG_PRINT == 1
946 if( target_brightness != 255 ) {
947 Serial.print(
"power demand at scaled brightness mW = ");
948 Serial.println( requested_power_mW);
949 }
950 Serial.print(
"power limit mW = ");
951 Serial.println( max_power_mW);
952#endif
953
954 if( requested_power_mW <= max_power_mW) {
955#if POWER_LED > 0
958 }
959#endif
960#if POWER_DEBUG_PRINT == 1
961 Serial.print(
"demand is under the limit");
962#endif
963 return target_brightness;
964 }
965
967 fixed_mW, controllable_mW, target_brightness, max_power_mW);
968#if POWER_DEBUG_PRINT == 1
969 Serial.print(
"recommended brightness # = ");
970 Serial.println( recommended_brightness);
971
972 fl::u32 resultant_power_mW =
974 Serial.print(
"resultant power demand mW = ");
975 Serial.println( resultant_power_mW);
976
978#endif
979
980#if POWER_LED > 0
983 }
984#endif
985
986 return recommended_brightness;
987}
static CLEDController * head() FL_NO_EXCEPT
Get the first LED controller in the linked list of controllers.
VIRTUAL_IF_NOT_AVR int size() const FL_NO_EXCEPT
How many LEDs does this controller manage?
CLEDController * next() FL_NO_EXCEPT
Get the next controller in the linked list after this one.
fl::CLEDController CLEDController
fl::u32 scale_power_for_brightness(fl::u32 total_mW, fl::u8 brightness) FL_NO_EXCEPT
Applies the configured power-scaling response to a total power value.
fl::u32 controller_dither_reserve_mW(const fl::CLEDController &controller) FL_NO_EXCEPT
dither_reserve_mW() for a controller that dithers, and zero for one that does not: a mode other than ...
fl::u32 controller_unscaled_power_mW(const fl::CLEDController &controller) FL_NO_EXCEPT
One controller's demand at full brightness, in mW, including idle draw – the quantity the limiter sum...
static fl::u8 gMaxPowerIndicatorLEDPinNumber
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