/
cylon.h
63 lines (46 loc) · 1.32 KB
/
cylon.h
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
#ifndef CYLON_H
#define CYLON_H
/* int cylon_step
int cylon_center
uint8_t cylon_index
uint8_t cylon_brightness = 255
*/
void cylon(bool old) {
mode_number = 57;
if (old) {
ringPaletteAdd(1, old_cylon_center, current_palette, old_cylon_index, old_cylon_brightness, current_blending);
for (uint8_t i = 0; i < 15; i++) {
if (old_cylon_center - 7 + i >= 0 && old_cylon_center - 7 + i < STRIP_LENGTH) {
ringPaletteAdd(1, old_cylon_center - 7 + i, current_palette, old_cylon_index, old_cylon_brightness - i * 43, current_blending);
}
}
switch (old_cylon_step) {
case -1:
old_cylon_center--;
if (old_cylon_center < -14) { old_cylon_step = 1; }
break;
case 1:
old_cylon_center++;
if (old_cylon_center > STRIP_LENGTH + 14) { old_cylon_step = -1; old_cylon_index = random8(); }
break;
}
}
else {
for (uint8_t i = 0; i < 15; i++) {
if (cylon_center - 7 + i >= 0 && cylon_center - 7 + i < STRIP_LENGTH) {
ringPaletteAdd(0, cylon_center - 7 + i, current_palette, cylon_index, cylon_brightness - i * 43, current_blending);
}
}
switch (cylon_step) {
case -1:
cylon_center--;
if (cylon_center < -14) { cylon_step = 1; }
break;
case 1:
cylon_center++;
if (cylon_center > STRIP_LENGTH + 14) { cylon_step = -1; cylon_index = random8(); }
break;
}
}
}
#endif