This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColors_Hub.ino
369 lines (301 loc) · 8.98 KB
/
Colors_Hub.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
#include "FastLED.h"
#define UNDERGLOW_DATA_PIN 3
#define UNDERGLOW_NUM_LEDS 69
CRGB underglow[UNDERGLOW_NUM_LEDS];
int underglow_pattern = 6;
int underglow_clock = 0;
#define CYCLONE_DATA_PIN 4
#define CYCLONE_NUM_LEDS 34
#define CYCLONE_LED_SPEED 3
CRGB cyclone[CYCLONE_NUM_LEDS];
int cyclone_pattern = 6;
int cyclone_clock = 0;
#define HOPPER_DATA_PIN 5
#define HOPPER_NUM_LEDS 80
CRGB hopper[HOPPER_NUM_LEDS];
int hopper_pattern;
int hopper_clock = 0;
/*
* underglow patterns
* u0x : off
* u1x : red
* u2x : blue
* u3x : pulsing orange
* u4x : chasing orange
* u5x : rainbow
* u6x : chasing rainbow
* u7x : spiral orange scheme
*
* cyclone patterns
* c0x : off
* c1x : orange
* c2x : chasing orange
* c3x : chasing white
* c4x : chasing "screamin" yellow
* c5x : rainbow
* c6x : chasing rainbow
*
* hopper patterns
* h0x : off
* h1x :
* h2x :
* h3x :
* h4x :
* h5x : rainbow
* h6x : chasing rainbow
*/
int pattern_id = -1;
int prev_pattern_id;
void setup()
{
FastLED.addLeds<NEOPIXEL, UNDERGLOW_DATA_PIN>(underglow, UNDERGLOW_NUM_LEDS);
FastLED.addLeds<NEOPIXEL, CYCLONE_DATA_PIN>(cyclone, CYCLONE_NUM_LEDS);
FastLED.addLeds<NEOPIXEL, HOPPER_DATA_PIN>(hopper, HOPPER_NUM_LEDS);
Serial.begin(9600);
Serial.setTimeout(1000);
}
void loop()
{
prev_pattern_id = pattern_id;
while (Serial.available() > 0)
{
pattern_id = Serial.parseInt();
}
if (pattern_id >= 0 && pattern_id < 10)
underglow_pattern = pattern_id;
else if (pattern_id >= 10 && pattern_id < 20)
cyclone_pattern = pattern_id - 10;
else if (pattern_id >= 20 && pattern_id < 30)
hopper_pattern = pattern_id - 20;
if (prev_pattern_id != pattern_id)
setupPatterns(pattern_id);
runPatterns();
FastLED.show();
delay(50);
}
void runPatterns()
{
//underglow
switch (underglow_pattern)
{
case 0: //off
for (int i = 0; i < UNDERGLOW_NUM_LEDS; i++)
{
underglow[i] = CRGB::Black;
} break;
case 1: //red
for (int i = 0; i < UNDERGLOW_NUM_LEDS; i++)
{
underglow[i].setRGB(127, 0, 0);
} break;
case 2: //blue
for (int i = 0; i < UNDERGLOW_NUM_LEDS; i++)
{
underglow[i].setRGB(0, 0, 127);
} break;
case 3: // pulse orange
underglow_clock++;
if (underglow_clock >= 40)
underglow_clock = 0;
for (int i = 0; i < UNDERGLOW_NUM_LEDS; i++)
{
if (underglow_clock < 20)
underglow[i].setHSV(24, 255, (10 * underglow_clock) + 30);
else if (underglow_clock >= 20)
underglow[i].setHSV(24, 255, 200 - (10 * (underglow_clock - 20)));
} break;
case 4: //chase orange
underglow_clock++;
if (underglow_clock >= UNDERGLOW_NUM_LEDS - 1)
underglow_clock = 1;
underglow[underglow_clock].setHSV(24, 255, 230);
underglow[underglow_clock-1].setHSV(24, 255, 127);
break;
case 5: //rainbow
if (underglow_clock >= 255)
underglow_clock = 0;
underglow_clock += 2;
for (int i = 0; i < UNDERGLOW_NUM_LEDS; i++)
{
underglow[i].setHue(underglow_clock);
} break;
case 6: // chasing rainbow
underglow_clock += 2;
if (underglow_clock >= UNDERGLOW_NUM_LEDS)
underglow_clock = 0;
for (int i = 0; i < UNDERGLOW_NUM_LEDS; i++)
{
if ((i + underglow_clock) < UNDERGLOW_NUM_LEDS)
underglow[i + underglow_clock].setHue((i * floor(255/UNDERGLOW_NUM_LEDS)) + 1);
else if ((i + underglow_clock) > UNDERGLOW_NUM_LEDS)
underglow[(i + underglow_clock - UNDERGLOW_NUM_LEDS) - 1].setHue(i * floor(255/UNDERGLOW_NUM_LEDS));
}
break;
case 7: //orange chase scheme
underglow_clock++;
if (underglow_clock > UNDERGLOW_NUM_LEDS * 3)
underglow_clock = 0;
if (underglow_clock < UNDERGLOW_NUM_LEDS)
underglow[underglow_clock] = 0xFF3300;
else if (underglow_clock >= UNDERGLOW_NUM_LEDS && underglow_clock < UNDERGLOW_NUM_LEDS * 2)
underglow[underglow_clock - UNDERGLOW_NUM_LEDS] = 0xFF6600;
else if (underglow_clock >= UNDERGLOW_NUM_LEDS * 2)
underglow[underglow_clock - UNDERGLOW_NUM_LEDS * 2] = 0xFF9900;
}
//cyclone
switch (cyclone_pattern)
{
case 0: // off
for (int i = 0; i < CYCLONE_NUM_LEDS; i++)
{
cyclone[i] = CRGB::Black;
}break;
case 1: //solid orange
for (int i = 0; i < CYCLONE_NUM_LEDS; i++)
{
cyclone[i].setHSV(24, 255, 180);
} break;
case 2: // chase orange
cyclone_clock += CYCLONE_LED_SPEED;
if (cyclone_clock > CYCLONE_NUM_LEDS)
cyclone_clock = 0;
for (int i = 0; i < CYCLONE_NUM_LEDS; i++)
{
cyclone[i].setHSV(24, 255, 130);
}
cyclone[cyclone_clock].setHSV(24, 255, 230);
if (cyclone_clock > 0)
cyclone[cyclone_clock-1].setHSV(24, 255, 210);
if (cyclone_clock > 1)
cyclone[cyclone_clock-2].setHSV(24, 255, 190);
if (cyclone_clock > 2)
cyclone[cyclone_clock-3].setHSV(24, 255, 170);
if (cyclone_clock > 3)
cyclone[cyclone_clock-4].setHSV(24, 255, 150);
break;
case 3: // chase white
cyclone_clock += CYCLONE_LED_SPEED;
if (cyclone_clock > CYCLONE_NUM_LEDS)
cyclone_clock = 0;
for (int i = 0; i < CYCLONE_NUM_LEDS; i++)
{
cyclone[i].setRGB(80, 80, 60);
}
cyclone[cyclone_clock].setRGB(255, 255, 230);
if (cyclone_clock > 0)
cyclone[cyclone_clock-1].setRGB(220, 220, 220);
if (cyclone_clock > 1)
cyclone[cyclone_clock-2].setRGB(190, 190, 160);
if (cyclone_clock > 2)
cyclone[cyclone_clock-3].setRGB(150, 150, 130);
if (cyclone_clock > 3)
cyclone[cyclone_clock-4].setRGB(100, 100, 80);
break;
case 4: // chase "screamin" yellow
cyclone_clock += CYCLONE_LED_SPEED;
if (cyclone_clock > CYCLONE_NUM_LEDS)
cyclone_clock = 0;
for (int i = 0; i < CYCLONE_NUM_LEDS; i++)
{
cyclone[i].setHSV(39, 255, 156);
}
cyclone[cyclone_clock].maximizeBrightness();
break;
case 5: //rainbow
cyclone_clock += 2;
if (cyclone_clock >= 255)
cyclone_clock = 0;
for (int i = 0; i < CYCLONE_NUM_LEDS; i++)
{
cyclone[i].setHue(cyclone_clock);
} break;
case 6: // chasing rainbow
cyclone_clock += 2;
if (cyclone_clock >= CYCLONE_NUM_LEDS)
cyclone_clock = 0;
for (int i = 0; i < CYCLONE_NUM_LEDS; i++)
{
if ((i + cyclone_clock) < CYCLONE_NUM_LEDS)
cyclone[i + cyclone_clock].setHue((i * floor(255/CYCLONE_NUM_LEDS)) + 1);
else if ((i + cyclone_clock) > CYCLONE_NUM_LEDS)
cyclone[(i + cyclone_clock - CYCLONE_NUM_LEDS) - 1].setHue(i * floor(255/CYCLONE_NUM_LEDS));
}
break;
}
//hopper
switch (hopper_pattern)
{
case 0: //off
for (int i = 0; i < HOPPER_NUM_LEDS; i++)
{
hopper[i] = CRGB::Black;
} break;
case 1:
break;
case 5: //rainbow
hopper_clock += 2;
if (hopper_clock >= 255)
hopper_clock = 0;
for (int i = 0; i < HOPPER_NUM_LEDS; i++)
{
hopper[i].setHue(hopper_clock);
} break;
case 6: // chasing rainbow
hopper_clock += 2;
if (hopper_clock >= HOPPER_NUM_LEDS)
hopper_clock = 0;
for (int i = 0; i < HOPPER_NUM_LEDS; i++)
{
if ((i + hopper_clock) < HOPPER_NUM_LEDS)
hopper[i + hopper_clock].setHue((i * floor(255/HOPPER_NUM_LEDS)) + 1);
else if ((i + hopper_clock) > HOPPER_NUM_LEDS)
hopper[(i + hopper_clock - HOPPER_NUM_LEDS) - 1].setHue(i * floor(255/HOPPER_NUM_LEDS));
}break;
}
}
void setupPatterns(int pattern)
{
switch (pattern)
{
case 3: //orange underglow pulse
for (int i = 0; i < UNDERGLOW_NUM_LEDS; i++)
{
underglow[i].setHSV(24, 255, 127);
}
underglow_clock = 15;
break;
case 4: //orange underglow chase
for (int i = 0; i < UNDERGLOW_NUM_LEDS; i++)
{
underglow[i].setHSV(24, 255, 127);
}
underglow_clock = 0;
break;
case 5: //rainbow underglow
for (int i = 0; i < UNDERGLOW_NUM_LEDS; i++)
{
underglow[i].setHSV(1, 255, 255);
}
underglow_clock = 0;
break;
case 6: //rainbow chase underglow
for (int i = 0; i < UNDERGLOW_NUM_LEDS; i++)
{
underglow[i] = CRGB::Black;
}
underglow_clock = 0;
break;
case 12: // orange chase cyclone
cyclone_clock = 0;
for (int i = 0; i < CYCLONE_NUM_LEDS; i++)
{
cyclone[i].setHSV(24, 255, 130);
}break;
case 13: // white chase cyclone
cyclone_clock = 0;
for (int i = 0; i < CYCLONE_NUM_LEDS; i++)
{
cyclone[i].setRGB(127, 127, 127);
}break;
}
}