blinksy 0.10.0

no-std, no-alloc LED control library designed for 1D, 2D, and 3D layouts
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pub enum BitOrder {
    MostSignificantBit,
    LeastSignificantBit,
}

pub fn u8_to_bits(byte: &u8, order: BitOrder) -> [bool; 8] {
    let bit_positions = match order {
        BitOrder::MostSignificantBit => [128, 64, 32, 16, 8, 4, 2, 1],
        BitOrder::LeastSignificantBit => [1, 2, 4, 8, 16, 32, 64, 128],
    };
    #[allow(clippy::match_like_matches_macro)]
    bit_positions.map(|bit_position| match byte & bit_position {
        0 => false,
        _ => true,
    })
}