Building partial update

This commit is contained in:
eraden 2024-10-01 09:57:55 +02:00
parent 09f4b17674
commit 6e5d7a7fb0

View File

@ -218,6 +218,36 @@ where
Ok(()) Ok(())
} }
/**
void EPD_3IN7_1Gray_Display_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend)
{
UWORD i, Width;
Width = (Xend-Xstart)%8 == 0 ? (Xend-Xstart)/8 : (Xend-Xstart)/8+1;
UWORD IMAGE_COUNTER = Width * (Yend-Ystart);
EPD_3IN7_SendCommand(0x44);
EPD_3IN7_SendData(Xstart & 0xff);
EPD_3IN7_SendData((Xstart>>8) & 0x03);
EPD_3IN7_SendData(Xend & 0xff);
EPD_3IN7_SendData((Xend>>8) & 0x03);
EPD_3IN7_SendCommand(0x45);
EPD_3IN7_SendData(Ystart & 0xff);
EPD_3IN7_SendData((Ystart>>8) & 0x03);
EPD_3IN7_SendData(Yend & 0xff);
EPD_3IN7_SendData((Yend>>8) & 0x03);
EPD_3IN7_SendCommand(0x24);
for (i = 0; i < IMAGE_COUNTER; i++)
{
EPD_3IN7_SendData(Image[i]);
}
EPD_3IN7_Load_LUT(2);
EPD_3IN7_SendCommand(0x20);
EPD_3IN7_ReadBusy_HIGH();
}
*/
#[allow(unused)] #[allow(unused)]
fn update_partial_frame( fn update_partial_frame(
&mut self, &mut self,
@ -229,6 +259,20 @@ where
width: u32, width: u32,
height: u32, height: u32,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
self.interface
.cmd(spi, Command::SetRamXAddressStartEndPosition);
self.interface.data(spi, &[x as u8 & 0xff]);
self.interface.data(spi, &[(x >> 8) as u8 & 0x03]);
self.interface.data(spi, &[(width - x) as u8 & 0xff]);
self.interface.data(spi, &[((width - x) as u8 >> 8) & 0x03]);
self.interface
.cmd(spi, Command::SetRamYAddressStartEndPosition);
self.interface.data(spi, y as u8 & 0xff);
self.interface.data(spi, (y as u8 >> 8) & 0x03);
self.interface.data(spi, (height - y) as u8 & 0xff);
self.interface.data(spi, ((height - y) as u8 >> 8) & 0x03);
todo!() todo!()
} }
@ -236,7 +280,7 @@ where
//self.interface //self.interface
// .cmd_with_data(spi, Command::WRITE_LUT_REGISTER, &LUT_1GRAY_GC)?; // .cmd_with_data(spi, Command::WRITE_LUT_REGISTER, &LUT_1GRAY_GC)?;
self.interface.cmd(spi, Command::DisplayUpdateSequence)?; self.interface.cmd(spi, Command::DisplayUpdateSequence)?;
self.interface.wait_until_idle(delay, IS_BUSY_LOW); let _ = self.interface.wait_until_idle(delay, IS_BUSY_LOW);
Ok(()) Ok(())
} }