-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsequence_startup.ino
273 lines (217 loc) · 7.21 KB
/
sequence_startup.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
/*
* https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#LEDStripEffectSparkle
*/
void sequence_BLACK() {
for ( int i=0; i<pref_num_leds; i++ ) {
leds[i] = CRGB( 0, 0, 0 );
}
}
void sequence_WIFI_SmartConfig() {
// All LED's are RED
// Every 2nd LED is bright
for ( int i=0; i<pref_num_leds; i=i+3 ) {
leds[i] = CRGB( 255,0,0);
leds[i+1] = CRGB( 0,255,0);
leds[i+2] = CRGB( 0,0,255);
}
}
void sequence_WIFI_Connecting() {
// All LED's are RED
// Every 2nd LED is bright
for ( int i=0; i<pref_num_leds; i++ ) {
leds[i] = CRGB( 0, 50 + (i%2==0?200:0 ) , 0 );
}
}
void sequence_ARTNET_Starting() {
// All LED's are BLUE
// Every 2nd LED is bright
for ( int i=0; i<pref_num_leds; i++ ) {
leds[i] = CRGB( 50 + (i%2==0?200:0 ) , 0, 0 );
}
}
void sequence_WebServer_Starting() {
// All LED's are GREEN
// Every 2nd LED is bright
for ( int i=0; i<pref_num_leds; i++ ) {
leds[i] = CRGB( 0, 0, 50 + (i%2==0?200:0 ));
}
}
void sequence_config_mode(){
// Everything black, except start and end LED's
for ( int i=0; i<pref_num_leds; i++ ) {
leds[i] = CRGB( 0,0,0 );
if ( i == pref_led_first or i == pref_led_last) {
leds[i] = CRGB( 255,255,255 );
}
}
}
void sequence_startup(){
// Startup Sequence
for ( int i=0; i<(pref_num_leds + 6); i++ ) {
//Green
if ( i < pref_num_leds )
leds[i] = CRGB( 20 ,20, 0);
//Red
if ( i-1 >= 0 && i-1 < pref_num_leds ) {
leds[i-1] = CRGB( 0,255,0);
}
//Green
if ( i-2 >= 0 && i-2 < pref_num_leds) {
leds[i-2] = CRGB( 255,0,0);
}
if ( i-3 >= 0 && i-3 < pref_num_leds) {
//Blue
leds[i-3] = CRGB( 0,0,255);
}
if ( i-4 >= 0 && i-4 < pref_num_leds) {
//Blue
leds[i-4] = CRGB( 0,0,50);
}
if ( i-5 >= 0 && i-5 < pref_num_leds) {
// Off
leds[i-5] = CRGB( 0,0,0);
}
FastLED.show();
delay(15);
}
}
void sequence_startup_pos( int i ){
// Startup Sequence
//for ( int i=0; i<(pref_num_leds + 6); i++ ) {
//Green
if ( i < pref_num_leds )
leds[i] = CRGB( 20 ,20, 0);
//Red
if ( i-1 >= 0 && i-1 < pref_num_leds ) {
leds[i-1] = CRGB( 0,255,0);
}
//Green
if ( i-2 >= 0 && i-2 < pref_num_leds) {
leds[i-2] = CRGB( 255,0,0);
}
if ( i-3 >= 0 && i-3 < pref_num_leds) {
//Blue
leds[i-3] = CRGB( 0,0,255);
}
if ( i-4 >= 0 && i-4 < pref_num_leds) {
//Blue
leds[i-4] = CRGB( 0,0,50);
}
if ( i-5 >= 0 && i-5 < pref_num_leds) {
// Off
leds[i-5] = CRGB( 0,0,0);
}
FastLED.show();
//delay(15);
//}
}
int LastStrobeSpeedA;
int LastStrobeSpeedB;
void sequende_RGB( int R, int G, int B, int StrobeSpeedA, int StrobeSpeedB ){
// RGB Mode
// if Strobe speed changes, reset the interval
if (( StrobeSpeedA != LastStrobeSpeedA ) || ( StrobeSpeedB != LastStrobeSpeedB )) {
last_chase_millis = millis()+20;
}
LastStrobeSpeedA = StrobeSpeedA;
LastStrobeSpeedB = StrobeSpeedB;
if ( StrobeSpeedA==0 && StrobeSpeedB==0 ) {
startIndex = 1;
last_chase_millis = millis();
} else {
// Map 0-255 as BPM... into MS
unsigned int RGB_Millis = ( 60000/(StrobeSpeedA+(StrobeSpeedB*5)) / 2 ); // /2 for on/off cycle
if ( millis() >= last_chase_millis ) {
startIndex ++;
last_chase_millis = millis() + RGB_Millis;
}
}
// Paint RGB or Black, depending on if startindex is odd or even
if ( startIndex%2 == 0 ) {
for ( int i=0; i<pref_num_leds; i++ ) {
leds[i] = CRGB( 0,0,0 );
}
} else {
for ( int i=0; i<pref_num_leds; i++ ) {
leds[i] = CRGB( R, G, B );
}
}
}
void sequence_pallet( int palette, int speed ){
unsigned int increment;
// Below 126
if ( speed < 126 ) {
millis_per_chase = map( speed, 0, 126, 3, 150 );
increment = +1;
// Stationary
} else if (( speed >= 126 ) && ( speed <= 130 )) {
millis_per_chase = 0;
increment = 0;
// Above 130
} else if ( speed > 130 ) {
millis_per_chase = map( speed, 131, 255, 150, 3 );
increment = -1;
}
if( palette < 23) { currentPalette = RainbowColors_p; currentBlending = LINEARBLEND; }
else if( palette < 46) { currentPalette = RainbowStripeColors_p; currentBlending = NOBLEND; }
else if( palette < 69) { currentPalette = RainbowStripeColors_p; currentBlending = LINEARBLEND; }
else if( palette < 92) { SetupPurpleAndGreenPalette(); currentBlending = LINEARBLEND; }
else if( palette < 115) { SetupTotallyRandomPalette(); currentBlending = LINEARBLEND; }
else if( palette < 138) { SetupBlackAndWhiteStripedPalette(); currentBlending = NOBLEND; }
else if( palette < 161) { SetupBlackAndWhiteStripedPalette(); currentBlending = LINEARBLEND; }
else if( palette < 184) { currentPalette = CloudColors_p; currentBlending = LINEARBLEND; }
else if( palette < 207) { currentPalette = PartyColors_p; currentBlending = LINEARBLEND; }
else if( palette < 230) { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND; }
else { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }
// Perform Chase here and re-fill LED's
if ( millis() > (last_chase_millis + millis_per_chase) ) {
if ( increment != 0 ) {
startIndex = startIndex + increment;
FillLEDsFromPaletteColors( startIndex );
}
last_chase_millis = millis();
}
}
void sequence_glitter( int star_count, int fade, int R, int G, int B){
// https://gist.github.com/mock-turtle/d59716ab96dca6c8ec0b
//changing the third variable changes how quickly the lights fade
fadeToBlackBy( leds, pref_num_leds, map( fade, 0, 255, 0, 100 ) );
//changing this variable will increase the chance of a "star" popping up
// addGlitter( star_count );
if( random8() < star_count) {
if ( R==0 && G==0 && B==0 ) {
leds[ random16(pref_num_leds) ] += CRGB( random16(255), random16(255), random16(255) );
} else {
leds[ random16(pref_num_leds) ] += CRGB( B, R, G ); //CRGB::White;
}
}
}
byte heat[1024];
void sequence_fire(int Cooling, int Sparking, int SpeedDelay) {
int cooldown;
// Step 1. Cool down every cell a little
for( int i = 0; i < pref_num_leds; i++) {
cooldown = random(0, ((Cooling * 10) / pref_num_leds) + 2);
if(cooldown>heat[i]) {
heat[i]=0;
} else {
heat[i]=heat[i]-cooldown;
}
}
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for( int k= pref_num_leds - 1; k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;
}
// Step 3. Randomly ignite new 'sparks' near the bottom
if( random(255) < Sparking ) {
int y = random(7);
heat[y] = heat[y] + random(160,255);
//heat[y] = random(160,255);
}
// Step 4. Convert heat to LED colors
for( int j = 0; j < pref_num_leds; j++) {
setPixelHeatColor(j, heat[j] );
}
//showStrip();
delay(SpeedDelay);
}