tm1637_embedded_hal/
brightness.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
//! Brightness level for the `TM1637` device.

/// The brightness level.
///
/// Represents a byte that can be sent directly to the `TM1637` to set the brightness level.
///
/// ## Bits:
/// - 1-3: Brightness level (0-7)
/// - 4: Display state (0 - off, 1 - on). Always on.
/// - 5-7: Base address
#[repr(u8)]
#[derive(Clone, Copy)]
#[cfg_attr(feature = "impl-defmt-format", derive(defmt::Format))]
#[cfg_attr(feature = "impl-debug", derive(core::fmt::Debug))]
pub enum Brightness {
    /// Brightness level 0. Lowest brightness.
    L0 = 0b10001000,
    /// Brightness level 1.
    L1 = 0b10001001,
    /// Brightness level 2.
    L2 = 0b10001010,
    /// Brightness level 3.
    L3 = 0b10001011,
    /// Brightness level 4.
    L4 = 0b10001100,
    /// Brightness level 5.
    L5 = 0b10001101,
    /// Brightness level 6.
    L6 = 0b10001110,
    /// Brightness level 7. Highest brightness.
    L7 = 0b10001111,
}

/// Display state.
///
/// Represents a byte that can be sent directly to the `TM1637` to set the display state.
#[repr(u8)]
#[derive(Clone, Copy)]
#[cfg_attr(feature = "impl-defmt-format", derive(defmt::Format))]
#[cfg_attr(feature = "impl-debug", derive(core::fmt::Debug))]
#[cfg(any(feature = "async", feature = "blocking"))]
pub(crate) enum DisplayState {
    /// Display off.
    Off = 0b10000000,
}