-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLights.cpp
More file actions
616 lines (530 loc) · 23.7 KB
/
Lights.cpp
File metadata and controls
616 lines (530 loc) · 23.7 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
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
/*
* Lights.cpp
*
* A class to control light signal decoder
*
*/
#include <NmraDcc.h>
#include "Lights.h"
#include "defines.h"
void Lights::init(NmraDcc Dcc, byte* outputs)
{
this->state = TT_IDLE;
memset(this->commandQueue, TT_MOVER_SLOT_EMPTY, TT_MOVER_MAX_TRACKS + 1);
for (byte i=0; i < MAXACCESSORIES; i++)
{
#ifdef DEBUG_MSG_LIGHTS
Serial.print("CV: ");Serial.print(CV_BASE_NUMBER + 0 + i * NUMBER_OF_CVS);
Serial.print(" value: ");Serial.println(Dcc.getCV(CV_BASE_NUMBER + 0 + i * NUMBER_OF_CVS));
Serial.print("mode: ");Serial.println(Dcc.getCV(CV_BASE_NUMBER + 0 + i * NUMBER_OF_CVS) >> 4 & 0x0F);
Serial.print("outputpin: ");Serial.println(Dcc.getCV(CV_BASE_NUMBER + 0 + i * NUMBER_OF_CVS) & 0x0F);
#endif
accessory[i].mode1 = Dcc.getCV(CV_BASE_NUMBER + 0 + i * NUMBER_OF_CVS) >> 4 & 0xF0; // outputPin1 mode
accessory[i].mode2 = Dcc.getCV(CV_BASE_NUMBER + 1 + i * NUMBER_OF_CVS) >> 4 & 0xF0; // outputPin2 mode
accessory[i].mode3 = Dcc.getCV(CV_BASE_NUMBER + 2 + i * NUMBER_OF_CVS) >> 4 & 0xF0; // outputPin3 mode
accessory[i].mode4 = Dcc.getCV(CV_BASE_NUMBER + 3 + i * NUMBER_OF_CVS) >> 4 & 0xF0; // outputPin3 mode
accessory[i].outputPin1 = outputs[int(Dcc.getCV(CV_BASE_NUMBER + 0 + i * NUMBER_OF_CVS) & 0x0F)]; // output pin 1 for signals
accessory[i].outputPin2 = outputs[int(Dcc.getCV(CV_BASE_NUMBER + 1 + i * NUMBER_OF_CVS) & 0x0F)]; // output pin 2 for signals
accessory[i].outputPin3 = (Dcc.getCV(CV_BASE_NUMBER + 2 + i * NUMBER_OF_CVS) & 0x0F) ? 0 : outputs[int(Dcc.getCV(CV_BASE_NUMBER + 2 + i * NUMBER_OF_CVS) & 0x0F)]; // output pin 3 for signals
accessory[i].outputPin4 = (Dcc.getCV(CV_BASE_NUMBER + 3 + i * NUMBER_OF_CVS) & 0x0F) ? 0 : outputs[int(Dcc.getCV(CV_BASE_NUMBER + 3 + i * NUMBER_OF_CVS) & 0x0F)]; // output pin 3 for signals
accessory[i].ontime = Dcc.getCV(CV_BASE_NUMBER + 4 + i * NUMBER_OF_CVS); // ontime
accessory[i].ontimeX = Dcc.getCV(CV_BASE_NUMBER + 5 + i * NUMBER_OF_CVS); // ontime multiplier
accessory[i].offtime = Dcc.getCV(CV_BASE_NUMBER + 6 + i * NUMBER_OF_CVS); // offtime
accessory[i].offtimeX = Dcc.getCV(CV_BASE_NUMBER + 7 + i * NUMBER_OF_CVS); // offtime multiplier
accessory[i].fadein = Dcc.getCV(CV_BASE_NUMBER + 8 + i * NUMBER_OF_CVS); // fade in time for fader
accessory[i].fadeout = Dcc.getCV(CV_BASE_NUMBER + 9 + i * NUMBER_OF_CVS); // fade out time for fader
#ifdef DEBUG_MSG_LIGHTS
Serial.print("accessory: ");Serial.print(i);Serial.print(" mode1: ");Serial.print(accessory[i].mode1);
Serial.print(" outputPin1: ");Serial.println(accessory[i].outputPin1);
#endif
accessory[i].dccstate = 0; // Internal use. DCC state of accessory: 1=on, 0=off
accessory[i].onoff = 0; // Internal use. Output state of accessory: 1=on, 0=off
accessory[i].onMilli = 0; // Internal use.
accessory[i].offMilli = 0; // Internal use.
accessory[i].fade = 0; // Internal use. Output state of accessory: 1=on, 0=off
pinMode(accessory[i].outputPin1, OUTPUT);
digitalWrite(accessory[i].outputPin1, LOW);
pinMode(accessory[i].outputPin2, OUTPUT);
digitalWrite(accessory[i].outputPin2, LOW);
if(accessory[i].outputPin3 != 0)
{
pinMode(accessory[i].outputPin3, OUTPUT);
digitalWrite(accessory[i].outputPin3, LOW);
}
if(accessory[i].outputPin4 != 0)
{
pinMode(accessory[i].outputPin4, OUTPUT);
digitalWrite(accessory[i].outputPin4, LOW);
}
}
}
void Lights::addCommand(uint8_t command)
{
for(uint8_t i = 0; i < TT_MOVER_MAX_TRACKS; i++)
{
if(this->commandQueue[i] == command)
{
return;
}
else if(commandQueue[i] == TT_MOVER_SLOT_EMPTY)
{
this->commandQueue[i] = command;
this->process();
return;
}
}
return;
}
void Lights::process(void)
{
if ( this->commandQueue[0] != TT_MOVER_SLOT_EMPTY )
{
this->thisCommand = this->commandQueue[0];
this->state = TT_MOVE;
#ifdef DEBUG_MSG_LIGHTS_1
Serial.print("Process 1: commandQueue 0 = ");Serial.println(this->commandQueue[0], DEC);
Serial.print("Process 1: state = ");Serial.println(this->state);
#endif
}
/*
* this starts and stops the applicable mode depending on the state of accessory[target].dccstate
* for each mode there will be a #ifdef ACTION_ #endif section
*
*/
if ( this->state == TT_MOVE )
{
this->target = byte( this->thisCommand / COMMAND_OFFSET);
this->direction = ( ( this->thisCommand ) - ( this->target * COMMAND_OFFSET ) - 1);
#ifdef DEBUG_MSG_LIGHTS_2
if(this->direction != 18)
{
// Serial.print("thisCommand = ");Serial.println(this->thisCommand);
Serial.print("Process 2: target = ");Serial.println(this->target);
Serial.print("Process 2: direction = ");Serial.println(this->direction);
Serial.println();
Serial.print("Process 2: mode1 = ");Serial.println(accessory[this->target].mode1);
Serial.print("Process 2: outputPin1 = ");Serial.println(accessory[this->target].outputPin1);
Serial.print("Process 2: mode2 = ");Serial.println(accessory[this->target].mode2);
Serial.print("Process 2: outputPin2 = ");Serial.println(accessory[this->target].outputPin2);
Serial.println();
}
#endif
switch (this->direction)
{
case 0: // aspect 0 red signal
#ifdef DEBUG_MSG_LIGHTS_3
// Serial.print("thisCommand = ");Serial.println(this->thisCommand);
Serial.print("Process 3: target = ");Serial.println(this->target);
Serial.print("Process 3: direction = ");Serial.println(this->direction);
Serial.print("outputPin1: "); Serial.println(accessory[this->target].outputPin1);
Serial.print("outputPin2: "); Serial.println(accessory[this->target].outputPin2);
Serial.println();
#endif
// switch (accessory[this->target].mode1)
// {
// case 0: // on/off
digitalWrite(accessory[this->target].outputPin1, LOW);
digitalWrite(accessory[this->target].outputPin2, HIGH);
if (accessory[this->target].outputPin3 != 0)
{
digitalWrite(accessory[this->target].outputPin3, LOW);
}
if (accessory[this->target].outputPin4 != 0)
{
digitalWrite(accessory[this->target].outputPin4, LOW);
}
accessory[this->target].dccstate = 0;
accessory[this->target].onoff = 1;
this->state = TT_STOP;
// break;
// }
break;
case 1: // aspect 1 green signal
#ifdef DEBUG_MSG_LIGHTS_3
// Serial.print("thisCommand = ");Serial.println(this->thisCommand);
Serial.print("Process 3: target = ");Serial.println(this->target);
Serial.print("Process 3: direction = ");Serial.println(this->direction);
Serial.print("outputPin1: "); Serial.println(accessory[this->target].outputPin1);
Serial.print("outputPin2: "); Serial.println(accessory[this->target].outputPin2);
Serial.println();
#endif
// switch (accessory[this->target].mode1)
// {
// case 0:
digitalWrite(accessory[this->target].outputPin1, HIGH);
digitalWrite(accessory[this->target].outputPin2, LOW);
if (accessory[this->target].outputPin3 != 0)
{
digitalWrite(accessory[this->target].outputPin3, LOW);
}
if (accessory[this->target].outputPin4 != 0)
{
digitalWrite(accessory[this->target].outputPin4, LOW);
}
accessory[this->target].dccstate = 1;
accessory[this->target].onoff = 1;
this->state = TT_STOP;
// break;
// }
break;
case 2: // aspect 2 amber signal
digitalWrite(accessory[this->target].outputPin1, LOW);
digitalWrite(accessory[this->target].outputPin2, LOW);
if (accessory[this->target].outputPin3 != 0)
{
digitalWrite(accessory[this->target].outputPin3, HIGH);
}
if (accessory[this->target].outputPin4 != 0)
{
digitalWrite(accessory[this->target].outputPin4, LOW);
}
accessory[this->target].dccstate = 2;
accessory[this->target].onoff = 1;
this->state = TT_STOP;
break;
case 3: // aspect 3 amber amber
digitalWrite(accessory[this->target].outputPin1, LOW);
digitalWrite(accessory[this->target].outputPin2, LOW);
if (accessory[this->target].outputPin3 != 0)
{
digitalWrite(accessory[this->target].outputPin3, HIGH);
}
if (accessory[this->target].outputPin4 != 0)
{
digitalWrite(accessory[this->target].outputPin4, HIGH);
}
accessory[this->target].dccstate = 3;
accessory[this->target].onoff = 1;
this->state = TT_STOP;
break;
case 4: // aspect 4 flashing red
digitalWrite(accessory[this->target].outputPin1, LOW);
digitalWrite(accessory[this->target].outputPin2, HIGH);
accessory[this->target].offMilli = millis() + (accessory[this->target].ontime * accessory[this->target].ontimeX);
if (accessory[this->target].outputPin3 != 0)
{
digitalWrite(accessory[this->target].outputPin3, LOW);
}
if (accessory[this->target].outputPin4 != 0)
{
digitalWrite(accessory[this->target].outputPin4, LOW);
}
accessory[this->target].dccstate = 4;
accessory[this->target].onoff = 1;
this->state = TT_STOP;
break;
case 5: // aspect 5 flashing green
digitalWrite(accessory[this->target].outputPin1, HIGH);
digitalWrite(accessory[this->target].outputPin2, LOW);
if (accessory[this->target].outputPin3 != 0)
{
digitalWrite(accessory[this->target].outputPin3, LOW);
}
if (accessory[this->target].outputPin4 != 0)
{
digitalWrite(accessory[this->target].outputPin4, LOW);
}
accessory[this->target].dccstate = 5;
accessory[this->target].onoff = 1;
this->state = TT_STOP;
break;
case 6: // aspect 6 flashing amber
digitalWrite(accessory[this->target].outputPin1, LOW);
digitalWrite(accessory[this->target].outputPin2, LOW);
if (accessory[this->target].outputPin3 != 0)
{
digitalWrite(accessory[this->target].outputPin3, HIGH);
}
if (accessory[this->target].outputPin4 != 0)
{
digitalWrite(accessory[this->target].outputPin4, LOW);
}
accessory[this->target].dccstate = 6;
accessory[this->target].onoff = 1;
this->state = TT_STOP;
break;
case 7: // aspect 7 alternate flash
accessory[this->target].offMilli = millis() + (accessory[this->target].ontime * accessory[this->target].ontimeX);
digitalWrite(accessory[this->target].outputPin1, HIGH);
digitalWrite(accessory[this->target].outputPin2, LOW);
accessory[this->target].dccstate = 7;
accessory[this->target].onoff = 1;
this->state = TT_STOP;
break;
case 8: // aspect 8 alternate flash fade
#ifdef DEBUG_MSG_LIGHTS_3
// Serial.print("thisCommand = ");Serial.println(this->thisCommand);
Serial.print("Process 3: target = ");Serial.println(this->target);
Serial.print("Process 3: direction = ");Serial.println(this->direction);
Serial.print("outputPin1: "); Serial.println(accessory[this->target].outputPin1);
Serial.print("outputPin2: "); Serial.println(accessory[this->target].outputPin2);
Serial.println();
#endif
accessory[this->target].offMilli = millis() + (accessory[this->target].ontime * accessory[this->target].ontimeX);
accessory[this->target].dccstate = 8;
accessory[this->target].onoff = 1;
accessory[this->target].fade = 0;
analogWrite(accessory[this->target].outputPin1, accessory[this->target].fade);
analogWrite(accessory[this->target].outputPin2, 255 - accessory[this->target].fade);
this->state = TT_STOP;
break;
case 9: // aspect 9 double strobe
#ifdef DEBUG_MSG_LIGHTS_9
// Serial.print("thisCommand = ");Serial.println(this->thisCommand);
Serial.print("Process 9: target = ");Serial.println(this->target);
Serial.print("Process 9: direction = ");Serial.println(this->direction);
Serial.print("Process 9: outputPin1 = ");Serial.println(accessory[this->target].outputPin1);
Serial.println();
#endif
accessory[this->target].offMilli = millis() + (accessory[this->target].ontime * accessory[this->target].ontimeX);
this->strobe(accessory[this->target].outputPin1);
delay(100);
this->strobe(accessory[this->target].outputPin1);
accessory[this->target].dccstate = 9;
accessory[this->target].onoff = 0;
this->state = TT_STOP;
break;
case 10: // aspect 10 single strobe
#ifdef DEBUG_MSG_LIGHTS_10
// Serial.print("thisCommand = ");Serial.println(this->thisCommand);
Serial.print("Process 9: target = ");Serial.println(this->target);
Serial.print("Process 9: direction = ");Serial.println(this->direction);
Serial.print("Process 9: outputPin1 = ");Serial.println(accessory[this->target].outputPin1);
Serial.println();
#endif
accessory[this->target].offMilli = millis() + (accessory[this->target].ontime * accessory[this->target].ontimeX);
this->strobe(accessory[this->target].outputPin1);
accessory[this->target].dccstate = 10;
accessory[this->target].onoff = 0;
this->state = TT_STOP;
break;
case 11:
break;
case 31: // aspect dark (31)
digitalWrite(accessory[this->target].outputPin1, LOW);
digitalWrite(accessory[this->target].outputPin2, LOW);
if (accessory[this->target].outputPin3 != 0)
{
digitalWrite(accessory[this->target].outputPin3, LOW);
}
if (accessory[this->target].outputPin4 != 0)
{
digitalWrite(accessory[this->target].outputPin4, LOW);
}
accessory[this->target].dccstate = 18;
accessory[this->target].onoff = 0;
this->state = TT_STOP;
break;
default:
this->state = TT_STOP;
break;
}
}
/*
* this alters the output depending on aspect, time and dccstate
*
* only aspects > 3 are processed as they are flashing etc
*
*/
for ( int i = 0; i < MAXACCESSORIES; i++)
{
if ((accessory[i].dccstate > 3) && (accessory[i].dccstate != 18))
{
#ifdef DEBUG_MSG_LIGHTS
Serial.print("onMilli = ");Serial.println(accessory[i].onMilli);
Serial.print("offMilli = ");Serial.println(accessory[i].offMilli);
Serial.print("millis = ");Serial.println(millis());
#endif
switch (accessory[i].dccstate)
{
case 4: // aspect 4 flashing red
if (accessory[i].onoff && millis() > accessory[i].offMilli)
{
digitalWrite(accessory[i].outputPin2, LOW);
accessory[i].onMilli = millis() + (accessory[i].offtime * accessory[i].offtimeX);
accessory[i].onoff = 0;
this->state = TT_STOP;
}
else
{
if (!accessory[i].onoff && millis() > accessory[i].onMilli)
{
digitalWrite(accessory[i].outputPin2, HIGH);
accessory[i].offMilli = millis() + (accessory[i].ontime * accessory[i].ontimeX);
accessory[i].onoff = 1;
this->state = TT_STOP;
}
}
break;
case 5: // aspect 5 flashing green
if (accessory[i].onoff && millis() > accessory[i].offMilli)
{
digitalWrite(accessory[i].outputPin1, LOW);
accessory[i].onMilli = millis() + (accessory[i].offtime * accessory[i].offtimeX);
accessory[i].onoff = 0;
this->state = TT_STOP;
}
else
{
if (!accessory[i].onoff && millis() > accessory[i].onMilli)
{
digitalWrite(accessory[i].outputPin1, HIGH);
accessory[i].offMilli = millis() + (accessory[i].ontime * accessory[i].ontimeX);
accessory[i].onoff = 1;
this->state = TT_STOP;
}
}
break;
case 6: // aspect 6 flashing amber
if (accessory[i].onoff && millis() > accessory[i].offMilli)
{
if(accessory[i].outputPin3 != 0)
{
digitalWrite(accessory[i].outputPin3, LOW);
}
accessory[i].onMilli = millis() + (accessory[i].offtime * accessory[i].offtimeX);
accessory[i].onoff = 0;
this->state = TT_STOP;
}
else
{
if (!accessory[i].onoff && millis() > accessory[i].onMilli)
{
if(accessory[i].outputPin3 != 0)
{
digitalWrite(accessory[i].outputPin3, HIGH);
}
accessory[i].offMilli = millis() + (accessory[i].ontime * accessory[i].ontimeX);
accessory[i].onoff = 1;
this->state = TT_STOP;
}
}
break;
case 7: // flashing alternate
if (accessory[i].onoff && millis() > accessory[i].offMilli)
{
digitalWrite(accessory[i].outputPin1, LOW);
digitalWrite(accessory[i].outputPin2, HIGH);
accessory[i].onMilli = millis() + (accessory[i].offtime * accessory[i].offtimeX);
accessory[i].onoff = 0;
this->state = TT_STOP;
}
else
{
if (!accessory[i].onoff && millis() > accessory[i].onMilli)
{
digitalWrite(accessory[i].outputPin1, HIGH);
digitalWrite(accessory[i].outputPin2, LOW);
accessory[i].offMilli = millis() + (accessory[i].ontime * accessory[i].ontimeX);
accessory[i].onoff = 1;
this->state = TT_STOP;
}
}
break;
case 8: // alternate flash fader
#ifdef DEBUG_MSG_LIGHTS_8
Serial.println("Flashing");
#endif
if ( (accessory[i].onoff) && (millis() > accessory[i].offMilli) )
{
if ( accessory[i].fade <= 255 )
{
if ( millis() > accessory[i].offMilli + accessory[i].fadein )
{
analogWrite(accessory[i].outputPin1, accessory[i].fade);
analogWrite(accessory[i].outputPin2, 255 - accessory[i].fade);
accessory[i].offMilli += accessory[i].fadein;
accessory[i].fade += 5;
}
}
else
{
accessory[i].onMilli = millis() + (accessory[i].offtime * accessory[i].offtimeX);
accessory[i].onoff = 0;
accessory[i].fade = 255;
this->state = TT_STOP;
}
}
else
{
if ( (!accessory[i].onoff) && (millis() > accessory[i].onMilli))
{
if ( accessory[i].fade >= 0 )
{
if ( millis() > accessory[i].onMilli + accessory[i].fadeout )
{
analogWrite(accessory[i].outputPin1, accessory[i].fade);
analogWrite(accessory[i].outputPin2, 255 - accessory[i].fade);
accessory[i].onMilli += accessory[i].fadeout;
accessory[i].fade -= 5;
}
}
else
{
accessory[i].offMilli = millis() + (accessory[i].ontime * accessory[i].ontimeX);
accessory[i].onoff = 1;
accessory[i].fade = 0;
this->state = TT_STOP;
}
}
}
break;
case 9: // strobe double
if (accessory[i].onoff && millis() > accessory[i].offMilli)
{
accessory[i].onMilli = millis() + (accessory[i].offtime * accessory[i].offtimeX);
accessory[i].onoff = 0;
this->state = TT_STOP;
}
else
{
if (!accessory[i].onoff && millis() > accessory[i].onMilli)
{
this->strobe(accessory[i].outputPin1);
delay(STROBE_DELAY);
this->strobe(accessory[i].outputPin1);
accessory[i].offMilli = millis() + (accessory[i].ontime * accessory[i].ontimeX);
accessory[i].onoff = 1;
this->state = TT_STOP;
}
}
break;
case 10: // strobe single
if (accessory[i].onoff && millis() > accessory[i].offMilli)
{
accessory[i].onMilli = millis() + (accessory[i].offtime * accessory[i].offtimeX);
accessory[i].onoff = 0;
this->state = TT_STOP;
}
else
{
if (!accessory[i].onoff && millis() > accessory[i].onMilli)
{
this->strobe(accessory[i].outputPin1);
accessory[i].offMilli = millis() + (accessory[i].ontime * accessory[i].ontimeX);
accessory[i].onoff = 1;
this->state = TT_STOP;
}
}
break;
}
}
}
/*
* change state to TT_IDLE and move next command up in the queue
*/
if (this->state == TT_STOP)
{
memmove(this->commandQueue, this->commandQueue + 1, TT_MOVER_MAX_TRACKS);
this->state = TT_IDLE;
}
}
/*
* double strobe function
*/
void Lights::strobe(uint8_t pin)
{
digitalWrite(pin, HIGH);
delay(10);
digitalWrite(pin, LOW);
}