6 {
7
8 uint8_t r, g, b;
9
10
11
12
13
14
15
16
17
18 hue = (
hue * 1530L + 32768) / 65536;
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42 b = 0;
44 r = 255;
46 } else {
48 g = 255;
49 }
50 }
else if (
hue < 1020) {
51 r = 0;
53 g = 255;
55 } else {
57 b = 255;
58 }
59 }
else if (
hue < 1530) {
60 g = 0;
63 b = 255;
64 } else {
65 r = 255;
67 }
68 } else {
69 r = 255;
70 g = b = 0;
71 }
72
73
74 uint32_t v1 = 1 + val;
75 uint16_t s1 = 1 + sat;
76 uint8_t s2 = 255 - sat;
77 return ((((((r * s1) >> 8) + s2) * v1) & 0xff00) << 8) |
78 (((((g * s1) >> 8) + s2) * v1) & 0xff00) |
79 (((((b * s1) >> 8) + s2) * v1) >> 8);
80}