From c387b5ebf8bd7726fb5b3546955a6b77e08adc7f Mon Sep 17 00:00:00 2001 From: sawyer bristol Date: Sun, 6 Jul 2025 11:10:41 -0600 Subject: [PATCH] update display driver --- Cargo.lock | 1 + Cargo.toml | 3 +-- src/display.rs | 29 ++++++----------------------- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b6773f..1dc6e45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1741,6 +1741,7 @@ dependencies = [ [[package]] name = "st7365p-lcd" version = "0.10.0" +source = "git+https://github.com/legitcamper/st7365p-lcd-rs?branch=async#f826038c0c8e4150be8581d30a8c6fe480947f66" dependencies = [ "embedded-graphics-core", "embedded-hal 1.0.0", diff --git a/Cargo.toml b/Cargo.toml index 7595054..01e4fec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,8 +71,7 @@ defmt-rtt = "0.4.2" embedded-graphics = { version = "0.8.1" } embedded-sdmmc = { git = "https://github.com/Be-ing/embedded-sdmmc-rs", branch = "bisync", default-features = false } -# st7365p-lcd = { git = "https://github.com/legitcamper/st7365p-lcd-rs" } -st7365p-lcd = { path = "../ST7365P-lcd-rs" } +st7365p-lcd = { git = "https://github.com/legitcamper/st7365p-lcd-rs", branch = "async" } static_cell = "2.1.1" bitflags = "2.9.1" diff --git a/src/display.rs b/src/display.rs index 4a3ec11..9726122 100644 --- a/src/display.rs +++ b/src/display.rs @@ -20,42 +20,25 @@ use st7365p_lcd::{FrameBuffer, ST7365P}; type SPI = Spi<'static, SPI1, Async>; -type FRAMEBUFFER = FrameBuffer< - SCREEN_WIDTH, - SCREEN_HEIGHT, - ExclusiveDevice, Output<'static>, Delay>, - Output<'static>, - Output<'static>, ->; +type FRAMEBUFFER = FrameBuffer; const SCREEN_WIDTH: usize = 320; const SCREEN_HEIGHT: usize = 320; -const SCREEN_ROWS: usize = 15; -const SCREEN_COLS: usize = 31; -const FONT: MonoFont = FONT_10X20; -const COLOR: Rgb565 = Rgb565::CSS_LAWN_GREEN; #[embassy_executor::task] pub async fn display_task(spi: SPI, cs: PIN_13, data: PIN_14, reset: PIN_15) { let spi_device = ExclusiveDevice::new(spi, Output::new(cs, Level::Low), Delay).unwrap(); - let display = ST7365P::new( + let mut display = ST7365P::new( spi_device, Output::new(data, Level::Low), Some(Output::new(reset, Level::High)), false, true, - SCREEN_WIDTH as u32, - SCREEN_HEIGHT as u32, ); - let mut framebuffer: FRAMEBUFFER = FrameBuffer::new(display); + display.init(&mut Delay).await.unwrap(); + display.set_custom_orientation(0x60).await.unwrap(); - framebuffer.init(&mut Delay).await.unwrap(); - framebuffer.display.set_offset(0, 0); - framebuffer - .display - .set_custom_orientation(0x60) - .await - .unwrap(); + let mut framebuffer: FRAMEBUFFER = FrameBuffer::new(); Text::with_alignment( "Hello!", @@ -67,7 +50,7 @@ pub async fn display_task(spi: SPI, cs: PIN_13, data: PIN_14, reset: PIN_15) { .unwrap(); loop { - framebuffer.draw().await.unwrap(); + framebuffer.draw(&mut display).await.unwrap(); Timer::after_millis(500).await; } }