From ae25129ada5f834a9ec016577b46b3363c30a6e9 Mon Sep 17 00:00:00 2001 From: Andreas Date: Mon, 19 Apr 2021 18:00:41 +0200 Subject: [PATCH] Merge branch 'fix-70' --- src/epd2in9_v2/mod.rs | 64 +++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/src/epd2in9_v2/mod.rs b/src/epd2in9_v2/mod.rs index 6797d3d..01dcfcc 100644 --- a/src/epd2in9_v2/mod.rs +++ b/src/epd2in9_v2/mod.rs @@ -33,11 +33,11 @@ //! .draw(&mut display); //! //! // Display updated frame -//!epd.update_frame(&mut spi, &display.buffer())?; -//!epd.display_frame(&mut spi)?; +//!epd.update_frame(&mut spi, &display.buffer(), &mut delay)?; +//!epd.display_frame(&mut spi, &mut delay)?; //! //!// Set the EPD to sleep -//!epd.sleep(&mut spi)?; +//!epd.sleep(&mut spi, &mut delay)?; //!# Ok(()) //!# } //!``` @@ -83,28 +83,25 @@ pub use crate::epd2in9_v2::graphics::Display2in9; /// Epd2in9 driver /// -pub struct Epd2in9 { +pub struct Epd2in9 { /// SPI - interface: DisplayInterface, + interface: DisplayInterface, /// Color background_color: Color, /// Refresh LUT refresh: RefreshLut, } -impl Epd2in9 +impl Epd2in9 where SPI: Write, CS: OutputPin, BUSY: InputPin, DC: OutputPin, RST: OutputPin, + DELAY: DelayMs, { - fn init>( - &mut self, - spi: &mut SPI, - delay: &mut DELAY, - ) -> Result<(), SPI::Error> { + fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { self.interface.reset(delay, 2); self.wait_until_idle(); @@ -136,14 +133,15 @@ where } } -impl WaveshareDisplay - for Epd2in9 +impl WaveshareDisplay + for Epd2in9 where SPI: Write, CS: OutputPin, BUSY: InputPin, DC: OutputPin, RST: OutputPin, + DELAY: DelayMs, { type DisplayColor = Color; fn width(&self) -> u32 { @@ -154,7 +152,7 @@ where HEIGHT } - fn new>( + fn new( spi: &mut SPI, cs: CS, busy: BUSY, @@ -175,7 +173,7 @@ where Ok(epd) } - fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { + fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> { self.wait_until_idle(); // 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode self.interface @@ -183,16 +181,17 @@ where Ok(()) } - fn wake_up>( - &mut self, - spi: &mut SPI, - delay: &mut DELAY, - ) -> Result<(), SPI::Error> { + fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { self.init(spi, delay)?; Ok(()) } - fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { + fn update_frame( + &mut self, + spi: &mut SPI, + buffer: &[u8], + _delay: &mut DELAY, + ) -> Result<(), SPI::Error> { self.wait_until_idle(); self.interface.cmd_with_data(spi, Command::WriteRam, buffer) } @@ -215,7 +214,7 @@ where Ok(()) } - fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { + fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> { self.wait_until_idle(); // Enable clock signal, Enable Analog, Load temperature value, DISPLAY with DISPLAY Mode 1, Disable Analog, Disable OSC self.interface @@ -225,13 +224,18 @@ where Ok(()) } - fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { - self.update_frame(spi, buffer)?; - self.display_frame(spi)?; + fn update_and_display_frame( + &mut self, + spi: &mut SPI, + buffer: &[u8], + delay: &mut DELAY, + ) -> Result<(), SPI::Error> { + self.update_frame(spi, buffer, delay)?; + self.display_frame(spi, delay)?; Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { + fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> { self.wait_until_idle(); // clear the ram with the background color @@ -265,13 +269,14 @@ where } } -impl Epd2in9 +impl Epd2in9 where SPI: Write, CS: OutputPin, BUSY: InputPin, DC: OutputPin, RST: OutputPin, + DELAY: DelayMs, { fn wait_until_idle(&mut self) { self.interface.wait_until_idle(IS_BUSY_LOW); @@ -343,14 +348,15 @@ where } } -impl QuickRefresh - for Epd2in9 +impl QuickRefresh + for Epd2in9 where SPI: Write, CS: OutputPin, BUSY: InputPin, DC: OutputPin, RST: OutputPin, + DELAY: DelayMs, { /// To be followed immediately by `update_new_frame`. fn update_old_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {