diff --git a/src/at_commands.rs b/src/at_commands.rs index 7fe9831..b14c81f 100644 --- a/src/at_commands.rs +++ b/src/at_commands.rs @@ -99,6 +99,7 @@ impl<'a, 'd> ATCommands<'a, 'd> { self.uart.read_ready() } { let length = self.uart.read(&mut buffer).unwrap(); + log::info!("{:?}", &buffer[..length]); contents += str::from_utf8(&buffer[..length]).unwrap(); } diff --git a/src/main.rs b/src/main.rs index d505f0a..d9238da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,7 +87,7 @@ fn main() -> ! { let _ = peripherals.GPIO10; let _ = peripherals.GPIO11; let _ = peripherals.GPIO16; - let _ = peripherals.GPIO20; + let _ = peripherals.GPIO17; esp_alloc::heap_allocator!(#[esp_hal::ram(reclaimed)] size: 98768); @@ -101,9 +101,9 @@ fn main() -> ! { ) .unwrap() .with_sck(peripherals.GPIO5) - .with_mosi(peripherals.GPIO18) - .with_miso(peripherals.GPIO19) - .with_cs(peripherals.GPIO21); + .with_mosi(peripherals.GPIO19) + .with_miso(peripherals.GPIO21) + .with_cs(peripherals.GPIO4); let rst = Output::new(peripherals.GPIO14, Level::Low, OutputConfig::default()); let dc = Output::new(peripherals.GPIO32, Level::Low, OutputConfig::default()); @@ -133,8 +133,8 @@ fn main() -> ! { .with_sw_flow_ctrl(uart::SwFlowControl::Disabled), ) .unwrap() - .with_rx(peripherals.GPIO16) - .with_tx(peripherals.GPIO17); + .with_rx(peripherals.GPIO7) + .with_tx(peripherals.GPIO8); let mut at_commands = ATCommands { rst: sim_rst, @@ -182,11 +182,6 @@ fn main() -> ! { // let input_6 = Input::new(peripherals.GPIO26, pull_up_cfg); // let input_7 = Input::new(peripherals.GPIO27, pull_up_cfg); - let button = Input::new( - peripherals.GPIO13, - InputConfig::default().with_pull(esp_hal::gpio::Pull::Up), - ); - static mut THREAD_2_STACK: Stack<{ 30 * 1024 }> = esp_hal::system::Stack { mem: MaybeUninit::new([0u8; 30 * 1024]), }; @@ -203,10 +198,73 @@ fn main() -> ! { }, { let io = async_io.clone(); - || thread_2_main(io, at_commands, button) + || thread_2_main(io, at_commands) }, ); + // let mut pin_1 = Output::new(peripherals.GPIO13, Level::Low, OutputConfig::default()); + // let mut pin_2 = Output::new(peripherals.GPIO33, Level::High, OutputConfig::default()); + // let mut pin_3 = Output::new(peripherals.GPIO15, Level::Low, OutputConfig::default()); + // let mut pin_4 = Output::new(peripherals.GPIO22, Level::Low, OutputConfig::default()); + // let mut pin_5 = Output::new(peripherals.GPIO26, Level::Low, OutputConfig::default()); + // let mut pin_6 = Output::new(peripherals.GPIO23, Level::Low, OutputConfig::default()); + // let mut pin_7 = Output::new(peripherals.GPIO25, Level::Low, OutputConfig::default()); + + // // let mut pins = [pin_1, pin_2, pin_3, pin_4, pin_5, pin_6, pin_7]; + // let delay = Delay::new(); + + // loop { + // pin_3.set_low(); + // delay.delay_millis(300); + // pin_3.set_high(); + // delay.delay_millis(300); + // } + + // let pin_1 = Input::new( + // peripherals.GPIO13, + // InputConfig::default().with_pull(esp_hal::gpio::Pull::Up), + // ); + // let mut pin_2 = Output::new(peripherals.GPIO33, Level::High, OutputConfig::default()); + // let pin_3 = Input::new( + // peripherals.GPIO15, + // InputConfig::default().with_pull(esp_hal::gpio::Pull::Up), + // ); + // let mut pin_4 = Output::new(peripherals.GPIO22, Level::High, OutputConfig::default()); + // let pin_5 = Input::new( + // peripherals.GPIO26, + // InputConfig::default().with_pull(esp_hal::gpio::Pull::Up), + // ); + // let mut pin_6 = Output::new(peripherals.GPIO23, Level::High, OutputConfig::default()); + // let mut pin_7 = Output::new(peripherals.GPIO25, Level::High, OutputConfig::default()); + + // let col_pins = [pin_3, pin_1, pin_5]; + // let mut row_pins = [pin_2, pin_7, pin_6, pin_4]; + // let keypad = [ + // ['1', '2', '3'], + // ['4', '5', '6'], + // ['7', '8', '9'], + // ['*', '0', '#'], + // ]; + + // let delay = Delay::new(); + + // loop { + // delay.delay_millis(100); + // for row in 0..4usize { + // row_pins[row].set_low(); + // delay.delay_millis(10); + // for col in 0..3usize { + // if col_pins[col].is_low() { + // log::info!("Key: {}", keypad[row][col]); + // } + // } + // row_pins[row].set_high(); + // delay.delay_millis(10); + // } + // state_mgr.update(); + // state_mgr.draw(); + // } + loop { state_mgr.update(); state_mgr.draw(); @@ -215,7 +273,7 @@ fn main() -> ! { // for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.1.0/examples } -fn thread_2_main(async_io: AsyncIO, mut at_commands: ATCommands<'static, 'static>, button: Input) { +fn thread_2_main(async_io: AsyncIO, mut at_commands: ATCommands<'static, 'static>) { loop { if let Some(command) = unsafe { async_io.check_at_command() } { let response = match command { @@ -236,9 +294,5 @@ fn thread_2_main(async_io: AsyncIO, mut at_commands: ATCommands<'static, 'static }; unsafe { async_io.set_at_response(response) }; } - - unsafe { - async_io.button.set_pressed(button.is_low()); - }; } }