From a340c9083ace748d132946cfff9a9b9fa2876908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Wo=C5=BAniak?= Date: Thu, 3 Oct 2024 16:25:41 +0200 Subject: [PATCH] WOrking on partial refresh --- epd-waveshare/src/epd3in7/mod.rs | 27 +++++---------------------- src/apps/maze_game.rs | 4 ++-- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/epd-waveshare/src/epd3in7/mod.rs b/epd-waveshare/src/epd3in7/mod.rs index e8ed9a7..507f5b1 100644 --- a/epd-waveshare/src/epd3in7/mod.rs +++ b/epd-waveshare/src/epd3in7/mod.rs @@ -260,29 +260,12 @@ where width: u32, height: u32, ) -> Result<(), SPI::Error> { - let i = &mut self.interface; - i.cmd(spi, Command::SetRamXAddressStartEndPosition); - i.data(spi, &[(x >> 8) as u8])?; - let tmp = x & 0xf8; - i.data(spi, &[tmp as u8])?; // x should be the multiple of 8, the last 3 bit will always be ignored - let tmp = tmp + width - 1; - i.data(spi, &[(tmp >> 8) as u8])?; - i.data(spi, &[(tmp | 0x07) as u8])?; - - i.cmd(spi, Command::SetRamYAddressStartEndPosition); - i.data(spi, &[(y >> 8) as u8])?; - i.data(spi, &[y as u8])?; - i.data(spi, &[((y + height - 1) >> 8) as u8])?; - i.data(spi, &[(y + height - 1) as u8])?; - - i.cmd_with_data(spi, Command::WriteRam, buffer); - - //load lut 2 - i.cmd_with_data(spi, Command::WriteLutRegister, &LUT_1GRAY_DU); - - i.cmd(spi, Command::DisplayUpdateSequence); - i.wait_until_idle(delay, IS_BUSY_LOW); + self.wait_until_idle(spi, delay)?; + self.set_ram_area(spi, delay, x, y, x + width, y + height)?; + self.set_ram_counter(spi, delay, x, y)?; + self.interface + .cmd_with_data(spi, Command::WriteRam, buffer)?; Ok(()) } diff --git a/src/apps/maze_game.rs b/src/apps/maze_game.rs index 11a1c49..12718d9 100644 --- a/src/apps/maze_game.rs +++ b/src/apps/maze_game.rs @@ -27,7 +27,7 @@ impl MazeGame { impl MazeGame { const X_OFFSET: i32 = 4; const Y_OFFSET: i32 = 4; - const CELL_SIZE: i32 = 6; + const CELL_SIZE: i32 = 10; fn player_pos(&self) -> (u16, u16) { (self.player.x as u16, self.player.y as u16) @@ -72,7 +72,7 @@ impl MazeGame { (self.player.x * Self::CELL_SIZE) + Self::X_OFFSET + 1, (self.player.y * Self::CELL_SIZE) + Self::Y_OFFSET + 1, ), - Size::new(4, 4), + Size::new((Self::CELL_SIZE - 2) as u32, (Self::CELL_SIZE - 2) as u32), ) .draw_styled(&player_style, &mut ctx.epaper.display) .unwrap();