-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUTILITY_FXNS.ino
74 lines (67 loc) · 1.47 KB
/
UTILITY_FXNS.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
//------------------------------------- UTILITY FXNS --------------------------------------
//---SET THE COLOR OF A SINGLE RGB LED
void set_color_led(int adex, int cred, int cgrn, int cblu) {
leds[adex].setRGB( cred, cgrn, cblu);
}
//---FIND INDEX OF HORIZONAL OPPOSITE LED
int horizontal_index(int i) {
//-ONLY WORKS WITH INDEX < TOPINDEX
if (i == BOTTOM_INDEX) {
return BOTTOM_INDEX;
}
if (i == TOP_INDEX && EVENODD == 1) {
return TOP_INDEX + 1;
}
if (i == TOP_INDEX && EVENODD == 0) {
return TOP_INDEX;
}
return LED_COUNT - i;
}
//---FIND INDEX OF ANTIPODAL OPPOSITE LED
int antipodal_index(int i) {
int iN = i + TOP_INDEX;
if (i >= TOP_INDEX) {
iN = ( i + TOP_INDEX ) % LED_COUNT;
}
return iN;
}
//---FIND ADJACENT INDEX CLOCKWISE
int adjacent_cw(int i) {
int r;
if (i < LED_COUNT - 1) {
r = i + 1;
}
else {
r = 0;
}
return r;
}
//---FIND ADJACENT INDEX COUNTER-CLOCKWISE
int adjacent_ccw(int i) {
int r;
if (i > 0) {
r = i - 1;
}
else {
r = LED_COUNT - 1;
}
return r;
}
void copy_led_array() {
for (int i = 0; i < LED_COUNT; i++ ) {
ledsX[i][0] = leds[i].r;
ledsX[i][1] = leds[i].g;
ledsX[i][2] = leds[i].b;
}
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
}
void setAll(byte red, byte green, byte blue) {
for (int i = 0; i < LED_COUNT; i++ ) {
setPixel(i, red, green, blue);
}
FastLED.show();
}