20 static const uint8_t cie1931[101] =
22 0, 0, 1, 1, 1, 1, 2, 2, 2, 3,
23 3, 3, 4, 4, 4, 5, 5, 6, 6, 7,
24 8, 8, 9, 10, 10, 11, 12, 13, 14, 15,
25 16, 17, 18, 19, 20, 22, 23, 24, 26, 27,
26 29, 30, 32, 34, 35, 37, 39, 41, 43, 45,
27 47, 49, 51, 54, 56, 58, 61, 64, 66, 69,
28 72, 75, 78, 81, 84, 87, 90, 93, 97, 100,
29 104, 108, 111, 115, 119, 123, 127, 131, 136, 140,
30 145, 149, 154, 159, 163, 168, 173, 179, 184, 189,
31 195, 200, 206, 212, 217, 223, 230, 236, 242, 248,
35 #if LIGHTNESS_PWM_STEP != 255
36 #error this cie1931 array supports only 255 steps, feel free to implement your own
41 percentage = min(percentage,
ARRAY_SIZE(cie1931) - 1);
43 return cie1931[percentage];
Handle non-linearity in human eye brightness sensitivity.
uint8_t lightness_to_pwm(uint8_t percentage)
PWM value for driving a LED expressed as perceived percentage.
#define ARRAY_SIZE(x)
Number of elements in the array.