-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgamma.ino
executable file
·73 lines (67 loc) · 5.45 KB
/
gamma.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Gamma correction for the LED brightnesses.
const uint32_t gamma[] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,
4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9,
9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16,
16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 23, 23, 24, 24,
25, 26, 26, 27, 28, 28, 29, 30, 30, 31, 32, 32, 33, 34, 35, 35,
36, 37, 38, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 97, 98, 99,
100, 102, 103, 104, 105, 107, 108, 109, 111, 112, 113, 115, 116, 117, 119, 120,
121, 123, 124, 126, 127, 128, 130, 131, 133, 134, 136, 137, 139, 140, 142, 143,
145, 146, 148, 149, 151, 152, 154, 155, 157, 158, 160, 162, 163, 165, 166, 168,
170, 171, 173, 175, 176, 178, 180, 181, 183, 185, 186, 188, 190, 192, 193, 195,
197, 199, 200, 202, 204, 206, 207, 209, 211, 213, 215, 217, 218, 220, 222, 224,
226, 228, 230, 232, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255
};
uint32_t doGamma(uint32_t pwm) {
// uint32_t gammaVal = pgm_read_byte(&gamma[pwm]);
return doGamma(pwm, pwm, pwm);
// return pwm << 16 | pwm << 8 | pwm;
}
uint32_t doGamma(uint32_t r, uint32_t g, uint32_t b) {
uint32_t gammaR = pgm_read_byte(&gamma[r]);
uint32_t gammaG = pgm_read_byte(&gamma[g]);
uint32_t gammaB = pgm_read_byte(&gamma[b]);
return gammaR << 16 | gammaG << 8 | gammaB;
}
const uint32_t chasing[256][3] PROGMEM = {
{168, 0, 0}, {168, 0, 0}, {168, 0, 0}, {168, 0, 0}, {168, 0, 0}, {168, 0, 0}, {168, 0, 0}, {168, 0, 0},
{168, 0, 0}, {168, 0, 0}, {168, 0, 0}, {168, 0, 0}, {168, 0, 0}, {168, 0, 0}, {168, 0, 0}, {168, 0, 0},
{168, 0, 0}, {166, 0, 0}, {163, 0, 0}, {161, 0, 0}, {158, 0, 0}, {156, 0, 0}, {154, 0, 0}, {151, 0, 0},
{149, 0, 0}, {147, 0, 0}, {145, 0, 0}, {143, 0, 0}, {140, 0, 0}, {138, 0, 0}, {136, 0, 0}, {134, 0, 0},
{132, 0, 0}, {130, 1, 0}, {128, 4, 0}, {126, 8, 0}, {124, 14, 0}, {121, 23, 0}, {119, 34, 0}, {117, 46, 0},
{115, 61, 0}, {113, 78, 0}, {110, 97, 0}, {108, 118, 0}, {106, 140, 0}, {103, 163, 0}, {101, 186, 0}, {98, 209, 0},
{95, 232, 0}, {92, 239, 0}, {89, 243, 0}, {86, 246, 0}, {82, 247, 0}, {79, 247, 0}, {76, 245, 0}, {72, 242, 0},
{69, 238, 0}, {66, 233, 0}, {63, 227, 0}, {60, 221, 0}, {57, 214, 0}, {54, 206, 0}, {51, 199, 0}, {49, 191, 0},
{46, 183, 0}, {44, 181, 0}, {42, 178, 0}, {41, 176, 0}, {39, 173, 0}, {37, 171, 0}, {36, 168, 0}, {34, 166, 0},
{32, 163, 0}, {31, 161, 0}, {29, 158, 0}, {28, 156, 0}, {27, 153, 0}, {25, 150, 0}, {24, 148, 0}, {23, 145, 0},
{22, 143, 0}, {20, 139, 0}, {19, 136, 0}, {17, 133, 0}, {16, 130, 0}, {15, 127, 0}, {14, 124, 0}, {12, 121, 0},
{11, 118, 0}, {10, 115, 0}, {9, 111, 0}, {8, 108, 0}, {8, 105, 0}, {7, 102, 0}, {6, 99, 0}, {5, 96, 0},
{5, 93, 0}, {4, 90, 1}, {3, 87, 3}, {3, 85, 8}, {2, 82, 15}, {2, 79, 24}, {2, 76, 35}, {1, 74, 49},
{1, 71, 65}, {1, 69, 83}, {1, 66, 103}, {0, 64, 125}, {0, 61, 148}, {0, 59, 172}, {0, 57, 197}, {0, 55, 222},
{0, 53, 247}, {0, 51, 253}, {0, 49, 255}, {0, 48, 255}, {0, 46, 255}, {0, 44, 255}, {0, 43, 255}, {0, 41, 251},
{0, 40, 246}, {0, 39, 239}, {0, 37, 232}, {0, 36, 223}, {0, 35, 215}, {0, 33, 205}, {0, 32, 196}, {0, 31, 187},
{0, 30, 177}, {0, 28, 172}, {0, 27, 167}, {0, 26, 162}, {0, 24, 157}, {0, 23, 152}, {0, 22, 147}, {0, 21, 142},
{0, 20, 137}, {0, 19, 133}, {0, 18, 128}, {0, 17, 124}, {0, 16, 120}, {0, 15, 116}, {0, 14, 112}, {0, 13, 108},
{0, 12, 105}, {0, 11, 102}, {0, 11, 99}, {0, 10, 97}, {0, 9, 94}, {0, 9, 92}, {0, 8, 90}, {0, 8, 88},
{0, 7, 86}, {0, 7, 84}, {0, 6, 82}, {0, 6, 80}, {0, 5, 79}, {0, 5, 77}, {0, 4, 76}, {0, 4, 74},
{0, 4, 73}, {0, 3, 71}, {0, 3, 70}, {0, 3, 69}, {0, 2, 67}, {0, 2, 66}, {0, 2, 65}, {0, 1, 64},
{0, 1, 62}, {0, 1, 61}, {0, 1, 60}, {0, 1, 59}, {0, 1, 57}, {0, 1, 56}, {0, 0, 54}, {0, 0, 53},
{0, 0, 51}, {0, 0, 49}, {0, 0, 47}, {0, 0, 44}, {0, 0, 42}, {0, 0, 40}, {0, 0, 38}, {0, 0, 36},
{0, 0, 33}, {0, 0, 31}, {0, 0, 29}, {0, 0, 27}, {0, 0, 25}, {0, 0, 24}, {0, 0, 22}, {0, 0, 20},
{0, 0, 18}, {0, 0, 17}, {0, 0, 16}, {0, 0, 15}, {0, 0, 13}, {0, 0, 12}, {0, 0, 11}, {0, 0, 10},
{0, 0, 9}, {0, 0, 9}, {0, 0, 8}, {0, 0, 7}, {0, 0, 6}, {0, 0, 6}, {0, 0, 5}, {0, 0, 5},
{0, 0, 4}, {0, 0, 4}, {0, 0, 3}, {0, 0, 3}, {0, 0, 2}, {0, 0, 2}, {0, 0, 2}, {0, 0, 2},
{0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 1}, {0, 0, 0},
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
};
byte getChase(uint32_t pwm, uint32_t led) {
return pgm_read_byte(&chasing[pwm][led]);
}