-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
FlipDisc.h
663 lines (620 loc) · 27 KB
/
FlipDisc.h
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
/*----------------------------------------------------------------------*
* FlipDisc.h - Arduino library for flip-disc displays. *
* This library is intended for use with the displays designed by *
* www.Flipo.io - Marcin Saj. *
* *
* The MIT License *
* Marcin Saj 15 Jan 2023 *
* https://github.com/marcinsaj/FlipDisc *
*----------------------------------------------------------------------*/
#ifndef FlipDisc_h
#define FlipDisc_h
#include <Arduino.h>
#include <SPI.h>
#ifdef __AVR__
#include <avr/pgmspace.h>
#endif
// Codenames of display modules
static const uint8_t D7SEG = 0x7F;
static const uint8_t D2X1 = 0x31; /* D3X1 = D2X1 - are the same */
static const uint8_t D3X1 = 0x31;
static const uint8_t D1X3 = 0x13;
static const uint8_t D1X7 = 0x17;
static const uint8_t D2X6 = 0x26;
static const uint8_t D3X3 = 0x33;
static const uint8_t D3X4 = 0x34;
static const uint8_t D3X5 = 0x35;
static const uint8_t NONE = 0xFF;
// Codenames of symbols for 7-segment display
static const uint8_t ALL = 8; // ALL - Set all discs
static const uint8_t CLR = 10; // CLR - Clear display
static const uint8_t A = 11;
static const uint8_t B = 12;
static const uint8_t C = 13;
static const uint8_t D = 14;
static const uint8_t E = 15;
static const uint8_t F = 16;
static const uint8_t G = 17;
static const uint8_t H = 18;
static const uint8_t I = 19;
static const uint8_t J = 20;
static const uint8_t K = 21;
static const uint8_t L = 22;
static const uint8_t M = 23;
static const uint8_t N = 24;
static const uint8_t O = 25;
static const uint8_t P = 26;
static const uint8_t Q = 27;
static const uint8_t R = 28;
static const uint8_t S = 29;
static const uint8_t T = 30;
static const uint8_t U = 31;
static const uint8_t V = 32;
static const uint8_t W = 33;
static const uint8_t X = 34;
static const uint8_t Y = 35;
static const uint8_t Z = 36;
static const uint8_t DEG = 37; // DEG - "°" - Degree symbol
static const uint8_t PFH = 37; // PFH - "%" - Percent first half symbol
static const uint8_t PRC = 38; // PRC - "%" - Percent symbol for 3x5 display
static const uint8_t PSH = 38; // PSH - "%" - Percent second half symbol
static const uint8_t HLU = 39; // HLU - "¯" - Horizontal line - upper
static const uint8_t HLM = 40; // HLM - "-" - Horizontal line - middle
static const uint8_t MIN = 40; // MIN - "-" - Minus symbol
static const uint8_t HLL = 41; // HLL - "_" - Horizontal line - lower
static const uint8_t HLT = 42; // HLT - "=" - Horizontal line - upper & lower
static const uint8_t HLA = 43; // HLA - "≡" - All three lines
static const uint8_t VLL = 44; // VLL - "| " - Vertical line - left
static const uint8_t VLR = 1 ; // VLR - " |" - Vertical line - right
static const uint8_t VLA = 45; // VLA - "||" - All Vertical lines
// Codenames for the SendBlankData() function
static const uint8_t BEFORE = 0xAA;
static const uint8_t AFTER = 0xBB;
// Codenames for the moduleInitArray[][3] columns
static const uint8_t module_type_column = 0;
static const uint8_t number_bytes_column = 1;
static const uint8_t module_relative_position_column = 2;
/*
* The 7-segment display consists of 23 disks.
* displayArray_7Seg[][] - the array contains information about all the discs
* that we need to flip in order to display the selected digit/symbol.
* Each of the discs has two sides, one "color" side corresponds to the "1",
* the "black" side "0".
*
* 0 1 2 3 4
* 19 5
* 18 6
* 17 20 21 22 7
* 16 8
* 15 9
* 14 13 12 11 10
* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22
* 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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* 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 39/HLU - "¯" - Upper line symbol
* 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1 // 40/HLM - "-" - Middle line symbol
* 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 // 41/HLL - "_" - Lower line symbol
* 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 // 42/HLT - "=" - Upper & lower lines
* 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1 // 43/HLA - "≡" - All three lines
* 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 // 44/VLL - "| " - Vertical line - left
* 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 1/VLR - " |" - Vertical line - right
* 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 // 45/VLA - "||" - All Vertical lines
*/
/*
* Compressed array of all bits corresponding to discs states for selected symbols.
* Disc numbers in individual bytes:
* 7,6,5,4,3,2,1,0 15,14,13,12,11,10,9,8 23,22,21,20,19,18,17,16
*/
static const uint8_t displayArray_7Seg[46][3] PROGMEM =
{
{0b11111111, 0b11111111, 0b00001111}, // 0
{0b11110000, 0b00000111, 0b00000000}, // 1/VLR - " |" - Vertical line - right
{0b11111111, 0b11111100, 0b01110011}, // 2
{0b11111111, 0b01111111, 0b01110010}, // 3
{0b11110001, 0b00000111, 0b01111110}, // 4
{0b10011111, 0b01111111, 0b01111110}, // 5
{0b10011111, 0b11111111, 0b01111111}, // 6
{0b11111111, 0b00000111, 0b00000000}, // 7
{0b11111111, 0b11111111, 0b01111111}, // 8/ALL - Set all discs
{0b11111111, 0b01111111, 0b01111110}, // 9
{0b00000000, 0b00000000, 0b00000000}, // 10/CLR - Clear display
{0b11101110, 0b11000111, 0b01111111}, // 11/A
{0b01101111, 0b11111011, 0b01111111}, // 12/B
{0b00011110, 0b10111100, 0b00001111}, // 13/C
{0b11101111, 0b11111011, 0b00001111}, // 14/D
{0b00011111, 0b11111100, 0b01111111}, // 15/E
{0b00011111, 0b11000000, 0b01111111}, // 16/F
{0b10011110, 0b10111111, 0b01001111}, // 17/G
{0b11110001, 0b11000111, 0b01111111}, // 18/H
{0b11110000, 0b00000111, 0b00000000}, // 19/I/VLR - " |" - Vertical line - right
{0b11110000, 0b10111011, 0b00000000}, // 20/J
{0b01110001, 0b11000111, 0b01111111}, // 21/K
{0b00000001, 0b11111100, 0b00001111}, // 22/L
{0b11111011, 0b11000111, 0b00101111}, // 23/M
{0b11110011, 0b11001111, 0b00101111}, // 24/N
{0b11101110, 0b10111011, 0b00001111}, // 25/0
{0b01101111, 0b11000000, 0b01111111}, // 26/P
{0b11101110, 0b10111111, 0b00001111}, // 27/Q
{0b01101111, 0b11000111, 0b01111111}, // 28/R
{0b00011110, 0b01111011, 0b01111100}, // 29/S
{0b00011111, 0b00010000, 0b00100000}, // 30/T
{0b11110001, 0b10111011, 0b00001111}, // 31/U
{0b00010001, 0b11100000, 0b00101111}, // 32/V
{0b11110001, 0b11101111, 0b00101111}, // 33/W
{0b01110001, 0b11000111, 0b01111101}, // 34/X
{0b11110001, 0b00000111, 0b01111100}, // 35/Y
{0b00111111, 0b11111100, 0b00100000}, // 36/Z
{0b11111111, 0b00000000, 0b01111110}, // 37/DEG/PFH - "°" - Degree symbol / "%" - Percent first half symbol
{0b10000000, 0b11111111, 0b01110011}, // 38/PSH - "%" - Percent second half symbol
{0b00011111, 0b00000000, 0b00000000}, // 39/HLU - "¯" - Horizontal line - upper
{0b10000000, 0b00000000, 0b01110010}, // 40/HLM - "-" - Horizontal line - middle
{0b00000000, 0b01111100, 0b00000000}, // 41/HLL - "_" - Horizontal line - lower
{0b00011111, 0b01111100, 0b00000000}, // 42/HLT - "=" - Horizontal line - upper & lower
{0b10011111, 0b01111100, 0b01110010}, // 43/HLA - "≡" - All three lines
{0b00000001, 0b11000000, 0b00001111}, // 44/VLL - "| " - Vertical line - left
{0b11110001, 0b11000111, 0b00001111} // 45/VLA - "||" - All Vertical lines
};
/*
* Refers to "D7SEG" - 7-segment display.
* Each of the "0" or "1" disc statuses requires a different polarity of the current pulse
* released into the disc, and thus for each of the statuses we must drive different
* controller outputs to achieve the desired effect.
* -> setDiscArray_7Seg[][] - the array contains the addresses of all control outputs corresponding
* to the setting of the discs to the "color" side.
* A data frame to flip one disc requires 3 bytes and only two bits are set to "1" the other bits are "0".
* To flip the entire display, we need to send 3 bytes x 23 discs = 69 bytes of data.
*/
static const uint8_t setDiscArray_7Seg[23][3] PROGMEM =
{
{0b00000010, 0b00000010, 0b00000000}, // 0
{0b00000000, 0b00010010, 0b00000000}, // 1
{0b01000000, 0b00010000, 0b00000000}, // 2
{0b00001000, 0b00010000, 0b00000000}, // 3
{0b01000010, 0b00000000, 0b00000000}, // 4
{0b01000000, 0b00000100, 0b00000000}, // 5
{0b01000000, 0b01000000, 0b00000000}, // 6
{0b01000000, 0b00000000, 0b01000000}, // 7
{0b01000000, 0b00000000, 0b00000100}, // 8
{0b01000000, 0b00000000, 0b00000010}, // 9
{0b11000000, 0b00000000, 0b00000000}, // 10
{0b00001000, 0b00000000, 0b00000100}, // 11
{0b00001000, 0b00000000, 0b00000010}, // 12
{0b10001000, 0b00000000, 0b00000000}, // 13
{0b10000000, 0b00000010, 0b00000000}, // 14
{0b00000000, 0b00000010, 0b00000010}, // 15
{0b00000000, 0b00000010, 0b00000100}, // 16
{0b00000000, 0b00000010, 0b01000000}, // 17
{0b00000000, 0b01000010, 0b00000000}, // 18
{0b00000000, 0b00000110, 0b00000000}, // 19
{0b00001000, 0b01000000, 0b00000000}, // 20
{0b00001000, 0b00000100, 0b00000000}, // 21
{0b00001000, 0b00000000, 0b01000000} // 22
};
/*
* Refers to "D7SEG" - 7-segment display.
* -> resetDiscArray_7Seg[][] - the array contains the addresses of all control outputs corresponding
* to the setting of the discs to the "black" side.
* Each of the "0" or "1" disc statuses requires a different polarity of the current pulse
* released into the disc, and thus for each of the statuses we must drive different
* controller outputs to achieve the desired effect.
* A data frame to flip one disc requires 3 bytes and only two bits are set to "1" the other bits are "0".
* To flip the entire display, we need to send 3 bytes x 23 discs = 69 bytes of data.
*/
static const uint8_t resetDiscArray_7Seg[23][3] PROGMEM =
{
{0b00000100, 0b00000000, 0b10000000}, // 0
{0b00000000, 0b00100000, 0b10000000}, // 1
{0b00100000, 0b00100000, 0b00000000}, // 2
{0b00010000, 0b00100000, 0b00000000}, // 3
{0b00100100, 0b00000000, 0b00000000}, // 4
{0b00100000, 0b00001000, 0b00000000}, // 5
{0b00100000, 0b10000000, 0b00000000}, // 6
{0b00100000, 0b00000000, 0b00100000}, // 7
{0b00100000, 0b00000000, 0b00000001}, // 8
{0b00100000, 0b00000001, 0b00000000}, // 9
{0b00100001, 0b00000000, 0b00000000}, // 10
{0b00010000, 0b00000000, 0b00000001}, // 11
{0b00010000, 0b00000001, 0b00000000}, // 12
{0b00010001, 0b00000000, 0b00000000}, // 13
{0b00000001, 0b00000000, 0b10000000}, // 14
{0b00000000, 0b00000001, 0b10000000}, // 15
{0b00000000, 0b00000000, 0b10000001}, // 16
{0b00000000, 0b00000000, 0b10100000}, // 17
{0b00000000, 0b10000000, 0b10000000}, // 18
{0b00000000, 0b00001000, 0b10000000}, // 19
{0b00010000, 0b10000000, 0b00000000}, // 20
{0b00010000, 0b00001000, 0b00000000}, // 21
{0b00010000, 0b00000000, 0b00100000} // 22
};
/*
* Refers to "D3X1 & D2X1" - 2 and 3-dot display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "color" side.
*/
static const uint8_t setDiscArray_3x1[3] PROGMEM =
{
0b00100001,
0b00101000,
0b00100010
};
/*
* Refers to "D3X1 & D2X1" - 2 and 3-dot display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "black" side.
*/
static const uint8_t resetDiscArray_3x1[3] PROGMEM =
{
0b11000000,
0b01010000,
0b01000100
};
/*
* Refers to "D1X3" - 1x3 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "color" side.
*/
static const uint8_t setDiscArray_1x3[3] PROGMEM =
{
0b10000010,
0b10010000,
0b10100000
};
/*
* Refers to "D1X3" - 1x3 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "black" side.
*/
static const uint8_t resetDiscArray_1x3[3] PROGMEM =
{
0b00000101,
0b01000100,
0b00001100
};
/*
* Refers to "D1X7" - 1x7 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "color" side.
*/
static const uint8_t setDiscArray_1x7[7][2] PROGMEM =
{
{0b00101000, 0b00000000},
{0b10001000, 0b00000000},
{0b00001100, 0b00000000},
{0b00001000, 0b01000000},
{0b00001000, 0b00000010},
{0b00001000, 0b00010000},
{0b00001000, 0b00000001}
};
/*
* Refers to "D1X7" - 1x7 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "black" side.
*/
static const uint8_t resetDiscArray_1x7[7][2] PROGMEM =
{
{0b00010001, 0b00000000},
{0b01000001, 0b00000000},
{0b00000001, 0b10000000},
{0b00000011, 0b00000000},
{0b00000001, 0b00000100},
{0b00000001, 0b00100000},
{0b00000001, 0b00001000}
};
/*
* Refers to "D2X6" - 2x6 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "color" side.
*/
static const uint8_t setDiscArray_2x6[12][2] PROGMEM =
{
{0b10001000, 0b00000000},
{0b10000010, 0b00000000},
{0b10000000, 0b00000010},
{0b10000000, 0b00000001},
{0b10000000, 0b00100000},
{0b10000000, 0b00010000},
{0b00011000, 0b00000000},
{0b00010010, 0b00000000},
{0b00010000, 0b00000010},
{0b00010000, 0b00000001},
{0b00010000, 0b00100000},
{0b00010000, 0b00010000}
};
/*
* Refers to "D2X6" - 2x6 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "black" side.
*/
static const uint8_t resetDiscArray_2x6[12][2] PROGMEM =
{
{0b01000100, 0b00000000},
{0b01000001, 0b00000000},
{0b01000000, 0b00000100},
{0b01000000, 0b10000000},
{0b01000000, 0b01000000},
{0b01000000, 0b00001000},
{0b00100100, 0b00000000},
{0b00100001, 0b00000000},
{0b00100000, 0b00000100},
{0b00100000, 0b10000000},
{0b00100000, 0b01000000},
{0b00100000, 0b00001000}
};
/*
* Refers to "D3X3" - 3x3 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "color" side.
*/
static const uint8_t setDiscArray_3x3[9][2] PROGMEM =
{
{0b00000000, 0b00010010},
{0b00000000, 0b00100010},
{0b00000100, 0b00000010},
{0b00000010, 0b00010000},
{0b00000010, 0b00100000},
{0b00000110, 0b00000000},
{0b00100000, 0b00010000},
{0b00100000, 0b00100000},
{0b00100100, 0b00000000}
};
/*
* Refers to "D3X3" - 3x3 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "black" side.
*/
static const uint8_t resetDiscArray_3x3[9][2] PROGMEM =
{
{0b10000000, 0b00000100},
{0b10000000, 0b00001000},
{0b10001000, 0b00000000},
{0b01000000, 0b00000100},
{0b01000000, 0b00001000},
{0b01001000, 0b00000000},
{0b00010000, 0b00000100},
{0b00010000, 0b00001000},
{0b00011000, 0b00000000}
};
/*
* Refers to "D3X4" - 3x4 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "color" side.
*/
static const uint8_t setDiscArray_3x4[12][2] PROGMEM =
{
{0b00000001, 0b00010000},
{0b00000001, 0b00100000},
{0b00000101, 0b00000000},
{0b00000000, 0b00010010},
{0b00000000, 0b00100010},
{0b00000100, 0b00000010},
{0b00000010, 0b00010000},
{0b00000010, 0b00100000},
{0b00000110, 0b00000000},
{0b00100000, 0b00010000},
{0b00100000, 0b00100000},
{0b00100100, 0b00000000}
};
/*
* Refers to "D3X4" - 3x4 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "black" side.
*/
static const uint8_t resetDiscArray_3x4[12][2] PROGMEM =
{
{0b00000000, 0b10000100},
{0b00000000, 0b10001000},
{0b00001000, 0b10000000},
{0b10000000, 0b00000100},
{0b10000000, 0b00001000},
{0b10001000, 0b00000000},
{0b01000000, 0b00000100},
{0b01000000, 0b00001000},
{0b01001000, 0b00000000},
{0b00010000, 0b00000100},
{0b00010000, 0b00001000},
{0b00011000, 0b00000000}
};
/*
* Refers to "D3X5" - 3x5 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "color" side.
*/
static const uint8_t setDiscArray_3x5[15][2] PROGMEM =
{
{0b00000000, 0b00010001},
{0b00000000, 0b00100001},
{0b00000100, 0b00000001},
{0b00000001, 0b00010000},
{0b00000001, 0b00100000},
{0b00000101, 0b00000000},
{0b00000000, 0b00010010},
{0b00000000, 0b00100010},
{0b00000100, 0b00000010},
{0b00000010, 0b00010000},
{0b00000010, 0b00100000},
{0b00000110, 0b00000000},
{0b00100000, 0b00010000},
{0b00100000, 0b00100000},
{0b00100100, 0b00000000}
};
/*
* Refers to "D3X5" - 3x5 display.
* The array contains the addresses of the control outputs corresponding
* to the setting of the discs to the "black" side.
*/
static const uint8_t resetDiscArray_3x5[15][2] PROGMEM =
{
{0b00000000, 0b01000100},
{0b00000000, 0b01001000},
{0b00001000, 0b01000000},
{0b00000000, 0b10000100},
{0b00000000, 0b10001000},
{0b00001000, 0b10000000},
{0b10000000, 0b00000100},
{0b10000000, 0b00001000},
{0b10001000, 0b00000000},
{0b01000000, 0b00000100},
{0b01000000, 0b00001000},
{0b01001000, 0b00000000},
{0b00010000, 0b00000100},
{0b00010000, 0b00001000},
{0b00011000, 0b00000000}
};
/*
* Refers to "D3X5" - 3x5 display
* Compressed array of all bits corresponding to discs states for selected symbols.
* Disc numbers in individual bytes: 7,6,5,4,3,2,1,0 15,14,13,12,11,10,9,8
*/
static const uint8_t displayArray_3x5[68][2] PROGMEM =
{
{0b01101111, 0b01111011}, // 0
{0b10010111, 0b00100110}, // 1
{0b11001111, 0b01111001}, // 2
{0b10100111, 0b01111001}, // 3
{0b11100100, 0b01011011}, // 4
{0b11100111, 0b01110011}, // 5
{0b11101111, 0b01110011}, // 6
{0b10010010, 0b01111000}, // 7
{0b11101111, 0b01111011}, // 8
{0b11100111, 0b01111011}, // 9
{0b00000000, 0b00000000}, // 10/CLR - Clear display
{0b11101101, 0b00101011}, // A/11
{0b11101111, 0b01111010}, // B/12
{0b01001111, 0b01110010}, // C/13
{0b01101011, 0b00111011}, // D/14
{0b11001111, 0b01110010}, // E/15
{0b11001001, 0b01110010}, // F/16
{0b01101111, 0b01100011}, // G/17
{0b11101101, 0b01011011}, // H/18
{0b10010010, 0b00100100}, // I/19
{0b00101111, 0b01001001}, // J/20
{0b11101101, 0b01011010}, // K/21
{0b01001111, 0b00010010}, // L/22
{0b01101101, 0b01011111}, // M/23
{0b11101001, 0b01001011}, // N/24
{0b01101111, 0b01111011}, // O/25
{0b11001001, 0b01111011}, // P/26
{0b01111100, 0b01111011}, // Q/27
{0b11101101, 0b00111010}, // R/28
{0b11100111, 0b01110011}, // S/29
{0b10010010, 0b01110100}, // T/30
{0b01101111, 0b01011011}, // U/31
{0b01101010, 0b01011011}, // V/32
{0b01111101, 0b01011011}, // W/33
{0b10101101, 0b01011010}, // X/34
{0b10010010, 0b01011010}, // Y/35
{0b10001111, 0b01111000}, // Z/36
{0b00000000, 0b00110110}, // "°"/37/DEG - Degree symbol
{0b10001101, 0b01011000}, // "%"/38/PRC - Percent symbol
{0b00000000, 0b01110000}, // "¯"/39/HLU - Horizontal line - upper
{0b11000000, 0b00000001}, // "-"/40/HLM/MIN - Horizontal line - middle
{0b00000111, 0b00000000}, // "_"/41/HLL - Horizontal line - lower
{0b00000111, 0b01110000}, // "="/42/HLT - Horizontal line - upper & lower
{0b11000111, 0b01110001}, // "≡"/43/HLA - All three lines
{0b01001001, 0b00010010}, // "| "/44/VLL - Vertical line - left
{0b00100100, 0b01001001}, // " |"/45/VLR - Vertical line - right
{0b00111000, 0b00001110}, // "="/46/EQL - Equal symbol
{0b11010000, 0b00000101}, // "+"/47/PLS - Plus symbol
{0b10101000, 0b00001010}, // "*"/48/AST - Asterisk symbol
{0b10000000, 0b00000111}, // "~"/49/TLD - Tilde symbol
{0b00000100, 0b00000000}, // "."/50/DOT - Dot symbol
{0b00010000, 0b00000100}, // ":"/51/CLN - Colon symbol
{0b00100110, 0b00000000}, // ","/52/CMM - Comma symbol
{0b00000000, 0b00010010}, // "'"/53/APS - Apostrophe symbol
{0b00000000, 0b01011010}, // """/54/QTT - Quotation symbol
{0b10001001, 0b01001000}, // "/"/55/SLS - Slash symbol
{0b10100100, 0b00010010}, // "\"/56/BLS - Backslash symbol
{0b01001010, 0b00100010}, // "["/57/RBL - Round bracket left
{0b00100010, 0b00101001}, // "]"/58/RBR - Round bracket right
{0b01010100, 0b01000100}, // "<"/59/ABL - Angle bracket left
{0b00010001, 0b00010101}, // ">"/60/ABR - Angle bracket right
{0b01001111, 0b01111011}, // "@"/61/ATS - AT symbol
{0b10101110, 0b00101010}, // "&"/62/ETS - ET symbol
{0b01111101, 0b01011111}, // "#"/63/HSH - Hash symbol
{0b01110010, 0b00100111}, // "$"/64/DOL - Dollar symbol
{0b10000010, 0b00100100}, // "!"/65/EXC - Exclamation symbol
{0b10000010, 0b01111000}, // "?"/66/QST - Question symbol
{0b11111111, 0b01111111} // 67/ALL - All discs
};
class FlipDisc
{
public:
FlipDisc();
void Pin(uint16_t EN_PIN, uint16_t CH_PIN, uint16_t PL_PIN);
void Init(uint8_t MOD1, uint8_t MOD2 = 0xFF, uint8_t MOD3 = 0xFF, uint8_t MOD4 = 0xFF,
uint8_t MOD5 = 0xFF, uint8_t MOD6 = 0xFF, uint8_t MOD7 = 0xFF, uint8_t MOD8 = 0xFF);
void Disc_7Seg(uint8_t module_number, uint8_t disc_number, bool disc_status);
void Display_7Seg(uint8_t module_number, uint8_t new_data);
void Matrix_7Seg(uint8_t data1, uint8_t data2 = 0xFF, uint8_t data3 = 0xFF, uint8_t data4 = 0xFF,
uint8_t data5 = 0xFF, uint8_t data6 = 0xFF, uint8_t data7 = 0xFF, uint8_t data8 = 0xFF);
void Disc_2x1(uint8_t module_number, uint8_t dot_number, bool disc_status);
void Display_2x1(uint8_t module_number, uint8_t disc1 = 0xFF, uint8_t disc2 = 0xFF);
void Disc_3x1(uint8_t module_number, uint8_t dot_number, bool disc_status);
void Display_3x1(uint8_t module_number, uint8_t disc1 = 0xFF, uint8_t disc2 = 0xFF, uint8_t disc3 = 0xFF);
void Disc_1x3(uint8_t module_number, uint8_t discNumber, bool disc_status);
void Display_1x3(uint8_t module_number, uint8_t disc1 = 0xFF, uint8_t disc2 = 0xFF, uint8_t disc3 = 0xFF);
void Disc_1x7(uint8_t module_number, uint8_t discNumber, bool disc_status);
void Display_1x7(uint8_t module_number, uint8_t disc1 = 0xFF, uint8_t disc2 = 0xFF, uint8_t disc3 = 0xFF,
uint8_t disc4 = 0xFF, uint8_t disc5 = 0xFF, uint8_t disc6 = 0xFF, uint8_t disc7 = 0xFF);
void Disc_2x6(uint8_t module_number, uint8_t discNumber, bool disc_status);
void Display_2x6(uint8_t module_number, uint8_t row_number, uint8_t column_number, bool disc_status);
void Disc_3x3(uint8_t module_number, uint8_t discNumber, bool disc_status);
void Display_3x3(uint8_t module_number, uint8_t row_number, uint8_t column_number, bool disc_status);
void Disc_3x4(uint8_t module_number, uint8_t discNumber, bool disc_status);
void Display_3x4(uint8_t module_number, uint8_t row_number, uint8_t column_number, bool disc_status);
void Disc_3x5(uint8_t module_number, uint8_t discNumber, bool disc_status);
void Display_3x5(uint8_t module_number, uint8_t new_data);
void Matrix_3x5(uint8_t data1, uint8_t data2 = 0xFF, uint8_t data3 = 0xFF, uint8_t data4 = 0xFF,
uint8_t data5 = 0xFF, uint8_t data6 = 0xFF, uint8_t data7 = 0xFF, uint8_t data8 = 0xFF);
void Delay(uint8_t new_time_delay);
void Test(void);
void All(void);
void Clear(void);
private:
void FlipDelay(void);
void SendBlankData(uint8_t module_number, uint8_t module_type, uint8_t data_position);
void ClearAllOutputs(void);
void PrepareCurrentPulse(void);
void ReleaseCurrentPulse(void);
bool Fuse(uint8_t module_number, uint8_t module_type);
};
extern FlipDisc Flip;
#endif