From c7d32ca86ea4d2557929146108184c84d4872ba3 Mon Sep 17 00:00:00 2001 From: Mitch Souders Date: Sun, 15 Nov 2020 05:32:17 -0800 Subject: [PATCH] Added some busy checks and seem to be avoiding missing pictures --- src/epd5in65f/mod.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/epd5in65f/mod.rs b/src/epd5in65f/mod.rs index 59fa103..1ccb4ff 100644 --- a/src/epd5in65f/mod.rs +++ b/src/epd5in65f/mod.rs @@ -30,7 +30,7 @@ pub const WIDTH: u32 = 600; pub const HEIGHT: u32 = 448; /// Default Background Color pub const DEFAULT_BACKGROUND_COLOR: OctColor = OctColor::White; -const IS_BUSY_LOW: bool = false; +const IS_BUSY_LOW: bool = true; /// EPD5in65f driver /// @@ -119,6 +119,8 @@ where } fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { + self.wait_busy_high(); + self.send_resolution(spi)?; self.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_1, buffer)?; Ok(()) } @@ -136,6 +138,7 @@ where } fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { + self.wait_busy_high(); self.command(spi, Command::POWER_ON)?; self.wait_busy_high(); self.command(spi, Command::DISPLAY_REFRESH)?; @@ -153,10 +156,10 @@ where fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { let bg = 0x77; /*clear frame */ //OctColor::colors_byte(self.color, self.color); - + self.wait_busy_high(); + self.send_resolution(spi)?; self.command(spi, Command::DATA_START_TRANSMISSION_1)?; - self.interface.data_x_times(spi, bg, WIDTH * HEIGHT / 2)?; - + self.interface.data_x_times(spi, bg, WIDTH * HEIGHT / 2)?; self.display_frame(spi)?; Ok(()) } @@ -221,7 +224,6 @@ where fn wait_busy_low(&mut self) { self.interface.wait_until_idle(false) } - fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { let w = self.width(); let h = self.height();