436 {
437 const fl::u32 requested_mW =
439 if (requested_mW <= max_power_mW) {
440 return target_brightness;
441 }
442 if (controllable_mW == 0) {
443
444
445 return 0;
446 }
447 if (max_power_mW <= fixed_mW) {
448
449
450
451
453 << " mW is at or under the " << fixed_mW
454 << " mW baseline (MCU + LED dark current); LEDs blanked."
455 << " Raise the budget or set FL_MCU_POWER_MW.");
456 return 0;
457 }
458
459
460
461
462
463
464
465
466
467
468
469
470 const fl::u32 headroom_mW = max_power_mW - fixed_mW;
473 if (allowed_scaled > target_scaled) {
474 allowed_scaled = target_scaled;
475 }
476 const fl::u32 recommended_scaled = static_cast<fl::u32>(allowed_scaled);
478
479
480
481
482
483
484
485
486
487
488
489 while (recommended > 0 &&
491 max_power_mW) {
492 --recommended;
493 }
494 return recommended;
495}
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 power_ratio_of_255(fl::u32 num, fl::u32 den) FL_NO_EXCEPT
min(255, floor(255 * num / den)) for den > 0, computed in 32-bit arithmetic.
#define FL_WARN_EVERY(MILLIS,...)
static fl::u8 map_power_value(fl::u8 brightness) FL_NO_EXCEPT
static fl::u8 unmap_power_value(fl::u8 scaled_brightness) FL_NO_EXCEPT