1#[repr(u8)]
15#[derive(Debug, Clone, Copy)]
16#[cfg_attr(feature = "defmt", derive(defmt::Format))]
17pub enum SegmentBits {
18 SegA = 0b00000001,
20 SegB = 0b00000010,
22 SegC = 0b00000100,
24 SegD = 0b00001000,
26 SegE = 0b00010000,
28 SegF = 0b00100000,
30 SegG = 0b01000000,
32 Dot = 0b10000000,
39}
40
41impl SegmentBits {
42 pub const fn all() -> [SegmentBits; 8] {
44 [
45 SegmentBits::SegA,
46 SegmentBits::SegB,
47 SegmentBits::SegC,
48 SegmentBits::SegD,
49 SegmentBits::SegE,
50 SegmentBits::SegF,
51 SegmentBits::SegG,
52 SegmentBits::Dot,
53 ]
54 }
55
56 pub const fn all_u8() -> [u8; 8] {
58 [
59 SegmentBits::SegA as u8,
60 SegmentBits::SegB as u8,
61 SegmentBits::SegC as u8,
62 SegmentBits::SegD as u8,
63 SegmentBits::SegE as u8,
64 SegmentBits::SegF as u8,
65 SegmentBits::SegG as u8,
66 SegmentBits::Dot as u8,
67 ]
68 }
69}
70
71#[repr(u8)]
73#[derive(Debug, Clone, Copy)]
74#[cfg_attr(feature = "defmt", derive(defmt::Format))]
75pub enum DigitBits {
76 Zero = 0b00111111,
78 One = 0b00000110,
80 Two = 0b01011011,
82 Three = 0b01001111,
84 Four = 0b01100110,
86 Five = 0b01101101,
88 Six = 0b01111101,
90 Seven = 0b00000111,
92 Eight = 0b01111111,
94 Nine = 0b01101111,
96}
97
98impl DigitBits {
99 pub const fn all() -> [DigitBits; 10] {
101 [
102 DigitBits::Zero,
103 DigitBits::One,
104 DigitBits::Two,
105 DigitBits::Three,
106 DigitBits::Four,
107 DigitBits::Five,
108 DigitBits::Six,
109 DigitBits::Seven,
110 DigitBits::Eight,
111 DigitBits::Nine,
112 ]
113 }
114
115 pub const fn all_u8() -> [u8; 10] {
117 [
118 DigitBits::Zero as u8,
119 DigitBits::One as u8,
120 DigitBits::Two as u8,
121 DigitBits::Three as u8,
122 DigitBits::Four as u8,
123 DigitBits::Five as u8,
124 DigitBits::Six as u8,
125 DigitBits::Seven as u8,
126 DigitBits::Eight as u8,
127 DigitBits::Nine as u8,
128 ]
129 }
130
131 pub const fn from_digit(digit: u8) -> Self {
133 match digit {
134 0 => DigitBits::Zero,
135 1 => DigitBits::One,
136 2 => DigitBits::Two,
137 3 => DigitBits::Three,
138 4 => DigitBits::Four,
139 5 => DigitBits::Five,
140 6 => DigitBits::Six,
141 7 => DigitBits::Seven,
142 8 => DigitBits::Eight,
143 9 => DigitBits::Nine,
144 _ => DigitBits::Zero,
145 }
146 }
147}
148
149#[repr(u8)]
151#[derive(Debug, Clone, Copy)]
152#[cfg_attr(feature = "defmt", derive(defmt::Format))]
153pub enum HexDigitBits {
154 Zero = DigitBits::Zero as u8,
156 One = DigitBits::One as u8,
158 Two = DigitBits::Two as u8,
160 Three = DigitBits::Three as u8,
162 Four = DigitBits::Four as u8,
164 Five = DigitBits::Five as u8,
166 Six = DigitBits::Six as u8,
168 Seven = DigitBits::Seven as u8,
170 Eight = DigitBits::Eight as u8,
172 Nine = DigitBits::Nine as u8,
174 A = UpCharBits::UpA as u8,
176 B = LoCharBits::LoB as u8,
178 C = UpCharBits::UpC as u8,
180 D = LoCharBits::LoD as u8,
182 E = UpCharBits::UpE as u8,
184 F = UpCharBits::UpF as u8,
186}
187
188impl HexDigitBits {
189 pub const fn all() -> [HexDigitBits; 16] {
191 [
192 HexDigitBits::Zero,
193 HexDigitBits::One,
194 HexDigitBits::Two,
195 HexDigitBits::Three,
196 HexDigitBits::Four,
197 HexDigitBits::Five,
198 HexDigitBits::Six,
199 HexDigitBits::Seven,
200 HexDigitBits::Eight,
201 HexDigitBits::Nine,
202 HexDigitBits::A,
203 HexDigitBits::B,
204 HexDigitBits::C,
205 HexDigitBits::D,
206 HexDigitBits::E,
207 HexDigitBits::F,
208 ]
209 }
210
211 pub const fn all_u8() -> [u8; 16] {
213 [
214 HexDigitBits::Zero as u8,
215 HexDigitBits::One as u8,
216 HexDigitBits::Two as u8,
217 HexDigitBits::Three as u8,
218 HexDigitBits::Four as u8,
219 HexDigitBits::Five as u8,
220 HexDigitBits::Six as u8,
221 HexDigitBits::Seven as u8,
222 HexDigitBits::Eight as u8,
223 HexDigitBits::Nine as u8,
224 HexDigitBits::A as u8,
225 HexDigitBits::B as u8,
226 HexDigitBits::C as u8,
227 HexDigitBits::D as u8,
228 HexDigitBits::E as u8,
229 HexDigitBits::F as u8,
230 ]
231 }
232
233 pub const fn from_digit(digit: u8) -> Self {
235 match digit {
236 0 => HexDigitBits::Zero,
237 1 => HexDigitBits::One,
238 2 => HexDigitBits::Two,
239 3 => HexDigitBits::Three,
240 4 => HexDigitBits::Four,
241 5 => HexDigitBits::Five,
242 6 => HexDigitBits::Six,
243 7 => HexDigitBits::Seven,
244 8 => HexDigitBits::Eight,
245 9 => HexDigitBits::Nine,
246 10 => HexDigitBits::A,
247 11 => HexDigitBits::B,
248 12 => HexDigitBits::C,
249 13 => HexDigitBits::D,
250 14 => HexDigitBits::E,
251 15 => HexDigitBits::F,
252 _ => HexDigitBits::Zero,
253 }
254 }
255}
256
257#[repr(u8)]
259#[derive(Debug, Clone, Copy)]
260#[cfg_attr(feature = "defmt", derive(defmt::Format))]
261pub enum UpsideDownDigitBits {
262 Zero = 0b00111111,
264 One = 0b00110000,
266 Two = 0b01011011,
268 Three = 0b01111001,
270 Four = 0b01110100,
272 Five = 0b01101101,
274 Six = 0b01101111,
276 Seven = 0b00111000,
278 Eight = 0b01111111,
280 Nine = 0b01111101,
282}
283impl UpsideDownDigitBits {
284 pub const fn all() -> [UpsideDownDigitBits; 10] {
286 [
287 UpsideDownDigitBits::Zero,
288 UpsideDownDigitBits::One,
289 UpsideDownDigitBits::Two,
290 UpsideDownDigitBits::Three,
291 UpsideDownDigitBits::Four,
292 UpsideDownDigitBits::Five,
293 UpsideDownDigitBits::Six,
294 UpsideDownDigitBits::Seven,
295 UpsideDownDigitBits::Eight,
296 UpsideDownDigitBits::Nine,
297 ]
298 }
299
300 pub const fn all_u8() -> [u8; 10] {
302 [
303 UpsideDownDigitBits::Zero as u8,
304 UpsideDownDigitBits::One as u8,
305 UpsideDownDigitBits::Two as u8,
306 UpsideDownDigitBits::Three as u8,
307 UpsideDownDigitBits::Four as u8,
308 UpsideDownDigitBits::Five as u8,
309 UpsideDownDigitBits::Six as u8,
310 UpsideDownDigitBits::Seven as u8,
311 UpsideDownDigitBits::Eight as u8,
312 UpsideDownDigitBits::Nine as u8,
313 ]
314 }
315
316 pub const fn from_digit(digit: u8) -> Self {
318 match digit {
319 0 => UpsideDownDigitBits::Zero,
320 1 => UpsideDownDigitBits::One,
321 2 => UpsideDownDigitBits::Two,
322 3 => UpsideDownDigitBits::Three,
323 4 => UpsideDownDigitBits::Four,
324 5 => UpsideDownDigitBits::Five,
325 6 => UpsideDownDigitBits::Six,
326 7 => UpsideDownDigitBits::Seven,
327 8 => UpsideDownDigitBits::Eight,
328 9 => UpsideDownDigitBits::Nine,
329 _ => UpsideDownDigitBits::Zero,
330 }
331 }
332}
333
334#[repr(u8)]
336#[derive(Debug, Clone, Copy)]
337#[cfg_attr(feature = "defmt", derive(defmt::Format))]
338pub enum UpCharBits {
339 UpA = 0x77,
341 UpB = 0x7F,
343 UpC = 0x39,
345 UpE = 0x79,
347 UpF = SegmentBits::SegA as u8
350 | SegmentBits::SegF as u8
351 | SegmentBits::SegE as u8
352 | SegmentBits::SegG as u8,
353 UpG = 0x3D,
355 UpH = 0x76,
357 UpI = 0x30,
359 UpJ = 0x1E,
361 UpL = 0x38,
363 UpO = 0x3F,
365 UpP = 0x73,
367 UpS = 0x6D,
369 UpU = 0x3E,
371 UpZ = 0x5B,
373}
374
375impl UpCharBits {
376 pub const fn all() -> [UpCharBits; 15] {
378 [
379 UpCharBits::UpA,
380 UpCharBits::UpB,
381 UpCharBits::UpC,
382 UpCharBits::UpE,
383 UpCharBits::UpF,
384 UpCharBits::UpG,
385 UpCharBits::UpH,
386 UpCharBits::UpI,
387 UpCharBits::UpJ,
388 UpCharBits::UpL,
389 UpCharBits::UpO,
390 UpCharBits::UpP,
391 UpCharBits::UpS,
392 UpCharBits::UpU,
393 UpCharBits::UpZ,
394 ]
395 }
396
397 pub const fn all_u8() -> [u8; 15] {
399 [
400 UpCharBits::UpA as u8,
401 UpCharBits::UpB as u8,
402 UpCharBits::UpC as u8,
403 UpCharBits::UpE as u8,
404 UpCharBits::UpF as u8,
405 UpCharBits::UpG as u8,
406 UpCharBits::UpH as u8,
407 UpCharBits::UpI as u8,
408 UpCharBits::UpJ as u8,
409 UpCharBits::UpL as u8,
410 UpCharBits::UpO as u8,
411 UpCharBits::UpP as u8,
412 UpCharBits::UpS as u8,
413 UpCharBits::UpU as u8,
414 UpCharBits::UpZ as u8,
415 ]
416 }
417}
418
419#[repr(u8)]
421#[derive(Debug, Clone, Copy)]
422#[cfg_attr(feature = "defmt", derive(defmt::Format))]
423pub enum LoCharBits {
424 LoA = 0x5F,
426 LoB = 0x7C,
428 LoC = 0x58,
430 LoD = 0x5E,
432 LoE = 0x7B,
434 LoG = 0x6F,
436 LoH = 0x74,
438 LoI = 0x10,
440 LoN = 0x54,
442 LoO = 0x5C,
444 LoQ = 0x67,
446 LoR = 0x50,
448 LoT = 0x78,
450 LoU = 0x1C,
452 LoY = 0x6E,
454}
455
456impl LoCharBits {
457 pub const fn all() -> [LoCharBits; 15] {
459 [
460 LoCharBits::LoA,
461 LoCharBits::LoB,
462 LoCharBits::LoC,
463 LoCharBits::LoD,
464 LoCharBits::LoE,
465 LoCharBits::LoG,
466 LoCharBits::LoH,
467 LoCharBits::LoI,
468 LoCharBits::LoN,
469 LoCharBits::LoO,
470 LoCharBits::LoQ,
471 LoCharBits::LoR,
472 LoCharBits::LoT,
473 LoCharBits::LoU,
474 LoCharBits::LoY,
475 ]
476 }
477
478 pub const fn all_u8() -> [u8; 15] {
480 [
481 LoCharBits::LoA as u8,
482 LoCharBits::LoB as u8,
483 LoCharBits::LoC as u8,
484 LoCharBits::LoD as u8,
485 LoCharBits::LoE as u8,
486 LoCharBits::LoG as u8,
487 LoCharBits::LoH as u8,
488 LoCharBits::LoI as u8,
489 LoCharBits::LoN as u8,
490 LoCharBits::LoO as u8,
491 LoCharBits::LoQ as u8,
492 LoCharBits::LoR as u8,
493 LoCharBits::LoT as u8,
494 LoCharBits::LoU as u8,
495 LoCharBits::LoY as u8,
496 ]
497 }
498}
499
500#[repr(u8)]
502#[derive(Debug, Clone, Copy)]
503#[cfg_attr(feature = "defmt", derive(defmt::Format))]
504pub enum SpecialCharBits {
505 Space = 0,
507 Minus = SegmentBits::SegG as u8,
509 Underscore = SegmentBits::SegD as u8,
511 Equals = SegmentBits::SegG as u8 | SegmentBits::SegD as u8,
513 QuestionMark = SegmentBits::SegA as u8
515 | SegmentBits::SegB as u8
516 | SegmentBits::SegG as u8
517 | SegmentBits::SegE as u8,
518}
519
520impl SpecialCharBits {
521 pub const fn all() -> [SpecialCharBits; 5] {
523 [
524 SpecialCharBits::Space,
525 SpecialCharBits::Minus,
526 SpecialCharBits::Underscore,
527 SpecialCharBits::Equals,
528 SpecialCharBits::QuestionMark,
529 ]
530 }
531
532 pub const fn all_u8() -> [u8; 5] {
534 [
535 SpecialCharBits::Space as u8,
536 SpecialCharBits::Minus as u8,
537 SpecialCharBits::Underscore as u8,
538 SpecialCharBits::Equals as u8,
539 SpecialCharBits::QuestionMark as u8,
540 ]
541 }
542}
543
544pub const fn flip(byte: u8) -> u8 {
551 let a_d_swapped = ((byte & 0b00001000) >> 3) | ((byte & 0b00000001) << 3);
552 let b_c_swapped = ((byte & 0b00000100) >> 1) | ((byte & 0b00000010) << 1);
553 let e_f_swapped = ((byte & 0b00100000) >> 1) | ((byte & 0b00010000) << 1);
554
555 (byte & 0b11000000) | a_d_swapped | b_c_swapped | e_f_swapped
556}
557
558pub const fn mirror(byte: u8) -> u8 {
564 let b_f_swapped = ((byte & 0b00100000) >> 4) | ((byte & 0b00000010) << 4);
565 let c_e_swapped = ((byte & 0b00010000) >> 2) | ((byte & 0b00000100) << 2);
566
567 (byte & 0b11001001) | b_f_swapped | c_e_swapped
568}
569
570pub const fn flip_mirror(byte: u8) -> u8 {
574 mirror(flip(byte))
575}
576
577pub const fn from_ascii_byte(byte: u8) -> u8 {
601 match byte {
602 b'0' => DigitBits::Zero as u8,
603 b'1' => DigitBits::One as u8,
604 b'2' => DigitBits::Two as u8,
605 b'3' => DigitBits::Three as u8,
606 b'4' => DigitBits::Four as u8,
607 b'5' => DigitBits::Five as u8,
608 b'6' => DigitBits::Six as u8,
609 b'7' => DigitBits::Seven as u8,
610 b'8' => DigitBits::Eight as u8,
611 b'9' => DigitBits::Nine as u8,
612
613 b'A' => UpCharBits::UpA as u8,
614 b'B' => UpCharBits::UpB as u8,
615 b'C' => UpCharBits::UpC as u8,
616 b'E' => UpCharBits::UpE as u8,
617 b'F' => UpCharBits::UpF as u8,
618 b'G' => UpCharBits::UpG as u8,
619 b'H' => UpCharBits::UpH as u8,
620 b'I' => UpCharBits::UpI as u8,
621 b'J' => UpCharBits::UpJ as u8,
622 b'L' => UpCharBits::UpL as u8,
623 b'O' => UpCharBits::UpO as u8,
624 b'P' => UpCharBits::UpP as u8,
625 b'S' => UpCharBits::UpS as u8,
626 b'U' => UpCharBits::UpU as u8,
627 b'Z' => UpCharBits::UpZ as u8,
628
629 b'a' => LoCharBits::LoA as u8,
630 b'b' => LoCharBits::LoB as u8,
631 b'c' => LoCharBits::LoC as u8,
632 b'd' => LoCharBits::LoD as u8,
633 b'e' => LoCharBits::LoE as u8,
634 b'g' => LoCharBits::LoG as u8,
635 b'h' => LoCharBits::LoH as u8,
636 b'i' => LoCharBits::LoI as u8,
637 b'n' => LoCharBits::LoN as u8,
638 b'o' => LoCharBits::LoO as u8,
639 b'q' => LoCharBits::LoQ as u8,
640 b'r' => LoCharBits::LoR as u8,
641 b't' => LoCharBits::LoT as u8,
642 b'u' => LoCharBits::LoU as u8,
643 b'y' => LoCharBits::LoY as u8,
644
645 b' ' => SpecialCharBits::Space as u8,
646 b'-' => SpecialCharBits::Minus as u8,
647 b'_' => SpecialCharBits::Underscore as u8,
648 b'=' => SpecialCharBits::Equals as u8,
649 b'?' => SpecialCharBits::QuestionMark as u8,
650
651 _ => 0,
652 }
653}
654
655pub const fn from_char(c: char) -> u8 {
657 from_ascii_byte(c as u8)
658}
659
660pub const fn str_from_byte(byte: u8) -> &'static str {
662 if byte == SegmentBits::Dot as u8 {
663 "."
664 } else if byte == DigitBits::Zero as u8 {
665 "0"
666 } else if byte == DigitBits::One as u8 {
667 "1"
668 } else if byte == DigitBits::Two as u8 {
669 "2"
670 } else if byte == DigitBits::Three as u8 {
671 "3"
672 } else if byte == DigitBits::Four as u8 {
673 "4"
674 } else if byte == DigitBits::Five as u8 {
675 "5"
676 } else if byte == DigitBits::Six as u8 {
677 "6"
678 } else if byte == DigitBits::Seven as u8 {
679 "7"
680 } else if byte == DigitBits::Eight as u8 {
681 "8"
682 } else if byte == DigitBits::Nine as u8 {
683 "9"
684 } else if byte == UpCharBits::UpA as u8 {
685 "A"
686 } else if byte == UpCharBits::UpB as u8 {
687 "B"
688 } else if byte == UpCharBits::UpC as u8 {
689 "C"
690 } else if byte == UpCharBits::UpE as u8 {
691 "E"
692 } else if byte == UpCharBits::UpF as u8 {
693 "F"
694 } else if byte == UpCharBits::UpG as u8 {
695 "G"
696 } else if byte == UpCharBits::UpH as u8 {
697 "H"
698 } else if byte == UpCharBits::UpI as u8 {
699 "I"
700 } else if byte == UpCharBits::UpJ as u8 {
701 "J"
702 } else if byte == UpCharBits::UpL as u8 {
703 "L"
704 } else if byte == UpCharBits::UpP as u8 {
705 "P"
706 } else if byte == UpCharBits::UpU as u8 {
707 "U"
708 } else if byte == LoCharBits::LoA as u8 {
709 "a"
710 } else if byte == LoCharBits::LoB as u8 {
711 "b"
712 } else if byte == LoCharBits::LoC as u8 {
713 "c"
714 } else if byte == LoCharBits::LoD as u8 {
715 "d"
716 } else if byte == LoCharBits::LoE as u8 {
717 "e"
718 } else if byte == LoCharBits::LoG as u8 {
719 "g"
720 } else if byte == LoCharBits::LoH as u8 {
721 "h"
722 } else if byte == LoCharBits::LoI as u8 {
723 "i"
724 } else if byte == LoCharBits::LoN as u8 {
725 "n"
726 } else if byte == LoCharBits::LoO as u8 {
727 "o"
728 } else if byte == LoCharBits::LoQ as u8 {
729 "q"
730 } else if byte == LoCharBits::LoR as u8 {
731 "r"
732 } else if byte == LoCharBits::LoT as u8 {
733 "t"
734 } else if byte == LoCharBits::LoU as u8 {
735 "u"
736 } else if byte == LoCharBits::LoY as u8 {
737 "y"
738 } else if byte == SpecialCharBits::Space as u8 {
739 " "
740 } else if byte == SpecialCharBits::Minus as u8 {
741 "-"
742 } else if byte == SpecialCharBits::Underscore as u8 {
743 "_"
744 } else if byte == SpecialCharBits::Equals as u8 {
745 "="
746 } else if byte == SpecialCharBits::QuestionMark as u8 {
747 "?"
748 } else if byte == DigitBits::Zero as u8 | SegmentBits::Dot as u8 {
749 "0."
750 } else if byte == DigitBits::One as u8 | SegmentBits::Dot as u8 {
751 "1."
752 } else if byte == DigitBits::Two as u8 | SegmentBits::Dot as u8 {
753 "2."
754 } else if byte == DigitBits::Three as u8 | SegmentBits::Dot as u8 {
755 "3."
756 } else if byte == DigitBits::Four as u8 | SegmentBits::Dot as u8 {
757 "4."
758 } else if byte == DigitBits::Five as u8 | SegmentBits::Dot as u8 {
759 "5."
760 } else if byte == DigitBits::Six as u8 | SegmentBits::Dot as u8 {
761 "6."
762 } else if byte == DigitBits::Seven as u8 | SegmentBits::Dot as u8 {
763 "7."
764 } else if byte == DigitBits::Eight as u8 | SegmentBits::Dot as u8 {
765 "8."
766 } else if byte == DigitBits::Nine as u8 | SegmentBits::Dot as u8 {
767 "9."
768 } else if byte == UpCharBits::UpA as u8 | SegmentBits::Dot as u8 {
769 "A."
770 } else if byte == UpCharBits::UpB as u8 | SegmentBits::Dot as u8 {
771 "B."
772 } else if byte == UpCharBits::UpC as u8 | SegmentBits::Dot as u8 {
773 "C."
774 } else if byte == UpCharBits::UpE as u8 | SegmentBits::Dot as u8 {
775 "E."
776 } else if byte == UpCharBits::UpF as u8 | SegmentBits::Dot as u8 {
777 "F."
778 } else if byte == UpCharBits::UpG as u8 | SegmentBits::Dot as u8 {
779 "G."
780 } else if byte == UpCharBits::UpH as u8 | SegmentBits::Dot as u8 {
781 "H."
782 } else if byte == UpCharBits::UpI as u8 | SegmentBits::Dot as u8 {
783 "I."
784 } else if byte == UpCharBits::UpJ as u8 | SegmentBits::Dot as u8 {
785 "J."
786 } else if byte == UpCharBits::UpL as u8 | SegmentBits::Dot as u8 {
787 "L."
788 } else if byte == UpCharBits::UpP as u8 | SegmentBits::Dot as u8 {
789 "P."
790 } else if byte == UpCharBits::UpU as u8 | SegmentBits::Dot as u8 {
791 "U."
792 } else if byte == LoCharBits::LoA as u8 | SegmentBits::Dot as u8 {
793 "a."
794 } else if byte == LoCharBits::LoB as u8 | SegmentBits::Dot as u8 {
795 "b."
796 } else if byte == LoCharBits::LoC as u8 | SegmentBits::Dot as u8 {
797 "c."
798 } else if byte == LoCharBits::LoD as u8 | SegmentBits::Dot as u8 {
799 "d."
800 } else if byte == LoCharBits::LoE as u8 | SegmentBits::Dot as u8 {
801 "e."
802 } else if byte == LoCharBits::LoG as u8 | SegmentBits::Dot as u8 {
803 "g."
804 } else if byte == LoCharBits::LoH as u8 | SegmentBits::Dot as u8 {
805 "h."
806 } else if byte == LoCharBits::LoI as u8 | SegmentBits::Dot as u8 {
807 "i."
808 } else if byte == LoCharBits::LoN as u8 | SegmentBits::Dot as u8 {
809 "n."
810 } else if byte == LoCharBits::LoO as u8 | SegmentBits::Dot as u8 {
811 "o."
812 } else if byte == LoCharBits::LoQ as u8 | SegmentBits::Dot as u8 {
813 "q."
814 } else if byte == LoCharBits::LoR as u8 | SegmentBits::Dot as u8 {
815 "r."
816 } else if byte == LoCharBits::LoT as u8 | SegmentBits::Dot as u8 {
817 "t."
818 } else if byte == LoCharBits::LoU as u8 | SegmentBits::Dot as u8 {
819 "u."
820 } else if byte == LoCharBits::LoY as u8 | SegmentBits::Dot as u8 {
821 "y."
822 } else if byte == SpecialCharBits::Minus as u8 | SegmentBits::Dot as u8 {
823 "-."
824 } else if byte == SpecialCharBits::Underscore as u8 | SegmentBits::Dot as u8 {
825 "_."
826 } else if byte == SpecialCharBits::Equals as u8 | SegmentBits::Dot as u8 {
827 "=."
828 } else if byte == SpecialCharBits::QuestionMark as u8 | SegmentBits::Dot as u8 {
829 "?."
830 } else {
831 ""
832 }
833}
834
835#[cfg(test)]
836mod tests {
837 use super::*;
838
839 #[test]
840 fn flipped_four() {
841 let four = DigitBits::Four as u8;
842 let flipped_four = flip(four);
843 let should_flipped_four = SegmentBits::SegB as u8
844 | SegmentBits::SegC as u8
845 | SegmentBits::SegE as u8
846 | SegmentBits::SegG as u8;
847
848 assert_eq!(flipped_four, should_flipped_four);
849 }
850
851 #[test]
852 fn flipped_e() {
853 let e = UpCharBits::UpE as u8;
854 let flipped_e = flip(e);
855 let should_flipped_e = UpCharBits::UpE as u8;
856
857 assert_eq!(flipped_e, should_flipped_e);
858 }
859
860 #[test]
861 fn mirrored_four() {
862 let four = DigitBits::Four as u8;
863 let mirrored_four = mirror(four);
864 let should_mirrored_four = SegmentBits::SegB as u8
865 | SegmentBits::SegE as u8
866 | SegmentBits::SegF as u8
867 | SegmentBits::SegG as u8;
868
869 assert_eq!(mirrored_four, should_mirrored_four);
870 }
871
872 #[test]
873 fn mirrored_e() {
874 let e = UpCharBits::UpE as u8;
875 let mirrored_e = mirror(e);
876 let should_mirrored_e = SegmentBits::SegA as u8
877 | SegmentBits::SegB as u8
878 | SegmentBits::SegC as u8
879 | SegmentBits::SegD as u8
880 | SegmentBits::SegG as u8;
881
882 assert_eq!(mirrored_e, should_mirrored_e);
883 }
884
885 #[test]
886 fn flipped_mirrored_four() {
887 let four = DigitBits::Four as u8;
888 let flipped_mirrored_four = flip_mirror(four);
889 let should_flipped_mirrored_four = SegmentBits::SegC as u8
890 | SegmentBits::SegE as u8
891 | SegmentBits::SegF as u8
892 | SegmentBits::SegG as u8;
893
894 assert_eq!(flipped_mirrored_four, should_flipped_mirrored_four);
895 }
896
897 #[test]
898 fn mirrored_flipped_is_flipped_mirrored() {
899 let four = DigitBits::Four as u8;
900
901 let mirrored_flipped_four = mirror(flip(four));
902 let flipped_mirrored_four = flip(mirror(four));
903
904 assert_eq!(mirrored_flipped_four, flipped_mirrored_four);
905 }
906
907 #[test]
908 fn flipped_flipped_is_original() {
909 let seven = DigitBits::Seven as u8;
910
911 let flipped_flipped_seven = flip(flip(seven));
912
913 assert_eq!(seven, flipped_flipped_seven);
914 }
915
916 #[test]
917 fn mirrored_mirrored_is_original() {
918 let five = DigitBits::Five as u8;
919
920 let mirrored_mirrored_five = mirror(mirror(five));
921
922 assert_eq!(five, mirrored_mirrored_five);
923 }
924}