#no-std #embedded #keyboard #hardware-support

no-std kiibohd-hall-effect-keyscanning

Hall Effect keyscanning for strobed matrices

5 releases

new 0.2.0 May 19, 2023
0.1.3 Nov 29, 2022
0.1.2 Nov 17, 2022
0.1.1 Jun 2, 2022
0.1.0 Apr 30, 2022

#324 in Embedded development

Download history 22/week @ 2023-01-27 16/week @ 2023-02-03 29/week @ 2023-02-10 22/week @ 2023-02-17 23/week @ 2023-02-24 14/week @ 2023-03-03 13/week @ 2023-03-10 14/week @ 2023-03-17 15/week @ 2023-03-24 18/week @ 2023-03-31 21/week @ 2023-04-07 21/week @ 2023-04-14 16/week @ 2023-04-21 14/week @ 2023-04-28 23/week @ 2023-05-05 17/week @ 2023-05-12

72 downloads per month

MIT/Apache

120KB
2K SLoC

kiibohd-hall-effect-keyscanning

Rust docs.rs Crates.io Crates.io Crates.io

Keyscanning embedded-hal driver for kiibohd-hall-effect. Can be used with single-shot, interrupt or DMA-connected ADC drivers.

Usage

const ADC_SAMPLES: usize = 1;
const RSIZE: usize = 6; // Matrix rows
const CSIZE: usize = 12; // Matrix columns
const MSIZE: usize = RSIZE * CSIZE; // Total matrix size
type Matrix = kiibohd_hall_effect_keyscanning::Matrix<PioX<Output<PushPull>>, CSIZE, MSIZE>;

let mut matrix = Matrix::new(cols).unwrap();
matrix.next_strobe().unwrap(); // Strobe first column

// Retrieve adc sample and key index
let sample = read_adc();
let index = determine_key_index();

// Store the sample value at the specified index
// ADC_SAMPLES specifies how many samples are needed (averaged) until a processed sense value is returned
match matrix.record::<ADC_SAMPLES>(index, sample) {
		Ok(val) => {
				// If data bucket has accumulated enough samples, pass to the next stage
				if let Some(sense) = val {
						// Processed ADC data
				}
		}
		Err(e) => {
		    // Usually this is an index error
				defmt::error!("Sample record failed ({}, {}, {}):{} -> {}", i, strobe, index, sample, e);
		}

Building

cargo build

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.5–1MB
~18K SLoC