From d03b00e3f0d1abcb69cb29694571aa3c70c94b24 Mon Sep 17 00:00:00 2001 From: Sofia Date: Sat, 16 May 2026 21:12:50 +0300 Subject: [PATCH] Print AT responses to screen --- src/main.rs | 70 +++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4028d47..94fca94 100644 --- a/src/main.rs +++ b/src/main.rs @@ -103,26 +103,10 @@ fn main() -> ! { }); display.set_tearing(display::TearingMode::Off); - display.draw_rect( - Position::new(0, 0), - Position::new(32, 32), - Rgb565::yellow().as_color(), - ); - let font_renderer = FontRenderer::create(30); - font_renderer.render( - &mut display, - "Hello\nWorld!", - Position::new(0, 0), - HorizontalAlignment::LeftToRight, - VerticalAlignment::TopToBottom, - Rgb565::black(), - Rgb565::white(), - ); - - let sim_rst = Output::new(peripherals.GPIO15, Level::High, OutputConfig::default()); - let sim_pwr_key = Output::new(peripherals.GPIO33, Level::High, OutputConfig::default()); + let sim_rst = Output::new(peripherals.GPIO27, Level::High, OutputConfig::default()); + let sim_pwr_key = Output::new(peripherals.GPIO12, Level::High, OutputConfig::default()); let uart = Uart::new( peripherals.UART2, @@ -143,20 +127,44 @@ fn main() -> ! { delay: Delay::new(), }; - // at_commands.init(); - // log::info!("{}", at_commands.raw_command("ATI".to_owned())); - // log::info!("{}", at_commands.raw_command("AT+CMGF?".to_owned())); - // log::info!("{}", at_commands.raw_command("AT+CPIN=1234".to_owned())); - // log::info!("{}", at_commands.raw_command("AT+CPIN?".to_owned())); - // log::info!("{}", at_commands.raw_command("AT+CMGF=1".to_owned())); - // log::info!("{}", at_commands.raw_command("AT+CSCS=?".to_owned())); + font_renderer.render( + &mut display, + "Hello\nWorld!", + Position::new(0, 0), + HorizontalAlignment::LeftToRight, + VerticalAlignment::TopToBottom, + Rgb565::black(), + Rgb565::white(), + ); - // log::info!( - // "{}", - // at_commands.raw_two_part_command( - // "AT+CMGS=\"number\"".to_owned(), - // "hello".to_owned() - // ) + let mut render_response = |response: alloc::string::String| { + log::info!("Rendering: {}", response); + display.draw_rect( + Position::new(0, 0), + Position::new(240, 240), + Rgb565::black().as_color(), + ); + + font_renderer.render( + &mut display, + response, + Position::new(0, 0), + HorizontalAlignment::LeftToRight, + VerticalAlignment::TopToBottom, + Rgb565::black(), + Rgb565::white(), + ); + }; + + at_commands.init(); + render_response(at_commands.raw_command("ATI".to_owned())); + render_response(at_commands.raw_command("AT+CMGF?".to_owned())); + render_response(at_commands.raw_command("AT+CPIN=1234".to_owned())); + render_response(at_commands.raw_command("AT+CPIN?".to_owned())); + render_response(at_commands.raw_command("AT+CMGF=1".to_owned())); + render_response(at_commands.raw_command("AT+CSCS=?".to_owned())); + // render_response( + // at_commands.raw_two_part_command("AT+CMGS=\"number\"".to_owned(), "hello".to_owned()), // ); let pull_down_cfg = InputConfig::default().with_pull(esp_hal::gpio::Pull::None);