Skip to content
Snippets Groups Projects
Commit b3c546ae authored by Stephen D's avatar Stephen D
Browse files

fix keyboard bug

parent a949d08c
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ use embedded_hal::{
digital::v2::{InputPin, OutputPin},
};
use rp2040_hal::Timer;
use rtt_target::rprintln;
pub struct Keyboard<
// col
......@@ -60,7 +61,8 @@ impl<
let mut out = 0;
for x in 0..6 {
self.write_cols(1 << x);
// +2 gets us to QF (col 6)
self.write_cols(1 << (x + 2));
self.timer.delay_ms(1);
......@@ -75,16 +77,17 @@ impl<
out
}
fn write_cols(&mut self, val: u8) {
for i in 0..8 {
// 1s in val are low
// 0s are high
// indexes from furthest pin (QH on second shift register)
fn write_cols(&mut self, val: u16) {
for i in 0..16 {
self.col_ser
.set_state(((val & (1 << i)) > 0).into())
.set_state(((val & (1 << i)) == 0).into())
.unwrap();
self.timer.delay_ms(1);
self.col_clk.set_low().unwrap();
self.timer.delay_ms(1);
self.col_clk.set_high().unwrap();
self.timer.delay_ms(1);
}
self.col_rclk.set_low().unwrap();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment