-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathledfacade.ino
61 lines (54 loc) · 1.16 KB
/
ledfacade.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
/**
* All led strips
*/
uint16_t num_pixels = 30;
Adafruit_NeoPixel lb_strip = Adafruit_NeoPixel(
num_pixels,
PIN_STRIP_LEFT_BOTTOM,
NEO_GRB + NEO_KHZ800
);
Adafruit_NeoPixel rb_strip = Adafruit_NeoPixel(
num_pixels,
PIN_STRIP_RIGHT_BOTTOM,
NEO_GRB + NEO_KHZ800
);
Adafruit_NeoPixel lt_strip = Adafruit_NeoPixel(
num_pixels,
PIN_STRIP_LEFT_TOP,
NEO_GRB + NEO_KHZ800
);
Adafruit_NeoPixel rt_strip = Adafruit_NeoPixel(
num_pixels,
PIN_STRIP_RIGHT_TOP,
NEO_GRB + NEO_KHZ800
);
Adafruit_NeoPixel strips[] = {
lb_strip, rb_strip, lt_strip, rt_strip
};
void LedFacade::setPixelColor(uint16_t x, uint16_t y, uint32_t color) {
Adafruit_NeoPixel* strip = <_strip;
if(x==0) {
strip = y>30 ? <_strip : &lb_strip;
} else {
strip = y>30 ? &rt_strip : &rb_strip;
}
strip->setPixelColor(y>30 ? y-30 : y, color);
}
void LedFacade::show() {
for(int i=0;i<4;i++) {
strips[i].show();
}
}
void LedFacade::begin() {
for(int i=0;i<4;i++) {
strips[i].begin();
}
}
void LedFacade::all(uint32_t color) {
for(int i=0;i<4;i++) {
for(uint16_t j=0;j<num_pixels;j++) {
strips[i].setPixelColor(j, color);
}
}
this->show();
}