diff --git a/src/keyboard.rs b/src/keyboard.rs index 7a0ae4e7b08e344b557f517ea42e35c331b1ca24..e787964717dc95473171e989ebab861c5cc2d878 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -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();