From 03f560b2c13d7dcc701cab79953837bf46e51eaf Mon Sep 17 00:00:00 2001 From: Sofia Date: Fri, 29 May 2026 18:34:20 +0300 Subject: [PATCH] Add preliminary keypad support --- src/main.rs | 16 ++++++++++++++-- src/sx1509.rs | 10 ++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4fa983b..23726e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -141,13 +141,25 @@ fn main() -> ! { ); sx1509.init().unwrap(); - sx1509.set_pin_dir(15, sx1509::PinDirection::InputPullUp, true); + sx1509.set_pin_dir(0, sx1509::PinDirection::Output, false); + sx1509.set_pin_dir(1, sx1509::PinDirection::InputPullUp, false); + sx1509.set_pin_dir(2, sx1509::PinDirection::Output, false); + sx1509.set_pin_dir(3, sx1509::PinDirection::InputPullUp, false); + sx1509.set_pin_dir(4, sx1509::PinDirection::Output, false); + sx1509.set_pin_dir(5, sx1509::PinDirection::InputPullUp, false); + sx1509.set_pin_dir(6, sx1509::PinDirection::InputPullUp, false); let delay = Delay::new(); loop { delay.delay_millis(500); - log::info!("Pin: {:?}", sx1509.read_pin(15)); + sx1509.write_pin(0, true); + log::info!("Pin 1: {:?}", sx1509.read_pin(1)); + log::info!("Pin 3: {:?}", sx1509.read_pin(3)); + log::info!("Pin 5: {:?}", sx1509.read_pin(5)); + log::info!("Pin 6: {:?}", sx1509.read_pin(6)); + + sx1509.write_pin(0, false); } // let mut at_commands = ATCommands::new(sim_rst, sim_pwr_key, uart); diff --git a/src/sx1509.rs b/src/sx1509.rs index 9ed8f14..e5e1596 100644 --- a/src/sx1509.rs +++ b/src/sx1509.rs @@ -159,4 +159,14 @@ impl<'d> Sx1509<'d> { pub fn led_driver_init(&mut self, pin: u8) { todo!() } + + pub fn keypad( + &mut self, + rows: u8, + columns: u8, + sleep_time: u16, + scan_time: u16, + debounce_time: u8, + ) { + } }