-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplayFunctions.ino
90 lines (81 loc) · 2.26 KB
/
displayFunctions.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
// WORD CLOCK - for ESP32
void initializeLEDs(){
delay(1000); // power-up safety delay
FastLED.addLeds<LED_TYPE, NEOPIN>(leds, NUM_LEDS);
FastLED.setBrightness(_DAYBRIGHTNESS);
FastLED.clear(); // Initialize all pixels to 'off'
FastLED.show();
}
void clearMask() {
for (int i = 0; i < NUM_MAP; i++) {
mask[i] = 0;
}
}
void xsetMask(uint8_t word[],uint8_t len,uint8_t sw) {
//len = sizeof(word)/sizeof(word[0]);
for (int i = 0; i < len; i++) {
mask[LED[word[i]]] = sw;
}
}
// show colorshift through the phrase mask. for each NeoPixel either show a color or show nothing!
void applyMask() {
for (int i = 0; i < NUM_MAP; i++) {
if (mask[LED[i]] == 0) {
leds[LED[i]] = CRGB( 0, 0, 0);
} else {
if (colormode == "Rainbow") {
leds[LED[i]]=CRGB(col(i+r_count),col(i+r_count+256),col(i+r_count+512));
continue;
}
if (colormode == "RGB") {
leds[LED[i]]=CRGB(colorG,colorR,colorB);
continue;
}
leds[LED[i]]=CRGB(_COLORG,_COLORR,_COLORB);
}
}
FastLED.show(); // show it!
clearMask(); // reset mask for next time
if (colormode == "Rainbow") {
if ((millis()-r_millis) > interval) {
r_count = (r_count+1) % 768; //(256 * 8);
r_millis = millis();
}
}
}
// change brightness
void adjustBrightness(int hour) {
//set the daytime brightness
if (morningcutoff < nightcutoff) {
if(hour>=morningcutoff && hour<nightcutoff) {
FastLED.setBrightness(daybrightness); //day time
return;
}
} else {
if(hour>=morningcutoff || hour<=nightcutoff) {
FastLED.setBrightness(daybrightness); //day time
return;
}
}
//set the nighttime brightness
FastLED.setBrightness(nightbrightness);
}
// Lights all LEDs in rainbow colors
void rainbowCycle() {
FastLED.setBrightness(ALLLED_BRIGHTNESS);
int cycles = 7; // 7 cycles of all colors on wheel
for (int j = 0; j < 256 * cycles; j++) {
for (int i = 0; i < NUM_MAP; i++) {
leds[LED[i]] = CRGB(col(i+j),col(i+j+256),col(i+j+512));
}
FastLED.show(); // show it!
delay(2);
}
}
// Input a value 0 to 767 to get a color value.
int col(int pos) {
pos = pos % 768;
if ( pos <= 255) return(pos);
if ( pos >= 512) return(0);
return(255-(pos-256));
}