FastLED 3.10.6
Loading...
Searching...
No Matches

◆ applyBrightnessCompression()

uint8_t applyBrightnessCompression ( float inputBrightnessPercent,
uint8_t maxBrightness,
float lowThreshold,
float highThreshold )

Definition at line 20 of file auto_brightness.cpp.

22 {
23 float maxBrightnessPercent = (maxBrightness / 255.0f) * 100.0f;
24 if (inputBrightnessPercent < lowThreshold) {
25 return 255;
26 } else if (inputBrightnessPercent < highThreshold) {
27 float range = highThreshold - lowThreshold;
28 float progress = (inputBrightnessPercent - lowThreshold) / range;
29 float targetPercent =
30 100.0f - (progress * (100.0f - maxBrightnessPercent));
31 return static_cast<uint8_t>((targetPercent / 100.0f) * 255.0f);
32 } else {
33 return maxBrightness;
34 }
35}
unsigned char uint8_t
Definition stdint.h:208

Referenced by loop().

+ Here is the caller graph for this function: