-
Notifications
You must be signed in to change notification settings - Fork 0
/
Animations.ino
98 lines (89 loc) · 2.77 KB
/
Animations.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
void meteorChaser(uint16_t meteorBodyPixel, uint8_t tailLength, uint16_t fadeValue, bool rainbowTail) {
uint16_t i;
int fadeSpectrum = fadeValue;
int fadeIncrement = (256 - fadeValue) / tailLength;
if (rainbowTail == true) {
fill_rainbow(&(infinity[meteorBodyPixel]), tailLength, colorCounter);
} else {
if (direction == true) {
for (i = meteorBodyPixel; i > (meteorBodyPixel - tailLength); i--) {
infinity[i].setHue(colorCounter);
infinity[i].fadeLightBy(fadeSpectrum);
fadeSpectrum += fadeIncrement;
}
} else {
for (i = (meteorBodyPixel - tailLength); i < meteorBodyPixel; i++) {
infinity[i].setHue(colorCounter);
infinity[i].fadeLightBy(fadeSpectrum);
fadeSpectrum += fadeIncrement;
}
}
}
FastLED.show();
}
int bodyPixel = 0; //needs to be signed
void meteorChaserColorSensor(uint8_t tailLength, uint16_t fadeValue) {
int i;
int fadeSpectrum = fadeValue;
int fadeIncrement = (256 - fadeValue) / tailLength;
getColorSensorData();
blackInfinityStrip();
if (bodyPixel > NUM_INFINITY_LED - 1) {
bodyPixel = 0;
} else if (bodyPixel < 0) {
bodyPixel = NUM_INFINITY_LED - 1;
}
if (direction == true) {
for (i = bodyPixel; i > (bodyPixel - tailLength); i--) {
infinity[correctNumber(i)].setRGB(gammatable[(int) r], gammatable[(int) g], gammatable[(int) b]);
infinity[correctNumber(i)].fadeLightBy(fadeSpectrum);
fadeSpectrum += fadeIncrement;
}
bodyPixel++;
} else {
for (i = (bodyPixel - tailLength); i < bodyPixel; i++) {
infinity[correctNumber(i)].setRGB(gammatable[(int) r], gammatable[(int) g], gammatable[(int) b]);
infinity[correctNumber(i)].fadeLightBy(fadeSpectrum);
fadeSpectrum += fadeIncrement;
}
bodyPixel--;
}
FastLED.show();
}
//wtf do I even name this?
uint8_t correctNumber(int number) {
if (number > NUM_INFINITY_LED - 1)
return (number - NUM_INFINITY_LED);
else if (number < 0)
return (number + NUM_INFINITY_LED);
else
return number;
}
void wipeRainbow(int delayTime) {
fill_rainbow(&(infinity[0]), NUM_INFINITY_LED, 0);
FastLED.show();
}
void wipeInfinity(int delayTime) {
for (uint8_t i = 0; i < NUM_INFINITY_LED; i++) {
setPixel(infinity, i);
FastLED.show();
delay(delayTime);
colorCounter += 4;
}
}
void fillSolid(CRGB color) {
fill_solid(&(infinity[0]), 60, color);
}
void fillSolid(uint16_t colorCounter) {
for (uint8_t i = 0; i < NUM_INFINITY_LED; i++) {
infinity[i].setHue(colorCounter);
}
}
void fourPoints(uint8_t point1, uint8_t point2, uint8_t point3, uint8_t point4) {
for (uint8_t i = 0; i < NUM_INFINITY_LED; i++) {
if (i == point1 || i == point2 || i == point3 || i == point4) {
infinity[i].setHue(colorCounter);
}
}
FastLED.show();
}