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.
881 {
882
883
885 fl::u32 controllable_mW = 0;
886
888 while(pCur) {
889 const fl::u32 count = pCur->
size();
890
891
894
895
897 controllable_mW += unscaled_mW > dark_mW ? unscaled_mW - dark_mW : 0;
899 }
900
901#if POWER_DEBUG_PRINT == 1
902 Serial.print(
"power demand at full brightness mW = ");
903 Serial.println( fixed_mW + controllable_mW);
904#endif
905
906 const fl::u32 requested_power_mW =
908#if POWER_DEBUG_PRINT == 1
909 if( target_brightness != 255 ) {
910 Serial.print(
"power demand at scaled brightness mW = ");
911 Serial.println( requested_power_mW);
912 }
913 Serial.print(
"power limit mW = ");
914 Serial.println( max_power_mW);
915#endif
916
917 if( requested_power_mW <= max_power_mW) {
918#if POWER_LED > 0
921 }
922#endif
923#if POWER_DEBUG_PRINT == 1
924 Serial.print(
"demand is under the limit");
925#endif
926 return target_brightness;
927 }
928
930 fixed_mW, controllable_mW, target_brightness, max_power_mW);
931#if POWER_DEBUG_PRINT == 1
932 Serial.print(
"recommended brightness # = ");
933 Serial.println( recommended_brightness);
934
935 fl::u32 resultant_power_mW =
937 Serial.print(
"resultant power demand mW = ");
938 Serial.println( resultant_power_mW);
939
941#endif
942
943#if POWER_LED > 0
946 }
947#endif
948
949 return recommended_brightness;
950}
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
static const fl::u8 gMCU_mW