#![no_std] use embedded_hal::i2c::SevenBitAddress; pub const I2C_ADDR: SevenBitAddress = 0b0_0110100; pub struct TCA8418 { i2c: I2C, } #[derive(Clone, Copy)] pub struct MatrixConfig { rows: u8, columns: u16, } impl MatrixConfig { /// A new config where the matrix has no rows or columns and all of the pins are /// allocated for GPIO. pub const fn new_empty() -> Self { MatrixConfig { rows: 0, columns: 0, } } /// Add a row to the keyboard matrix, meaning its pin will not be available for GPIO. /// /// `row_number` must be in the range `0..=7` pub const fn with_row(self, row_number: u8) -> Self { if row_number >= 8 { panic!("row_number out of bounds"); } MatrixConfig { rows: self.rows | (1 << row_number), columns: self.columns, } } /// Add a column to the keyboard matrix, meaning its pin will not be available for GPIO. /// /// `column_number` must be in the range `0..=9` pub const fn with_column(self, column_number: u8) -> Self { if column_number >= 10 { panic!("column_number out of bounds"); } MatrixConfig { rows: self.rows, columns: self.columns | (1 << column_number), } } }