Struct kiibohd_hall_effect_keyscanning::Matrix
source · pub struct Matrix<C: OutputPin, const CSIZE: usize, const MSIZE: usize, const INVERT_STROBE: bool> { /* private fields */ }
Expand description
Handles strobing the Hall Effect sensor matrix ADC reading is handled separately as the current embedded-hal doesn’t work well across oneshot, interrupt based and DMA ADC read methods. (usually requires quite a bit of MCU specific setup as well)
ⓘ
const CSIZE: usize = 18; // Number of columns
const RSIZE: usize = 6; // Number of rows
const MSIZE: usize = RSIZE * CSIZE; // Total matrix size
const INVERT_STROBE: bool = true; // P-Channel MOSFETs have an inverted strobe
type Matrix = kiibohd_hall_effect_keyscanning::Matrix<PioX<Output<PushPull>>, CSIZE, MSIZE, INVERT_STROBE>; // atsam4-hal
let cols = [
pins.strobe1.downgrade(),
pins.strobe2.downgrade(),
pins.strobe3.downgrade(),
pins.strobe4.downgrade(),
pins.strobe5.downgrade(),
pins.strobe6.downgrade(),
pins.strobe7.downgrade(),
pins.strobe8.downgrade(),
pins.strobe9.downgrade(),
pins.strobe10.downgrade(),
pins.strobe11.downgrade(),
pins.strobe12.downgrade(),
pins.strobe13.downgrade(),
pins.strobe14.downgrade(),
pins.strobe15.downgrade(),
pins.strobe16.downgrade(),
pins.strobe17.downgrade(),
pins.strobe18.downgrade(),
];
let mut matrix = Matrix::new(cols).unwrap();
Implementations§
source§impl<C: OutputPin, const CSIZE: usize, const MSIZE: usize, const INVERT_STROBE: bool> Matrix<C, CSIZE, MSIZE, INVERT_STROBE>
impl<C: OutputPin, const CSIZE: usize, const MSIZE: usize, const INVERT_STROBE: bool> Matrix<C, CSIZE, MSIZE, INVERT_STROBE>
pub fn new( cols: [C; CSIZE], mode: SensorMode, activation: i16, deactivation: i16 ) -> Result<Self, SensorError>
sourcepub fn clear<'a, E: 'a>(&'a mut self) -> Result<(), E>where
C: OutputPin<Error = E>,
pub fn clear<'a, E: 'a>(&'a mut self) -> Result<(), E>where C: OutputPin<Error = E>,
Clears strobes Resets strobe counter to the last element (so next_strobe starts at 0)
sourcepub fn next_strobe<'a, E: 'a>(&'a mut self) -> Result<usize, E>where
C: OutputPin<Error = E>,
pub fn next_strobe<'a, E: 'a>(&'a mut self) -> Result<usize, E>where C: OutputPin<Error = E>,
Next strobe
sourcepub fn record<const IDLE_LIMIT: usize>(
&mut self,
index: usize,
value: u16
) -> Result<Option<&SenseData>, SensorError>
pub fn record<const IDLE_LIMIT: usize>( &mut self, index: usize, value: u16 ) -> Result<Option<&SenseData>, SensorError>
Record ADC Hall Effect reading for the given the current row/sense index The sense index is usually 0-5, though it depends on the typical setup IDLE_LIMIT - Number of samples before considering the sensor idle (within the configured range)
Auto Trait Implementations§
impl<C, const CSIZE: usize, const MSIZE: usize, const INVERT_STROBE: bool> RefUnwindSafe for Matrix<C, CSIZE, MSIZE, INVERT_STROBE>where C: RefUnwindSafe,
impl<C, const CSIZE: usize, const MSIZE: usize, const INVERT_STROBE: bool> Send for Matrix<C, CSIZE, MSIZE, INVERT_STROBE>where C: Send,
impl<C, const CSIZE: usize, const MSIZE: usize, const INVERT_STROBE: bool> Sync for Matrix<C, CSIZE, MSIZE, INVERT_STROBE>where C: Sync,
impl<C, const CSIZE: usize, const MSIZE: usize, const INVERT_STROBE: bool> Unpin for Matrix<C, CSIZE, MSIZE, INVERT_STROBE>where C: Unpin,
impl<C, const CSIZE: usize, const MSIZE: usize, const INVERT_STROBE: bool> UnwindSafe for Matrix<C, CSIZE, MSIZE, INVERT_STROBE>where C: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more