tm1637_embedded_hal/options/circles/
bits.rs

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
use crate::mappings::SegmentBits;

/// Rotating circle bits.
#[repr(u8)]
#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RotatingCircleBits {
    /// ```text
    ///   ---
    ///  |   |
    ///  |
    ///   ---
    ///```
    A = SegmentBits::SegB as u8
        | SegmentBits::SegA as u8
        | SegmentBits::SegF as u8
        | SegmentBits::SegE as u8
        | SegmentBits::SegD as u8,
    /// ```text
    ///   ---
    ///  |
    ///  |   |
    ///   ---
    ///```
    B = SegmentBits::SegA as u8
        | SegmentBits::SegF as u8
        | SegmentBits::SegE as u8
        | SegmentBits::SegD as u8
        | SegmentBits::SegC as u8,
    /// ```text
    ///   
    ///  |   |
    ///  |   |
    ///   ---
    ///```
    C = SegmentBits::SegF as u8
        | SegmentBits::SegE as u8
        | SegmentBits::SegD as u8
        | SegmentBits::SegC as u8
        | SegmentBits::SegB as u8,
    /// ```text
    ///   ---
    ///      |
    ///  |   |
    ///   ---
    ///```
    D = SegmentBits::SegE as u8
        | SegmentBits::SegD as u8
        | SegmentBits::SegC as u8
        | SegmentBits::SegB as u8
        | SegmentBits::SegA as u8,
    /// ```text
    ///   ---
    ///  |   |
    ///      |
    ///   ---
    ///```
    E = SegmentBits::SegD as u8
        | SegmentBits::SegC as u8
        | SegmentBits::SegB as u8
        | SegmentBits::SegA as u8
        | SegmentBits::SegF as u8,
    /// ```text
    ///   ---
    ///  |   |
    ///  |   |
    ///   
    ///```
    F = SegmentBits::SegC as u8
        | SegmentBits::SegB as u8
        | SegmentBits::SegA as u8
        | SegmentBits::SegF as u8
        | SegmentBits::SegE as u8,
}

impl RotatingCircleBits {
    /// Returns all rotating circle bits.
    pub const fn all() -> [RotatingCircleBits; 6] {
        [
            RotatingCircleBits::A,
            RotatingCircleBits::B,
            RotatingCircleBits::C,
            RotatingCircleBits::D,
            RotatingCircleBits::E,
            RotatingCircleBits::F,
        ]
    }

    /// Resturns all rotating circle bits reversed.
    pub const fn all_reversed() -> [RotatingCircleBits; 6] {
        [
            RotatingCircleBits::F,
            RotatingCircleBits::E,
            RotatingCircleBits::D,
            RotatingCircleBits::C,
            RotatingCircleBits::B,
            RotatingCircleBits::A,
        ]
    }

    /// Returns all rotating circle bits as [`u8`].
    pub const fn all_u8() -> [u8; 6] {
        [
            RotatingCircleBits::A as u8,
            RotatingCircleBits::B as u8,
            RotatingCircleBits::C as u8,
            RotatingCircleBits::D as u8,
            RotatingCircleBits::E as u8,
            RotatingCircleBits::F as u8,
        ]
    }

    /// Resturns all rotating circle bits reversed as [`u8`].
    pub const fn all_u8_reversed() -> [u8; 6] {
        [
            RotatingCircleBits::F as u8,
            RotatingCircleBits::E as u8,
            RotatingCircleBits::D as u8,
            RotatingCircleBits::C as u8,
            RotatingCircleBits::B as u8,
            RotatingCircleBits::A as u8,
        ]
    }
}