diff --git a/src/epd2in7/mod.rs b/src/epd2in7/mod.rs index dc4a8280..77cccca0 100644 --- a/src/epd2in7/mod.rs +++ b/src/epd2in7/mod.rs @@ -3,8 +3,9 @@ //! [Documentation](https://www.waveshare.com/wiki/2.7inch_e-Paper_HAT) use embedded_hal::{ - blocking::{delay::*, spi::Write}, - digital::v2::*, + delay::DelayNs, + digital::{InputPin, OutputPin}, + spi::SpiDevice, }; use crate::interface::DisplayInterface; @@ -21,6 +22,7 @@ pub const HEIGHT: u32 = 264; /// Default Background Color pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = true; +const SINGLE_BYTE_WRITE: bool = true; use crate::color::Color; @@ -39,22 +41,21 @@ pub type Display2in7 = crate::graphics::Display< >; /// Epd2in7 driver -pub struct Epd2in7 { +pub struct Epd2in7 { /// Connection Interface - interface: DisplayInterface, + interface: DisplayInterface, /// Background Color color: Color, } -impl InternalWiAdditions - for Epd2in7 +impl InternalWiAdditions + for Epd2in7 where - SPI: Write, - CS: OutputPin, + SPI: SpiDevice, BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { // reset the device @@ -92,27 +93,25 @@ where } } -impl WaveshareDisplay - for Epd2in7 +impl WaveshareDisplay + for Epd2in7 where - SPI: Write, - CS: OutputPin, + SPI: SpiDevice, BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( spi: &mut SPI, - cs: CS, busy: BUSY, dc: DC, rst: RST, delay: &mut DELAY, delay_us: Option, ) -> Result { - let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); + let interface = DisplayInterface::new(busy, dc, rst, delay_us); let color = DEFAULT_BACKGROUND_COLOR; let mut epd = Epd2in7 { interface, color }; @@ -244,14 +243,13 @@ where } } -impl Epd2in7 +impl Epd2in7 where - SPI: Write, - CS: OutputPin, + SPI: SpiDevice, BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> { self.interface.cmd(spi, command)