mirror of
https://github.com/Anshorei/epd-waveshare.git
synced 2026-10-03 22:06:43 +00:00
Update/Include new update_and_display trait
This commit is contained in:
+12
-12
@@ -188,6 +188,7 @@ where
|
||||
}
|
||||
|
||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||
self.wait_until_idle();
|
||||
self.interface
|
||||
.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x17])?; //border floating
|
||||
self.command(spi, Command::VCM_DC_SETTING)?; // VCOM to 0V
|
||||
@@ -202,12 +203,11 @@ where
|
||||
self.wait_until_idle();
|
||||
self.interface
|
||||
.cmd_with_data(spi, Command::DEEP_SLEEP, &[0xA5])?;
|
||||
|
||||
self.wait_until_idle();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
||||
self.wait_until_idle();
|
||||
let color_value = self.color.get_byte_value();
|
||||
|
||||
self.send_resolution(spi)?;
|
||||
@@ -226,8 +226,6 @@ where
|
||||
|
||||
self.interface
|
||||
.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_2, buffer)?;
|
||||
|
||||
self.wait_until_idle();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -240,6 +238,7 @@ where
|
||||
width: u32,
|
||||
height: u32,
|
||||
) -> Result<(), SPI::Error> {
|
||||
self.wait_until_idle();
|
||||
if buffer.len() as u32 != width / 8 * height {
|
||||
//TODO: panic!! or sth like that
|
||||
//return Err("Wrong buffersize");
|
||||
@@ -273,19 +272,23 @@ where
|
||||
self.send_data(spi, buffer)?;
|
||||
|
||||
self.command(spi, Command::PARTIAL_OUT)?;
|
||||
|
||||
self.wait_until_idle();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||
|
||||
self.wait_until_idle();
|
||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
||||
self.update_frame(spi, buffer)?;
|
||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||
self.wait_until_idle();
|
||||
self.send_resolution(spi)?;
|
||||
|
||||
let color_value = self.color.get_byte_value();
|
||||
@@ -299,8 +302,6 @@ where
|
||||
.cmd(spi, Command::DATA_START_TRANSMISSION_2)?;
|
||||
self.interface
|
||||
.data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?;
|
||||
|
||||
self.wait_until_idle();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -397,6 +398,7 @@ where
|
||||
lut_wb: &[u8],
|
||||
lut_bb: &[u8],
|
||||
) -> Result<(), SPI::Error> {
|
||||
self.wait_until_idle();
|
||||
// LUT VCOM
|
||||
self.cmd_with_data(spi, Command::LUT_FOR_VCOM, lut_vcom)?;
|
||||
|
||||
@@ -411,8 +413,6 @@ where
|
||||
|
||||
// LUT BLACK to BLACK
|
||||
self.cmd_with_data(spi, Command::LUT_BLACK_TO_BLACK, lut_bb)?;
|
||||
|
||||
self.wait_until_idle();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user