-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathneopixelRing.ino
More file actions
114 lines (114 loc) · 2.98 KB
/
neopixelRing.ino
File metadata and controls
114 lines (114 loc) · 2.98 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#ifdef useNeopixelRing
void manageNeopixelRing(void *data)
{
if (neopixelPattern == 0)
{
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
}
}
else if (neopixelPattern == 1)
{
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
leds[i].r = (uint8_t)(pow(sin(((millis()/1000) * 1.5) + (i * 0.4)) * 0.5 + 0.5, 1.5) * neopixelRed);
leds[i].g = (uint8_t)(pow(sin(((millis()/1000) * 1.5) + (i * 0.4)) * 0.5 + 0.5, 1.5) * neopixelGreen);
leds[i].b = (uint8_t)(pow(sin(((millis()/1000) * 1.5) + (i * 0.4)) * 0.5 + 0.5, 1.5) * neopixelBlue);
}
}
else if (neopixelPattern == 2)
{
auto m = millis();
m = (m - (m % 1000)) / 1000;
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = cols[m % 6];
}
}
else if (neopixelPattern == 3)
{
static float nextDrop = 0;
if (changed)
{
randomSeed(micros());
}
if (millis() - lastMove > nextDrop)
{
lastMove = millis();
int dc = random(1, 4);
for (int n = 0; n < dc; n++)
{
int led = random(0, NUM_LEDS);
leds[led] = polybiusOrange;
}
nextDrop = random(0, 200) + 20;
}
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i].r = (uint8_t)max(0.0, leds[i].r * 0.85);
leds[i].g = (uint8_t)max(0.0, leds[i].g * 0.85);
leds[i].b = (uint8_t)max(0.0, leds[i].b * 0.85);
}
}
else if (neopixelPattern == 4)
{
static float nextChange = 0;
if (nextChange == 0)
{
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
}
}
if(millis() - nextChange > 250)
{
nextChange = millis();
int start = random(0, NUM_LEDS);
auto col = cols[random(0, 6)];
for (int i = start; i < start + 4; i++)
{
leds[i % NUM_LEDS] = col;
}
}
}
else if (neopixelPattern == 5)
{
unsigned long m = millis();
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i].r = 0;
leds[i].b = 0;
leds[i].g = ((m >> i) & 1) * 255;
}
}
else if (neopixelPattern == 6)
{
unsigned long m = millis();
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CHSV(((i * 8) + (m / 32)) % 256, 255, 255);
}
}
else if (neopixelPattern == 7)
{
if (millis() - lastMove >= neopixelAnimationRate)
{
lastMove = millis();
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Black;
}
if (ln == 0)
ln = NUM_LEDS;
ln--;
//leds[ln] = CRGB::White;
//leds[ln] = cols[installationToDisplay%6];
//leds[ln] = polybiusOrange;
leds[ln] = CRGB::DarkOrange;
}
}
FastLED.show();
}
#endif