-
Notifications
You must be signed in to change notification settings - Fork 0
/
StripManipulator.ino
84 lines (75 loc) · 1.91 KB
/
StripManipulator.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
/*
Methods to change the state of the strip
*/
void setStrip(CRGB strip[], CRGB color) {
}
void setStrip(CRGB strip[]) {
}
void setPixel(CRGB strip[], uint16_t index) {
if (useColorSensor == true) {
strip[index].setRGB(gammatable[(int) r], gammatable[(int) g], gammatable[(int) b]);
} else {
strip[index].setHue(colorCounter);
}
}
void setPixel(CRGB strip[], uint16_t index, CRGB color) {
strip[index] = color;
}
void blackInfinityStrip() {
for(uint8_t i=0;i<NUM_INFINITY_LED;i++) {
infinity[i] = CRGB::Black;
}
}
//Check out the memmove function to maybe do it more quickly
void shift(CRGB strip[], bool changeDirection) {
CRGB wrapAroundPixel;
if (changeDirection == true) {
wrapAroundPixel = strip[NUM_INFINITY_LED - 1];
for (int i = NUM_INFINITY_LED - 1; i > 0; i--) {
strip[i] = strip[i - 1];
}
strip[0] = wrapAroundPixel;
} else {
wrapAroundPixel = strip[0];
for (int i = 0; i < NUM_INFINITY_LED; i++) {
strip[i] = strip[i + 1];
}
strip[NUM_INFINITY_LED - 1] = wrapAroundPixel;
}
}
int runnerPixel = 0; //uint8 signed or unsigned?
void paint(CRGB strip[], CRGB color, bool changeDirection) {
if (runnerPixel == NUM_INFINITY_LED) { //using this constant wont jive with other strips...
runnerPixel = 0;
}
if (runnerPixel < 0) {
runnerPixel = NUM_INFINITY_LED;
}
strip[runnerPixel] = color;
if (changeDirection == true) {
runnerPixel++;
} else {
runnerPixel--;
}
}
void cycleSolid() {
colorCounter++;
for (int i = 0; i < NUM_INFINITY_LED; i++) {
infinity[i].setHue(colorCounter);
}
}
//do multiple like it says, dick.
void blinkRandom(uint8_t numberRandomPixels, bool randomColor) {
uint8_t randomPixel = random8(60);
uint8_t randomHue = random8();
for (int i = 0; i < NUM_INFINITY_LED; i++) {
infinity[i] = CRGB::Black;
if(randomPixel == i) {
if(randomColor == true) {
infinity[i].setHue(colorCounter);
} else {
infinity[i].setHue(randomHue);
}
}
}
}