-
Notifications
You must be signed in to change notification settings - Fork 0
/
MagicPanel.ino
3677 lines (3470 loc) · 113 KB
/
MagicPanel.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
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
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Magic Panel FX by IA-PARTS.com
//
//// Release History
// v011 - Cleanup of code, additional documentation added (TheJugg1er 02-18-2020)
// v010.6 - Added Serial interface support and additional sequences (TheJugg1er 01-05-2020)
// v010.5 - Re-added Working I2C and additional display sequences (FlthyMcNsty 05-21-2014)
// v010 - Remove I2C code and clean up
// v009 - Combine Big Happy Dude functions to v008 + allow for 3 pin binary input
// v008 - Final Code Release May 24 2013 - D Dobyns
// v007 - New Functions for Program Pin Control - D Dobyns
// v006 - Jumper Pin Program - D Dobyns
// v005 - Cleaned code - Production
// v004 - Added JEDI support for JEDI Serial Address 10 decimal
// v003 - Decode events... next add selectable jumper support.
// v002 - Added default operation & I2C support
// v001 - Initial Demo Sketch
//
/*
* The Full description of all command sequences are listed below. These are called using either i2c or serial and supplying
* the mode number as listed.
*
* The Code has two modes of operating. It is possible to set this during runtime of the panel, however the default is controlled
* in the code below. To set the Defaul mode, change the variable "alwaysOn" to be either true or false. The default here is false.
*
* If alwaysOn is set to False, the patterns will display for a given time, and then turn off.
* If alwaysOn is set to True, the pattern will display until the T00 (off) command is received. (or loop until T00 is received).
*
* To change the Default, Command P0 will set to "false", Command P1 will set to "true", overriding the default for this session.
*
* The Magic Panel uses JawaLite commands to trigger the patterns. Currently only A, D, P, and T commands from the JawaLite
* spec are supported.
*
* Command A will turn the panel on
*
* Command D will turn the panel off
*
* Command P will set the default panel mode as described above.
*
* Command T will trigger a numbered pattern. Txx where xx is the pattern number below.
*
* When sending i2c command the Panel Address is defined below to be 20. The command type and value are needed. To trigger a
* pattern, send character 'T' and the value corresponding to the pattern list below to trigger the corresponding sequence.
* Sequences must be terminated with a carriage return (\r)
*
* On the MarcDuino i2c can be connected from either the Master or Slave
*
* e.g. &20,x54,2\r - This will turn on the MP for ~2 seconds.
*
* When sending commands via serial, no address is required as Serial is a point to point communication protocol.
* Sequences must be terminated with a carriage return (\r)
*
* To use the MarcDuino Serial triggering, connect Pin 3 of the Magic Panel (Rx) to the "To Slave" Signal pin on the
* MarcDuino Slave.
*
* e.g. %T2 - This will turn on the MP for ~2 seconds.
*
* Mode 0 - Turn Panel off
* Mode 1 - Turn Panel on Indefinately
* Mode 2 - Turn Panel on for 2s
* Mode 3 - Turn Panel on for 5s
* Mode 4 - Turn Panel on for 10s
* Mode 5 - Begins Toggle Sequence: Top and Bottom Half of Panel Alternate
* Mode 6 - Begins Alert Sequence (4s): Panel Rapidly Flashes On & Off
* Mode 7 - Begins Alert Sequence (10s): Panel Rapidly Flashes On & Off
* Mode 8 - Begins Trace Up Sequence (Type 1): Each Row of the MP lights up from bottom to top filling entire panel
* Mode 9 - Begins Trace Up Sequence (Type 2): Each row of the MP lights up from bottom to top individually
* Mode 10 - Begins Trace Down Sequence (Type 1): Each row of the MP lights up from top to bottom filling entire panel
* Mode 11 - Begins Trace Down Sequence (Type 2): Each row of the MP lights up from top to bottom individually
* Mode 12 - Begins Trace Right Sequence (Type 1): Each column of the MP lights up from left to right filling entire panel
* Mode 13 - Begins Trace Right Sequence (Type 2): Each column of the MP lights up from left to right individually
* Mode 14 - Begins Trace Left Sequence (Type 1): Each column of the MP lights up from right to left filling entire panel
* Mode 15 - Begins Trace Left Sequence (Type 2): Each column of the MP lights up from right to left individually
* Mode 16 - Begins Expand Sequence (Type 1): Panel expands from center filling entire panel
* Mode 17 - Begins Expand Sequence (Type 2): Ring of pixels expands from center of panel
* Mode 18 - Begins Compress Sequence (Type 1): Panel compresses from outer edge filling entire panel
* Mode 19 - Begins Compress Sequence (Type 2): Ring of pixels compresses from outer edge of panel
* Mode 20 - Begins Cross Sequence: Panel is lit to display an X for 3s
* Mode 21 - Begins Cyclon Column Sequence: Each column illuminated one at a time from left to right back to left. (like the Cylons from Battlestar Galactica)
* Mode 22 - Begins Cyclon Row Sequence: Each row illuminated one at a time from top to bottom back to top. (like the Cylons from Battlestar Galactica)
* Mode 23 - Begins Eye Scan Sequence: Each row is illuminated from top to bottom followed by each column left to right. (like the eye ball scanners in the Mission Impossible movies)
* Mode 24 - Begins Fade Out/In Sequence: MP gradually and randomly fades out and then fades back in the same manner.
* Mode 25 - Begins Fade Out Sequence: MP gradually and randomly fades out (Similar to the Short Circuit Sequence on Teeces).
* Mode 26 - Begins Flash Sequence: MP flashes rapidly for 5 seconds (Similar to Alarm Sequence)
* Mode 27 - Begins Flash V Sequence: Left and Right Half of Panel Alternate
* Mode 28 - Begins Flash Q Sequence: Alternating quadrants of MP flash rapidly
* Mode 29 - Begins Two Loop Sequence: Dual pixels are lit opposite each other completing a loop around the 2nd ring from panel edge.
* Mode 30 - Begins One Loop Sequence: A single pixel is lit individually completing a loop around the 2nd ring from panel edge.
* Mode 31 - Begins Test Sequence (Type 1): Each pixel of the MP is lit sequentially from row 0, column 7 to row 7, column 0 until panel is filled, then unlit in the same order.
* Mode 32 - Begins Test Sequence (Type 2): Each pixel of the MP is lit indivually from row 0, column 7 to row 7, column 0.
* Mode 33 - Begins AI Logo Sequence: Displays the AI Aurebesh characters for 3s (...that we see all over our awesome packages from Rotopod and McWhlr)
* Mode 34 - Begins 2GWD Logo Sequence: Displays the Characters 2-G-W-D sequentially every 1s (...shameless, I know.)
* Mode 35 - Begins Quadrant Sequence (Type 1): Each Panel Quadrant lights up individually (TL, TR, BR, BL)
* Mode 36 - Begins Quadrant Sequence (Type 2): Each Panel Quadrant lights up individually (TR, TL, BL, BR)
* Mode 37 - Begins Quadrant Sequence (Type 3): Each Panel Quadrant lights up individually (TR, BR, BL, TL)
* Mode 38 - Begins Quadrant Sequence (Type 4): Each Panel Quadrant lights up individually (TL, BL, BR, TR)
* Mode 39 - Begins Random Pixel Sequence: Random pixels flashe individually for 6s
* Mode 40 - Begins countdown from 9 to 0 (takes 10 seconds)
* Mode 41 - Begins countdown from 3 to 0 (takes 4 seconds)
* Mode 42 - Begins Alert Sequence (4s): Panel Randomly Flashes On & Off, mimics the original MarcDuino code
* Mode 43 - Begins Alert Sequence (8s): Panel Randomly Flashes On & Off, mimics the original MarcDuino code
* Mode 44 - Begins Smiley Face
* Mode 45 - Begins Sad Face
* Mode 46 - Begins Heart
* Mode 47 - Begins Flash Checkerboard sequence. Flashes small squares in a checkerboard pattern
* Mode 48 - Begins Compress In Type 1 - Fills the rows from TL/BR in half row increments 5 times
* Mode 49 - Begins Compress In Type 2 - Fills the rows from TL/BR in half row increments then clears in the same order 5 times
* Mode 50 - Begins Explode Out Type 1 - Fills the rows from Centre Out in half row increments 5 times
* Mode 51 - Begins Explode Out Type 2 - Fills the rows from Centre Out in half row increments then clears in the same order 5 times
* Mode 52 - Begins VU Meter - Randomly ramp up/down on the columns to simulate a VU Meter. (Type 1)
* Mode 53 - Begins VU Meter - Randomly ramp up/down on the rows to simulate a VU Meter. (Type 2)
* Mode 54 - Begins VU Meter - Randomly ramp up/down on the columns from the top to simulate a VU Meter. (Type 3)
* Mode 55 - Begins VU Meter - Randomly ramp up/down on the rows from the right to simulate a VU Meter. (Type 4)
*/
//We always have to include the library
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "LedControl.h"
#include "Wire.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////// Assign IC2 Address Below //////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
byte I2CAdress = 20;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////// Patterns always on define //////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool alwaysOn = false; // false is default behaviour. Pattern will turn off after running (or given time)
// Set to true to have patterns remain on until Mode 0 is selected.
// Note this can cause some slight delays in response from the panel.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Uncomment this if you want debug messages
//#define DEBUG
const unsigned char scrolly[] PROGMEM ={"This is only a test. 1 2 3 ... Perhaps I'll try Arabesh next???"};
const unsigned char auratest[] PROGMEM ={" A B C D E F G H I J K L M N O P Q R S T U V W X Y Z , . ? ! : ; - / ` ' \" ( ) $ A U R E B E S H T E S T . C A N Y O U R E A D T H I S ? "};
unsigned long time = 0;
unsigned long last_time = 0;
byte Speed = 1;
byte first_time = 1; // used for 4-bit (0 2 3 5) input reading - reset all variables
// when 4-bit address value changes (except the first time on power up)
byte DigInState = 0;
byte lastDigInState; //= 0;
// State Variables
int AlertTime = 0;
int TraceUpTime = 0;
int TraceDownTime = 0;
int TraceRightTime = 0;
int TraceLeftTime = 0;
int QuadrantTime = 0;
int CompressTime = 0;
int ExpandTime = 0;
int ToggleTime = 0;
int RandomPixelTime = 0;
byte TopRow = 0;
byte BotRow = 0;
byte RandomState = 0;
byte RandomMode; // selected mode
unsigned long RandomTime = 0;
//unsigned long RandomInterval = 0; // time between function calls
unsigned long RandomOnTime = 0;
/*
To load a sketch onto Magic Panel as Arduino Duemilanove w/ ATmega328
Now we need a LedControl to work with.
***** These pin numbers will probably not work with your hardware *****
7221
Pin 1 - Data IN
Pin 12 - Load
Pin 13 - CLK
Pin 24 - Data Out
Top 7221 = 0
Bottom 7221 =1
Assign the pins from the 328p to LedControl
pin D8 is connected to the DataIn
pin D7 is connected to the CLK
pin D6 is connected to LOAD
We have two MAX7221 on the Magic Panel, so we use 2.
*/
LedControl lc=LedControl(8,7,6,2);
unsigned long delaytime=30;
unsigned long scrolldelaytime=50;
boolean VMagicPanel[8][8]; // [Row][Col]
unsigned char MagicPanel[16];
int NumLoops=2;
//Serial Stuff
int MPeventCode = 0;
int lastMPeventCode = 0;
bool firstTimeCode = true;
// String processing from Serial
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
boolean stringEvaluated = false; // whether the serial "packet" has been processed
//Timing stuff
unsigned long patternEndTime=0;
boolean patternActive = false;
void setup()
{
Wire.begin(I2CAdress); // Start I2C Bus as Master I2C Address
Wire.onReceive(receiveEvent); // register event so when we receive something we jump to receiveEvent();
// Setup the Serial Interface
Serial.begin(9600);
inputString.reserve(200);
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
lc.shutdown(0,false);
lc.shutdown(1,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,15);
lc.setIntensity(1,15);
/* and clear the display */
lc.clearDisplay(0);
lc.clearDisplay(1);
randomSeed(analogRead(A3)); // Randomizer
// Test Pixels
TheTest(30);
// SETUP 6 DIGITAL PINS FOR MANUAL CONTROL
// Jumpe Pins
pinMode(11, INPUT); // set pin 11 to input - input 3
pinMode(12, OUTPUT); // set pin PB4 to output - pin 4 - used to allow a jumper from pin 4 to adjacent pin to pull down the adjacent pin
pinMode(13, INPUT); // set pin 13 to input - input 5
digitalWrite(A0, HIGH); // turn on pullup resistors
digitalWrite(A1, HIGH); // turn on pullup resistors
digitalWrite(A2, HIGH); // turn on pullup resistors
digitalWrite(11, HIGH); // turn on pullup resistors
digitalWrite(13, HIGH); // turn on pullup resistors
digitalWrite(12, LOW); // set pin PC1 to output - pin 1
////digitalWrite(A1, LOW); // set pin PB4 to output - pin 4
}
void loop() {
time = millis(); // get an updated time stamp
if (time - last_time > Speed) // check if time has passed to change states - used to slow down the main loop
{
last_time = time; // reset the timer
//***********************************************
// These are the Binary Coded Input Pins
//
DigInState = 0; // read in the 4-bit address line
if (digitalRead(A0) == LOW) // 0
{ DigInState = DigInState + 4; }
if (digitalRead(A1) == LOW) // 1
{ DigInState = DigInState + 2; }
if (digitalRead(A2) == LOW) // 2
{ DigInState = DigInState + 1; }
//***********************************************
// These are the Jumper Pins
//
if (digitalRead(11) == LOW) // 3
{ DigInState = 8; } // if Jumper-1 is Placed - Don't look at Rotary Sw Values
if (digitalRead(13) == LOW) // 5
{ DigInState = 9; } // if Jumper-2 is Placed - Don't look at any other Input Values
if(first_time)
{
lastDigInState = DigInState; // dont allow a change in DigInState values if this is the first time through
first_time = 0;
}
if (DigInState != lastDigInState) //if DigInState has changed...
{
blankPANEL(); // Clear LED's
}
lastDigInState = DigInState; // Store the current Input Status
switch (DigInState) // Call the appropriate code routine - based on the input address values of the control lines A B C
{
case 0: // DO NOTHING - ALLOW I2C FUNCTIONS TO OVER-RIDE 6-PIN INPUT
{
///////////////////////////////////
// Toggle(100);
// Alert(100);
// TraceUp(1);
// TraceDown(1);
// Compress(5, 100);
// Expand (10, 50);
// Random();
//////////////////////////////////
break;
}
case 1: // FADE IN AND OUT:
{ allOFF();
FadeOutIn(1);
allOFF();
break;
}
case 2: // RANDOM FAST:
{
allOFF();
FlashAll(8, 200);
allOFF();
break;
}
case 3: // 2 LOOP:
{
allOFF();
TwoLoop(2);
allOFF();
break;
}
case 4: // TRACE DOWN:
{
allOFF();
TraceDown(5,1);
allOFF();
break;
}
case 5: // ONE TEST:
{
allOFF();
OneTest(30);
allOFF();
break;
}
case 6: // Random Fast:
{
Random(random(8000,14000));
break;
}
case 7: // RANDOM SLOW:
{
Random(random(40000,60000)); // 5 to 8 minute interval between light patterns
break;
}
case 8: // Jumper 1 :
{
allONTimed(0);
break;
}
case 9: // Jumper 2 :
{
Random(random(8000,14000)); // 1 to 2 min interval between light patterns
break;
}
default:
{ // OFF:
allOFF(); // Clear LED's
break;
}
}//end switch,\
// End the current Pattern if there is one being "played"
// This replaces the use of delay() which is a blocking call.
if (patternActive)
{
if (time >= patternEndTime)
{
allOFF();
patternActive=false;
}
}
// If we want the pattern to always be on, then re-call the process function
// with the same code as the last time.
// This only applies to patterns that are not "all on" patterns, to avoid a
// LED blink due to re-calling the code.
if (alwaysOn &&
(lastMPeventCode > 4)){
runPattern(lastMPeventCode);
}
}// end of if(time)
}//end of loop
void setPatternEndTime(unsigned long patternTime)
{
time = millis();
patternEndTime = time + patternTime;
patternActive = true;
}
void Random(int RandomInterval)
{
switch (RandomState)
{
case 0:
{
RandomMode = random(0,35); // randomly select DisplayMode 0 to 25
//RandomMode = 25;
// 0 = Toggle(100);
// 1 = Alert(100);
// 2 = TraceUp(1);
// 3 = TraceDown(1);
// 4 = Compress(5, 100);
// 5 = Expand (10, 50);
// 6 = AllON();
// 7 = AllOFF();
//...
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// RandomInterval = 1500;// 2500;//random(50000, 100000); // randomly select the interval between function calls - Panel is OFF
// RandomInterval = random(500, 1000); // randomly select the interval between function calls - Panel is OFF
///
/// 5000 = apprx 40 sec
/// 50000 = 400 secs or 6.5 mins
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
RandomOnTime = random(1000, 1500);// 8 to 12 seconds // ON Time - THIS TIME WILL CHANGE BASED ON THE SEQUENCE CALLED (For State Machine Based Functions)
RandomTime = 0;
RandomState++; // proceed to next state
break;
}
case 1:
{
switch(RandomMode)
{
case 0: // 0 = Turns Panel Off
{
allOFF();
break;
}
case 2: // 2 = Turns Panel on for 2s
{
allOFF();
allONTimed(2000);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 3: // 3 = Begins Toggle Sequence: Top and Bottom Half of Panel Alternate
{
allOFF();
Toggle(10);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 4: // 4 = Begins Alert Sequence (4s): Panel Rapidly Flashes On & Off
{
allOFF();
Alert(8);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 5: // 5 = Begins Trace Up Sequence (Type 1): Each row of the MP lights up from bottom to top filling entire panel
{
allOFF();
TraceUp(5, 1);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 6: // 6 = Begins Trace Up Sequence (Type 2): Each row of the MP lights up from bottom to top individually
{
allOFF();
TraceUp(5, 2);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 7: // 7 = Begins Trace Down Sequence (Type 1): Each row of the MP lights up from top to bottom filling entire panel
{
allOFF();
TraceDown(5, 1);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 8: // 8 = Begins Trace Down Sequence (Type 2): Each row of the MP lights up from top to bottom individually
{
allOFF();
TraceDown(5, 2);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 9: // 9 = Begins Expand Sequence (Type 1): Panel expands from center filling entire panel
{
allOFF();
Expand(5,1);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 10: // 10 = Begins Expand Sequence (Type 2): Ring of pixels expands from center of panel
{
allOFF();
Expand(5,2);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 11: // 11 = Begins Compress Sequence (Type 1): Panel compresses from outer edge filling entire panel
{
allOFF();
Compress(5,1);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 12: // 12 = Begins Compress Sequence (Type 2): Ring of pixels compresses from outer edge of panel
{
allOFF();
Compress(5,2);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 13: // 13 = Begins Cross Sequence: Panel is lit to display an X for 3s
{
allOFF();
Cross();
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 14: // 14 = Begins Cyclon Column Sequence:
{
allOFF();
CylonCol(2, 140);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 15: // 15 = Begins Cyclon Row Sequence:
{
allOFF();
CylonRow(2, 140);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 16: // 16 = Begins Eye Scan Sequence:
{
EyeScan(2, 100);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 17: // 17 = Begins Fade Out/In Sequence:
{
FadeOutIn(1);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 18: // 18 = Begins Fade Out Sequence:
{
FadeOutIn(2);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 19: // 19 = Begins Flash Sequence:
{
FlashAll(8, 200);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 20: // 20 = Begins Flash V Sequence:
{
FlashV(8, 200);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 21: // 21 = Begins Flash Q Sequence: Alternating quadrants of MP flash rapidly
{
FlashQ(8, 200);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 22: // 22 = Begins Two Loop Sequence:
{
allOFF();
TwoLoop(2);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 23: // 23 = Begins One Loop Sequence:
{
allOFF();
OneLoop(2);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 24: // 24 = Begins Test Sequence (Type 1):
{
allOFF();
TheTest(30);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 25: // 25 = Begins Test Sequence (Type 2):
{
allOFF();
OneTest(30);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 26: // 26 = Begins AI Logo Sequence: Displays the AI Aurebesh characters for 3s that we see all over our awesome packages from Rotopod and McWhlr
{
allOFF();
Symbol();
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 27: // 27 = Begins Quadrant Sequence (Type 1): Each Panel Quadrant lights up individually (TL, TR, BR, BL)
{
allOFF();
Quadrant(5, 1);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 28: // 28 = Begins Quadrant Sequence (Type 2): Each Panel Quadrant lights up individually (TR, TL, BL, BR)
{
allOFF();
Quadrant(5, 2);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 29: // 29 = Begins Quadrant Sequence (Type 3): Each Panel Quadrant lights up individually (TR, BR, BL, TL)
{
allOFF();
Quadrant(5, 3);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 30: // 30 = Begins Quadrant Sequence (Type 4): Each Panel Quadrant Rights up individually (TL, BL, BR, TR)
{
allOFF();
Quadrant(5, 4);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 31: // 31 = Begins Random Pixel Sequence: Random pixels flashe individually for 6s
{
allOFF();
RandomPixel(40);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 32: // 32 = Begins Trace Right Sequence (Type 1): Each column of the MP lights up from left to right filling entire panel
{
allOFF();
TraceRight(5, 1);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 33: // 33 = Begins Trace Right Sequence (Type 2): Each column of the MP lights up from left to right individually
{
allOFF();
TraceRight(5, 2);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 34: // 34 = Begins Trace Left Sequence (Type 1): Each column of the MP lights up from right to left filling entire panel
{
allOFF();
TraceLeft(5, 1);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
case 35: // 35 = Begins Trace Left Sequence (Type 2): Each column of the MP lights up from right to left individually
{
allOFF();
TraceLeft(5, 2);
RandomTime = RandomOnTime + 1;
allOFF();
break;
}
}// end of nested switch(RandomMode)
if(RandomTime++ > RandomOnTime)
{
RandomTime = 0; // reset timer
//allOFF(); // turn off All Leds
RandomState++; // proceed to next state
}
break;
}
//
case 2:
{
allOFF(); // turn off All Leds
if(RandomTime++ > RandomInterval) // OFF until timer expires
{
RandomTime = 0; // reset timer
RandomState = 0; // proceed to next state
}
break;
}
}// end switch
}//end Random
////////////////////////////////////////////////////////////////////////////////////////
// BHD Functions
////////////////////////////////////////////////////////////////////////////////////////
void EyeScan(int Repeats, int FlashDelay){
for(int i=0; i<Repeats; i++)
{
for(int j=0; j<8; j++){
SetRow(j, B11111111);
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
SetRow(j, B00000000);
}
allOFF();
delay(FlashDelay);
for(int j=0; j<8; j++){
SetCol(7-j, B11111111);
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
SetCol(7-j, B00000000);
}
allOFF();
delay(FlashDelay);
}
}
void CylonCol(int Repeats, int FlashDelay){
for(int i=0; i<Repeats; i++){
for(int j=0; j<8; j++){
SetCol(j, B11111111);
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
SetCol(j, B00000000);
}
for(int j=0; j<6; j++){
SetCol(6-j, B11111111);
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
SetCol(6-j, B00000000);
}
}
}
void CylonRow(int Repeats, int FlashDelay){
for(int i=0; i<Repeats; i++){
for(int j=0; j<8; j++){
SetRow(j, B11111111);
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
SetRow(j, B00000000);
}
for(int j=0; j<6; j++){
SetRow(6-j, B11111111);
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
SetRow(6-j, B00000000);
}
}
}
void FlashH(int Repeats, int FlashDelay){
for(int i=0; i<Repeats; i++){
for(int j=0; j<4; j++){
SetRow(j, B11111111);
SetRow(j+4, B00000000);
}
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
for(int j=0; j<4; j++){
SetRow(j, B00000000);
SetRow(j+4, B11111111);
}
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
}
}
void FlashV(int Repeats, int FlashDelay){
for(int i=0; i<Repeats; i++){
for(int j=0; j<4; j++){
SetCol(j, B11111111);
SetCol(j+4, B00000000);
}
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
for(int j=0; j<4; j++){
SetCol(j, B00000000);
SetCol(j+4, B11111111);
}
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
}
}
void FlashQ(int Repeats, int FlashDelay){
for(int i=0; i<Repeats; i++){
SetRow(0, B00001111);
SetRow(1, B00001111);
SetRow(2, B00001111);
SetRow(3, B00001111);
SetRow(4, B11110000);
SetRow(5, B11110000);
SetRow(6, B11110000);
SetRow(7, B11110000);
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
SetRow(0, B11110000);
SetRow(1, B11110000);
SetRow(2, B11110000);
SetRow(3, B11110000);
SetRow(4, B00001111);
SetRow(5, B00001111);
SetRow(6, B00001111);
SetRow(7, B00001111);
MapBoolGrid();
PrintGrid();
delay(FlashDelay);
}
}
void FlashAll(int Repeats, int FlashDelay){
for(int i=0; i<Repeats; i++){
allON();
delay(FlashDelay);
allOFF();
delay(FlashDelay);
}
}
void OneLoop(int Repeats){
for(int j=0; j<Repeats; j++){
for(int i=0; i<6; i++){
VMagicPanel[1][7-(1+i)]=true;
MapBoolGrid();
PrintGrid();
delay(100);
VMagicPanel[1][7-(1+i)]=false;
}
for(int i=0; i<4; i++){
VMagicPanel[2+i][1]=true;
MapBoolGrid();
PrintGrid();
delay(150);
VMagicPanel[2+i][1]=false;
}
for(int i=0; i<6; i++){
VMagicPanel[6][(1+i)]=true;
MapBoolGrid();
PrintGrid();
delay(100);
VMagicPanel[6][(1+i)]=false;
}
for(int i=0; i<4; i++){
VMagicPanel[7-(2+i)][6]=true;
MapBoolGrid();
PrintGrid();
delay(150);
VMagicPanel[7-(2+i)][6]=false;
}
}
}
void TwoLoop(int Repeats){
for(int j=0; j<Repeats; j++){
for(int i=0; i<6; i++){
VMagicPanel[1][7-(1+i)]=true;
VMagicPanel[6][(1+i)]=true;
MapBoolGrid();
PrintGrid();
delay(100);
VMagicPanel[1][7-(1+i)]=false;
VMagicPanel[6][(1+i)]=false;
}
for(int i=0; i<4; i++){
VMagicPanel[2+i][1]=true;
VMagicPanel[7-(2+i)][6]=true;
MapBoolGrid();
PrintGrid();
delay(150);
VMagicPanel[2+i][1]=false;
VMagicPanel[7-(2+i)][6]=false;
}
for(int i=0; i<6; i++){
VMagicPanel[6][(1+i)]=true;
VMagicPanel[1][7-(1+i)]=true;
MapBoolGrid();
PrintGrid();
delay(100);
VMagicPanel[6][(1+i)]=false;
VMagicPanel[1][7-(1+i)]=false;
}
for(int i=0; i<4; i++){
VMagicPanel[7-(2+i)][6]=true;
VMagicPanel[2+i][1]=true;
MapBoolGrid();
PrintGrid();
delay(150);
VMagicPanel[7-(2+i)][6]=false;
VMagicPanel[2+i][1]=false;
}
}
}
void FadeOutIn(byte type) { // FlthyMcNsty added a variable to this function pass a type value to allow for just a fade out sequence as well
for(int i=0; i<2*NumLoops; i++){
for(int i=0; i<8; i++){
SetRow(i, (random(256)|random(256)));
}
MapBoolGrid();
PrintGrid();
delay(150);
}
for(int i=0; i<NumLoops; i++){
for(int i=0; i<8; i++){
SetRow(i, random(256));
}
MapBoolGrid();
PrintGrid();
delay(150);
}
for(int i=0; i<NumLoops; i++){
for(int i=0; i<8; i++){
SetRow(i, (random(256)&random(256)));
}
MapBoolGrid();
PrintGrid();
delay(150);
}