-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLED_Strip.cpp
More file actions
574 lines (421 loc) · 27.9 KB
/
LED_Strip.cpp
File metadata and controls
574 lines (421 loc) · 27.9 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
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
#include "LED_Strip.h"
#include <inttypes.h>
using namespace std;
/** Constructor for the LEDStrip Class
Because of the Arduino's requirement that pin numbers be defined at compile, if-else-if statements are used to permit passing of a pin as a parameter from the .ino file
@param numLEDs Number of LEDs in the strip
@param pin The pin connected to the strip */
LEDStrip::LEDStrip(int numLEDs, int pinIn) {
pixelCount = numLEDs; // Save numLEDs to pixelCount
ledArray = new CRGB[numLEDs]; // Allocate new array of CRGB (pixels)
pin = pinIn;
if (pin == 0) FastLED.addLeds<NEOPIXEL, PIN0>(ledArray, numLEDs); // If pin == #, use PIN#
else if (pin == 1) FastLED.addLeds<NEOPIXEL, PIN1>(ledArray, numLEDs);
else if (pin == 2) FastLED.addLeds<NEOPIXEL, PIN2>(ledArray, numLEDs);
else if (pin == 3) FastLED.addLeds<NEOPIXEL, PIN3>(ledArray, numLEDs);
else if (pin == 4) FastLED.addLeds<NEOPIXEL, PIN4>(ledArray, numLEDs);
else if (pin == 5) FastLED.addLeds<NEOPIXEL, PIN5>(ledArray, numLEDs);
else if (pin == 6) FastLED.addLeds<NEOPIXEL, PIN6>(ledArray, numLEDs);
else if (pin == 7) FastLED.addLeds<NEOPIXEL, PIN7>(ledArray, numLEDs);
else if (pin == 8) FastLED.addLeds<NEOPIXEL, PIN8>(ledArray, numLEDs);
else if (pin == 9) FastLED.addLeds<NEOPIXEL, PIN9>(ledArray, numLEDs);
else if (pin == 10) FastLED.addLeds<NEOPIXEL, PIN10>(ledArray, numLEDs);
else if (pin == 11) FastLED.addLeds<NEOPIXEL, PIN11>(ledArray, numLEDs);
else if (pin == 12) FastLED.addLeds<NEOPIXEL, PIN12>(ledArray, numLEDs);
else if (pin == 13) FastLED.addLeds<NEOPIXEL, PIN13>(ledArray, numLEDs);
else if (pin == 14) FastLED.addLeds<NEOPIXEL, PIN14>(ledArray, numLEDs);
else if (pin == 15) FastLED.addLeds<NEOPIXEL, PIN15>(ledArray, numLEDs);
else if (pin == 16) FastLED.addLeds<NEOPIXEL, PIN16>(ledArray, numLEDs);
else if (pin == 17) FastLED.addLeds<NEOPIXEL, PIN17>(ledArray, numLEDs);
else if (pin == 18) FastLED.addLeds<NEOPIXEL, PIN18>(ledArray, numLEDs);
else if (pin == 19) FastLED.addLeds<NEOPIXEL, PIN19>(ledArray, numLEDs);
else if (pin == 20) FastLED.addLeds<NEOPIXEL, PIN20>(ledArray, numLEDs);
else if (pin == 21) FastLED.addLeds<NEOPIXEL, PIN21>(ledArray, numLEDs);
else if (pin == 22) FastLED.addLeds<NEOPIXEL, PIN22>(ledArray, numLEDs);
else if (pin == 23) FastLED.addLeds<NEOPIXEL, PIN23>(ledArray, numLEDs);
else if (pin == 24) FastLED.addLeds<NEOPIXEL, PIN24>(ledArray, numLEDs);
else if (pin == 25) FastLED.addLeds<NEOPIXEL, PIN25>(ledArray, numLEDs);
else if (pin == 26) FastLED.addLeds<NEOPIXEL, PIN26>(ledArray, numLEDs);
else if (pin == 27) FastLED.addLeds<NEOPIXEL, PIN27>(ledArray, numLEDs);
else if (pin == 28) FastLED.addLeds<NEOPIXEL, PIN28>(ledArray, numLEDs);
else if (pin == 29) FastLED.addLeds<NEOPIXEL, PIN29>(ledArray, numLEDs);
else if (pin == 30) FastLED.addLeds<NEOPIXEL, PIN30>(ledArray, numLEDs);
else if (pin == 31) FastLED.addLeds<NEOPIXEL, PIN31>(ledArray, numLEDs);
else if (pin == 32) FastLED.addLeds<NEOPIXEL, PIN32>(ledArray, numLEDs);
else if (pin == 33) FastLED.addLeds<NEOPIXEL, PIN33>(ledArray, numLEDs);
else if (pin == 34) FastLED.addLeds<NEOPIXEL, PIN34>(ledArray, numLEDs);
else if (pin == 35) FastLED.addLeds<NEOPIXEL, PIN35>(ledArray, numLEDs);
else if (pin == 36) FastLED.addLeds<NEOPIXEL, PIN36>(ledArray, numLEDs);
else if (pin == 37) FastLED.addLeds<NEOPIXEL, PIN37>(ledArray, numLEDs);
else if (pin == 38) FastLED.addLeds<NEOPIXEL, PIN38>(ledArray, numLEDs);
else if (pin == 39) FastLED.addLeds<NEOPIXEL, PIN39>(ledArray, numLEDs);
else if (pin == 40) FastLED.addLeds<NEOPIXEL, PIN40>(ledArray, numLEDs);
else if (pin == 41) FastLED.addLeds<NEOPIXEL, PIN41>(ledArray, numLEDs);
else if (pin == 42) FastLED.addLeds<NEOPIXEL, PIN42>(ledArray, numLEDs);
else if (pin == 43) FastLED.addLeds<NEOPIXEL, PIN43>(ledArray, numLEDs);
else if (pin == 44) FastLED.addLeds<NEOPIXEL, PIN44>(ledArray, numLEDs);
else if (pin == 45) FastLED.addLeds<NEOPIXEL, PIN45>(ledArray, numLEDs);
else if (pin == 46) FastLED.addLeds<NEOPIXEL, PIN46>(ledArray, numLEDs);
else if (pin == 47) FastLED.addLeds<NEOPIXEL, PIN47>(ledArray, numLEDs);
else if (pin == 48) FastLED.addLeds<NEOPIXEL, PIN48>(ledArray, numLEDs);
else if (pin == 49) FastLED.addLeds<NEOPIXEL, PIN49>(ledArray, numLEDs);
else if (pin == 50) FastLED.addLeds<NEOPIXEL, PIN50>(ledArray, numLEDs);
else if (pin == 51) FastLED.addLeds<NEOPIXEL, PIN51>(ledArray, numLEDs);
else if (pin == 52) FastLED.addLeds<NEOPIXEL, PIN52>(ledArray, numLEDs);
else if (pin == 53) FastLED.addLeds<NEOPIXEL, PIN53>(ledArray, numLEDs);
}
/** Copy Constructor for the LEDStrip Class
Because of the Arduino's requirement that pin numbers be defined at compile, if-else-if statements are used to permit passing of a pin as a parameter from the .ino file
@param stripIn The LEDStrip instance to be copied to the new LEDStrip */
LEDStrip::LEDStrip(const LEDStrip &stripIn) {
pixelCount = stripIn.pixelCount; // Save stripIn.pixelCount to pixelCount
ledArray = new CRGB[pixelCount]; // Allocate new array of CRGB (pixels)
pin = stripIn.pin;
for (int i = 0; i < pixelCount; i++)
ledArray[i] = stripIn.ledArray[i];
if (pin == 0) FastLED.addLeds<NEOPIXEL, PIN0>(ledArray, pixelCount); // If pin == #, use PIN#
else if (pin == 1) FastLED.addLeds<NEOPIXEL, PIN1>(ledArray, pixelCount);
else if (pin == 2) FastLED.addLeds<NEOPIXEL, PIN2>(ledArray, pixelCount);
else if (pin == 3) FastLED.addLeds<NEOPIXEL, PIN3>(ledArray, pixelCount);
else if (pin == 4) FastLED.addLeds<NEOPIXEL, PIN4>(ledArray, pixelCount);
else if (pin == 5) FastLED.addLeds<NEOPIXEL, PIN5>(ledArray, pixelCount);
else if (pin == 6) FastLED.addLeds<NEOPIXEL, PIN6>(ledArray, pixelCount);
else if (pin == 7) FastLED.addLeds<NEOPIXEL, PIN7>(ledArray, pixelCount);
else if (pin == 8) FastLED.addLeds<NEOPIXEL, PIN8>(ledArray, pixelCount);
else if (pin == 9) FastLED.addLeds<NEOPIXEL, PIN9>(ledArray, pixelCount);
else if (pin == 10) FastLED.addLeds<NEOPIXEL, PIN10>(ledArray, pixelCount);
else if (pin == 11) FastLED.addLeds<NEOPIXEL, PIN11>(ledArray, pixelCount);
else if (pin == 12) FastLED.addLeds<NEOPIXEL, PIN12>(ledArray, pixelCount);
else if (pin == 13) FastLED.addLeds<NEOPIXEL, PIN13>(ledArray, pixelCount);
else if (pin == 14) FastLED.addLeds<NEOPIXEL, PIN14>(ledArray, pixelCount);
else if (pin == 15) FastLED.addLeds<NEOPIXEL, PIN15>(ledArray, pixelCount);
else if (pin == 16) FastLED.addLeds<NEOPIXEL, PIN16>(ledArray, pixelCount);
else if (pin == 17) FastLED.addLeds<NEOPIXEL, PIN17>(ledArray, pixelCount);
else if (pin == 18) FastLED.addLeds<NEOPIXEL, PIN18>(ledArray, pixelCount);
else if (pin == 19) FastLED.addLeds<NEOPIXEL, PIN19>(ledArray, pixelCount);
else if (pin == 20) FastLED.addLeds<NEOPIXEL, PIN20>(ledArray, pixelCount);
else if (pin == 21) FastLED.addLeds<NEOPIXEL, PIN21>(ledArray, pixelCount);
else if (pin == 22) FastLED.addLeds<NEOPIXEL, PIN22>(ledArray, pixelCount);
else if (pin == 23) FastLED.addLeds<NEOPIXEL, PIN23>(ledArray, pixelCount);
else if (pin == 24) FastLED.addLeds<NEOPIXEL, PIN24>(ledArray, pixelCount);
else if (pin == 25) FastLED.addLeds<NEOPIXEL, PIN25>(ledArray, pixelCount);
else if (pin == 26) FastLED.addLeds<NEOPIXEL, PIN26>(ledArray, pixelCount);
else if (pin == 27) FastLED.addLeds<NEOPIXEL, PIN27>(ledArray, pixelCount);
else if (pin == 28) FastLED.addLeds<NEOPIXEL, PIN28>(ledArray, pixelCount);
else if (pin == 29) FastLED.addLeds<NEOPIXEL, PIN29>(ledArray, pixelCount);
else if (pin == 30) FastLED.addLeds<NEOPIXEL, PIN30>(ledArray, pixelCount);
else if (pin == 31) FastLED.addLeds<NEOPIXEL, PIN31>(ledArray, pixelCount);
else if (pin == 32) FastLED.addLeds<NEOPIXEL, PIN32>(ledArray, pixelCount);
else if (pin == 33) FastLED.addLeds<NEOPIXEL, PIN33>(ledArray, pixelCount);
else if (pin == 34) FastLED.addLeds<NEOPIXEL, PIN34>(ledArray, pixelCount);
else if (pin == 35) FastLED.addLeds<NEOPIXEL, PIN35>(ledArray, pixelCount);
else if (pin == 36) FastLED.addLeds<NEOPIXEL, PIN36>(ledArray, pixelCount);
else if (pin == 37) FastLED.addLeds<NEOPIXEL, PIN37>(ledArray, pixelCount);
else if (pin == 38) FastLED.addLeds<NEOPIXEL, PIN38>(ledArray, pixelCount);
else if (pin == 39) FastLED.addLeds<NEOPIXEL, PIN39>(ledArray, pixelCount);
else if (pin == 40) FastLED.addLeds<NEOPIXEL, PIN40>(ledArray, pixelCount);
else if (pin == 41) FastLED.addLeds<NEOPIXEL, PIN41>(ledArray, pixelCount);
else if (pin == 42) FastLED.addLeds<NEOPIXEL, PIN42>(ledArray, pixelCount);
else if (pin == 43) FastLED.addLeds<NEOPIXEL, PIN43>(ledArray, pixelCount);
else if (pin == 44) FastLED.addLeds<NEOPIXEL, PIN44>(ledArray, pixelCount);
else if (pin == 45) FastLED.addLeds<NEOPIXEL, PIN45>(ledArray, pixelCount);
else if (pin == 46) FastLED.addLeds<NEOPIXEL, PIN46>(ledArray, pixelCount);
else if (pin == 47) FastLED.addLeds<NEOPIXEL, PIN47>(ledArray, pixelCount);
else if (pin == 48) FastLED.addLeds<NEOPIXEL, PIN48>(ledArray, pixelCount);
else if (pin == 49) FastLED.addLeds<NEOPIXEL, PIN49>(ledArray, pixelCount);
else if (pin == 50) FastLED.addLeds<NEOPIXEL, PIN50>(ledArray, pixelCount);
else if (pin == 51) FastLED.addLeds<NEOPIXEL, PIN51>(ledArray, pixelCount);
else if (pin == 52) FastLED.addLeds<NEOPIXEL, PIN52>(ledArray, pixelCount);
else if (pin == 53) FastLED.addLeds<NEOPIXEL, PIN53>(ledArray, pixelCount);
}
/** Destructor for the LEDStrip Class
Deletes ledArray */
LEDStrip::~LEDStrip() {
clearData();
delete[] ledArray;
}
/** Assignment Operator for the LEDStrip Class
Because of the Arduino's requirement that pin numbers be defined at compile, if-else-if statements are used to permit passing of a pin as a parameter from the .ino file
@param stripIn The LEDStrip instance to be copied to the invoking LEDStrip instance */
LEDStrip &LEDStrip::operator=(const LEDStrip &stripIn) {
delete[] ledArray;
pixelCount = stripIn.pixelCount; // Save numLEDs to pixelCount
ledArray = new CRGB[pixelCount]; // Allocate new array of CRGB (pixels)
pin = stripIn.pin;
for (int i = 0; i < pixelCount; i++)
ledArray[i] = stripIn.ledArray[i];
if (pin == 0) FastLED.addLeds<NEOPIXEL, PIN0>(ledArray, pixelCount); // If pin == #, use PIN#
else if (pin == 1) FastLED.addLeds<NEOPIXEL, PIN1>(ledArray, pixelCount);
else if (pin == 2) FastLED.addLeds<NEOPIXEL, PIN2>(ledArray, pixelCount);
else if (pin == 3) FastLED.addLeds<NEOPIXEL, PIN3>(ledArray, pixelCount);
else if (pin == 4) FastLED.addLeds<NEOPIXEL, PIN4>(ledArray, pixelCount);
else if (pin == 5) FastLED.addLeds<NEOPIXEL, PIN5>(ledArray, pixelCount);
else if (pin == 6) FastLED.addLeds<NEOPIXEL, PIN6>(ledArray, pixelCount);
else if (pin == 7) FastLED.addLeds<NEOPIXEL, PIN7>(ledArray, pixelCount);
else if (pin == 8) FastLED.addLeds<NEOPIXEL, PIN8>(ledArray, pixelCount);
else if (pin == 9) FastLED.addLeds<NEOPIXEL, PIN9>(ledArray, pixelCount);
else if (pin == 10) FastLED.addLeds<NEOPIXEL, PIN10>(ledArray, pixelCount);
else if (pin == 11) FastLED.addLeds<NEOPIXEL, PIN11>(ledArray, pixelCount);
else if (pin == 12) FastLED.addLeds<NEOPIXEL, PIN12>(ledArray, pixelCount);
else if (pin == 13) FastLED.addLeds<NEOPIXEL, PIN13>(ledArray, pixelCount);
else if (pin == 14) FastLED.addLeds<NEOPIXEL, PIN14>(ledArray, pixelCount);
else if (pin == 15) FastLED.addLeds<NEOPIXEL, PIN15>(ledArray, pixelCount);
else if (pin == 16) FastLED.addLeds<NEOPIXEL, PIN16>(ledArray, pixelCount);
else if (pin == 17) FastLED.addLeds<NEOPIXEL, PIN17>(ledArray, pixelCount);
else if (pin == 18) FastLED.addLeds<NEOPIXEL, PIN18>(ledArray, pixelCount);
else if (pin == 19) FastLED.addLeds<NEOPIXEL, PIN19>(ledArray, pixelCount);
else if (pin == 20) FastLED.addLeds<NEOPIXEL, PIN20>(ledArray, pixelCount);
else if (pin == 21) FastLED.addLeds<NEOPIXEL, PIN21>(ledArray, pixelCount);
else if (pin == 22) FastLED.addLeds<NEOPIXEL, PIN22>(ledArray, pixelCount);
else if (pin == 23) FastLED.addLeds<NEOPIXEL, PIN23>(ledArray, pixelCount);
else if (pin == 24) FastLED.addLeds<NEOPIXEL, PIN24>(ledArray, pixelCount);
else if (pin == 25) FastLED.addLeds<NEOPIXEL, PIN25>(ledArray, pixelCount);
else if (pin == 26) FastLED.addLeds<NEOPIXEL, PIN26>(ledArray, pixelCount);
else if (pin == 27) FastLED.addLeds<NEOPIXEL, PIN27>(ledArray, pixelCount);
else if (pin == 28) FastLED.addLeds<NEOPIXEL, PIN28>(ledArray, pixelCount);
else if (pin == 29) FastLED.addLeds<NEOPIXEL, PIN29>(ledArray, pixelCount);
else if (pin == 30) FastLED.addLeds<NEOPIXEL, PIN30>(ledArray, pixelCount);
else if (pin == 31) FastLED.addLeds<NEOPIXEL, PIN31>(ledArray, pixelCount);
else if (pin == 32) FastLED.addLeds<NEOPIXEL, PIN32>(ledArray, pixelCount);
else if (pin == 33) FastLED.addLeds<NEOPIXEL, PIN33>(ledArray, pixelCount);
else if (pin == 34) FastLED.addLeds<NEOPIXEL, PIN34>(ledArray, pixelCount);
else if (pin == 35) FastLED.addLeds<NEOPIXEL, PIN35>(ledArray, pixelCount);
else if (pin == 36) FastLED.addLeds<NEOPIXEL, PIN36>(ledArray, pixelCount);
else if (pin == 37) FastLED.addLeds<NEOPIXEL, PIN37>(ledArray, pixelCount);
else if (pin == 38) FastLED.addLeds<NEOPIXEL, PIN38>(ledArray, pixelCount);
else if (pin == 39) FastLED.addLeds<NEOPIXEL, PIN39>(ledArray, pixelCount);
else if (pin == 40) FastLED.addLeds<NEOPIXEL, PIN40>(ledArray, pixelCount);
else if (pin == 41) FastLED.addLeds<NEOPIXEL, PIN41>(ledArray, pixelCount);
else if (pin == 42) FastLED.addLeds<NEOPIXEL, PIN42>(ledArray, pixelCount);
else if (pin == 43) FastLED.addLeds<NEOPIXEL, PIN43>(ledArray, pixelCount);
else if (pin == 44) FastLED.addLeds<NEOPIXEL, PIN44>(ledArray, pixelCount);
else if (pin == 45) FastLED.addLeds<NEOPIXEL, PIN45>(ledArray, pixelCount);
else if (pin == 46) FastLED.addLeds<NEOPIXEL, PIN46>(ledArray, pixelCount);
else if (pin == 47) FastLED.addLeds<NEOPIXEL, PIN47>(ledArray, pixelCount);
else if (pin == 48) FastLED.addLeds<NEOPIXEL, PIN48>(ledArray, pixelCount);
else if (pin == 49) FastLED.addLeds<NEOPIXEL, PIN49>(ledArray, pixelCount);
else if (pin == 50) FastLED.addLeds<NEOPIXEL, PIN50>(ledArray, pixelCount);
else if (pin == 51) FastLED.addLeds<NEOPIXEL, PIN51>(ledArray, pixelCount);
else if (pin == 52) FastLED.addLeds<NEOPIXEL, PIN52>(ledArray, pixelCount);
else if (pin == 53) FastLED.addLeds<NEOPIXEL, PIN53>(ledArray, pixelCount);
return *this;
}
/** Set Method for the LEDStrip Class
Sets the r, g, b values of all pixels in a strip to the color stored in a ColorContainer object
@param pixel The index of the pixel to be changed
@param colorValues The ColorContainer containing the desired color */
void LEDStrip::setPixelColor(int pixel, ColorContainer colorValues) {
ledArray[pixel] = CRGB(colorValues.getr(), colorValues.getg(), colorValues.getb());
return;
}
/** Overloaded Set Method for the LEDStrip Class
Sets the r, g, b values of a single pixel to the specified intensities
@param pixel The index of the pixel to be changed
@param rIn The value for the red LED
@param gIn The value for the green LED
@param bIn The value for the blue LED */
void LEDStrip::setPixelColor(int pixel, int rIn, int gIn, int bIn) {
ColorContainer temp(rIn, gIn, bIn);
setPixelColor(pixel, temp);
return;
}
/** Set Method for the LEDStrip Class
Sets the red value of a single pixel to the specified intensity
@param pixel The index of the pixel to be changed
@param rIn The value for the red LED */
void LEDStrip::setPixelRed(int pixel, int rIn) {
ledArray[pixel].red = rIn;
return;
}
/** Set Method for the LEDStrip Class
Sets the green value of a single pixel to the specified intensity
@param pixel The index of the pixel to be changed
@param gIn The value for the green LED */
void LEDStrip::setPixelGreen(int pixel, int gIn) {
ledArray[pixel].green = gIn;
return;
}
/** Set Method for the LEDStrip Class
Sets the blue value of a single pixel to the specified intensity
@param pixel The index of the pixel to be changed
@param bIn The value for the blue LED */
void LEDStrip::setPixelBlue(int pixel, int bIn) {
ledArray[pixel].blue = bIn;
return;
}
/** Set Method for the LEDStrip Class
Sets the r, g, b values of all pixels in a strip to the color stored in a ColorContainer object
@param colorValues The ColorContainer containing the desired color */
void LEDStrip::setStripColor(ColorContainer colorValues) {
fill_solid(ledArray, getPixelCount(), CRGB(colorValues.getr(), colorValues.getg(), colorValues.getb()));
return;
}
/** Overloaded Set Method for the LEDStrip Class
Sets the r, g, b values of all pixels in a strip to the specified intensities
@param rIn The intensity for the red values of the pixels
@param gIn The intensity for the green values of the pixels
@param bIn The intensity for the blue values of the pixels */
void LEDStrip::setStripColor(int rIn, int gIn, int bIn) {
ColorContainer temp(rIn, gIn, bIn);
setStripColor(temp);
return;
}
/** Set Method for the LEDStrip Class
Main fillLEDsFromPalette method
Fills a LED strip with colors from a specified color palette
@param palette The palette to be used (can be CRGBPalette16, CRGBPalette32, CRGBPalette256, CHSVPalette16, CHSVPalette32, CHSVPalette256, TProgmemRGBPalette16, TProgmemRGBPalette32, TProgmemHSVPalette16 or TProgmemHSVPalette32)
@param startIndex The offset in the color palette (used to make the animation 'move')
@param blend The blend type (LINEARBLEND or NOBLEND) to use
@param brightness The brightness of the LEDs */
template<class paletteType>
void
LEDStrip::fillLEDsFromPalette(const paletteType &palette, uint8_t startIndex, TBlendType blend, uint8_t brightness) {
for (int i = 0; i < getPixelCount(); i++) { // Loop through all pixels
ledArray[i] = ColorFromPalette(palette, startIndex, brightness, blend); // Set pixel to specified colors
startIndex += 3; // Move to next set of colors
}
return; // Return
}
/** Set Method for the LEDStrip Class
Fills a LED strip with colors from a specified RGB color palette
@param palette The CRGBPalette16 palette to be used
@param startIndex The offset in the color palette (used to make the animation 'move')
@param blend The blend type (LINEARBLEND or NOBLEND) to use (default LINEARBLEND)
@param brightness The brightness of the LEDs (default 255) */
void LEDStrip::fillLEDsFromPalette(const CRGBPalette16 &palette, uint8_t startIndex, TBlendType blend = LINEARBLEND,
uint8_t brightness = 255) {
fillLEDsFromPalette<CRGBPalette16>(palette, startIndex, blend,
brightness); // Call main fillLEDsFromPalette method
return; // Return
}
/** Set Method for the LEDStrip Class
Fills a LED strip with colors from a specified RGB color palette
@param palette The CRGBPalette32 palette to be used
@param startIndex The offset in the color palette (used to make the animation 'move')
@param blend The blend type (LINEARBLEND or NOBLEND) to use (default LINEARBLEND)
@param brightness The brightness of the LEDs (default 255) */
void LEDStrip::fillLEDsFromPalette(const CRGBPalette32 &palette, uint8_t startIndex, TBlendType blend = LINEARBLEND,
uint8_t brightness = 255) {
fillLEDsFromPalette<CRGBPalette32>(palette, startIndex, blend,
brightness); // Call main fillLEDsFromPalette method
return; // Return
}
/** Set Method for the LEDStrip Class
Fills a LED strip with colors from a specified RGB color palette
@param palette The CRGBPalette256 palette to be used
@param startIndex The offset in the color palette (used to make the animation 'move')
@param blend The blend type (LINEARBLEND or NOBLEND) to use (default LINEARBLEND)
@param brightness The brightness of the LEDs (default 255) */
void LEDStrip::fillLEDsFromPalette(const CRGBPalette256 &palette, uint8_t startIndex, TBlendType blend = LINEARBLEND,
uint8_t brightness = 255) {
fillLEDsFromPalette<CRGBPalette256>(palette, startIndex, blend,
brightness); // Call main fillLEDsFromPalette method
return; // Return
}
/** Set Method for the LEDStrip Class
Fills a LED strip with colors from a specified HSV color palette
@param palette The CHSVPalette16 palette to be used
@param startIndex The offset in the color palette (used to make the animation 'move')
@param blend The blend type (LINEARBLEND or NOBLEND) to use (default LINEARBLEND)
@param brightness The brightness of the LEDs (default 255) */
void LEDStrip::fillLEDsFromPalette(const CHSVPalette16 &palette, uint8_t startIndex, TBlendType blend = LINEARBLEND,
uint8_t brightness = 255) {
fillLEDsFromPalette<CHSVPalette16>(palette, startIndex, blend,
brightness); // Call main fillLEDsFromPalette method
return; // Return
}
/** Set Method for the LEDStrip Class
Fills a LED strip with colors from a specified HSV color palette
@param palette The CHSVPalette32 palette to be used
@param startIndex The offset in the color palette (used to make the animation 'move')
@param blend The blend type (LINEARBLEND or NOBLEND) to use (default LINEARBLEND)
@param brightness The brightness of the LEDs (default 255) */
void LEDStrip::fillLEDsFromPalette(const CHSVPalette32 &palette, uint8_t startIndex, TBlendType blend = LINEARBLEND,
uint8_t brightness = 255) {
fillLEDsFromPalette<CHSVPalette32>(palette, startIndex, blend,
brightness); // Call main fillLEDsFromPalette method
return; // Return
}
/** Set Method for the LEDStrip Class
Fills a LED strip with colors from a specified HSV color palette
@param palette The CHSVPalette256 palette to be used
@param startIndex The offset in the color palette (used to make the animation 'move')
@param blend The blend type (LINEARBLEND or NOBLEND) to use (default LINEARBLEND)
@param brightness The brightness of the LEDs (default 255) */
void LEDStrip::fillLEDsFromPalette(const CHSVPalette256 &palette, uint8_t startIndex, TBlendType blend = LINEARBLEND,
uint8_t brightness = 255) {
fillLEDsFromPalette<CHSVPalette256>(palette, startIndex, blend,
brightness); // Call main fillLEDsFromPalette method
return; // Return
}
/** Set Method for the LEDStrip Class
Fills a LED strip with colors from a specified color palette
@param palette The TprogmemRGBPalette16/TProgmemRGBPalette32/TProgmemHSVPalette16/TprogmemHSVPalette32 palette to be used
@param startIndex The offset in the color palette (used to make the animation 'move')
@param blend The blend type (LINEARBLEND or NOBLEND) to use (default LINEARBLEND)
@param brightness The brightness of the LEDs (default 255) */
void
LEDStrip::fillLEDsFromPalette(const TProgmemRGBPalette16 &palette, uint8_t startIndex, TBlendType blend = LINEARBLEND,
uint8_t brightness = 255) {
fillLEDsFromPalette<TProgmemRGBPalette16>(palette, startIndex, blend,
brightness); // Call main fillLEDsFromPalette method
return; // Return
}
/** Set Method for the LEDStrip Class
Fills a LED strip with colors that fade from colorValues1 at the beginning of the strip to colorValues2 at the end of the strip
@param colorValues1 The color at the beginning of the strip
@param colorValues2 The color at the end of the strip */
void LEDStrip::fillLEDsWithGradient(ColorContainer colorValues1, ColorContainer colorValues2) {
fill_gradient_RGB(ledArray, pixelCount, CRGB(colorValues1.getr(), colorValues1.getg(), colorValues1.getb()),
CRGB(colorValues2.getr(), colorValues2.getg(), colorValues2.getb()));
return;
}
/** Set Method for the LEDStrip Class
Fills a LED strip with colors that fade from colorValues1 at the beginning of the strip to colorValues2 at the middle of the strip to colorValues3 at the end of the strip
@param colorValues1 The color at the beginning of the strip
@param colorValues2 The color at the middle of the strip
@param colorValues3 The color at the end of the strip */
void
LEDStrip::fillLEDsWithGradient(ColorContainer colorValues1, ColorContainer colorValues2, ColorContainer colorValues3) {
fill_gradient_RGB(ledArray, pixelCount, CRGB(colorValues1.getr(), colorValues1.getg(), colorValues1.getb()),
CRGB(colorValues2.getr(), colorValues2.getg(), colorValues2.getb()),
CRGB(colorValues3.getr(), colorValues3.getg(), colorValues3.getb()));
return;
}
/** Set Method for the LEDStrip Class
Fills a LED strip with colors that fade from colorValues1 at the beginning of the strip to colorValues2 at the 1/3 point the strip to colorValues3 at the 2/3 point in the strip to colorValues4 at the end of the strip
@param colorValues1 The color at the beginning of the strip
@param colorValues2 The color at the 1/3 point in the strip
@param colorValues3 The color at the 2/3 point in the strip
@param colorValues4 The color at the end of the strip */
void
LEDStrip::fillLEDsWithGradient(ColorContainer colorValues1, ColorContainer colorValues2, ColorContainer colorValues3,
ColorContainer colorValues4) {
fill_gradient_RGB(ledArray, pixelCount, CRGB(colorValues1.getr(), colorValues1.getg(), colorValues1.getb()),
CRGB(colorValues2.getr(), colorValues2.getg(), colorValues2.getb()),
CRGB(colorValues3.getr(), colorValues3.getg(), colorValues3.getb()),
CRGB(colorValues4.getr(), colorValues4.getg(), colorValues4.getb()));
return;
}
/** Get Method for the pixelCount variable in the LEDStrip Class
Returns the number of pixels in a strip
@return pixelCount */
int LEDStrip::getPixelCount() { return pixelCount; }
/** Get Method for the color of a pixel in a LEDStrip instance
@param pixelIn The specified pixel
@return A ColorContainer containing the color of the specified pixel */
ColorContainer LEDStrip::getPixelColor(int pixelIn) {
return ColorContainer(ledArray[pixelIn].r, ledArray[pixelIn].g, ledArray[pixelIn].b);
}
/** Get Method for the red value of a pixel in a LEDStrip instance
@param pixelIn The specified pixel
@return The red value of the specified pixel */
int LEDStrip::getPixelRed(int pixelIn) { return ledArray[pixelIn].r; }
/** Get Method for the green value of a pixel in a LEDStrip instance
@param pixelIn The specified pixel
@return The green value of the specified pixel */
int LEDStrip::getPixelGreen(int pixelIn) { return ledArray[pixelIn].g; }
/** Get Method for the blue value of a pixel in a LEDStrip instance
@param pixelIn The specified pixel
@return The blue value of the specified pixel */
int LEDStrip::getPixelBlue(int pixelIn) { return ledArray[pixelIn].b; }