From 46c38bd2b9d6ba882b8918d9f710e375b9078281 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Tue, 7 Nov 2023 10:17:44 +0100 Subject: [PATCH 1/3] fix buffer size for 7in5v3 --- src/epd7in5_v3/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/epd7in5_v3/mod.rs b/src/epd7in5_v3/mod.rs index 962924af..79ba7653 100644 --- a/src/epd7in5_v3/mod.rs +++ b/src/epd7in5_v3/mod.rs @@ -29,7 +29,7 @@ pub type Display7in5 = crate::graphics::Display< WIDTH, HEIGHT, false, - { buffer_len(WIDTH as usize, HEIGHT as usize) }, + { buffer_len(WIDTH as usize, HEIGHT as usize * 2) }, TriColor, >; From 2f33f194ce398494b695bdbd084e3f4079864499 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Tue, 7 Nov 2023 17:01:59 +0100 Subject: [PATCH 2/3] update v2 driver and remove v3 --- src/epd7in5_v3/command.rs | 153 ----------------- src/epd7in5_v3/mod.rs | 328 ------------------------------------- src/epd7in5b_v2/command.rs | 20 ++- src/epd7in5b_v2/mod.rs | 69 +++++++- src/lib.rs | 2 +- 5 files changed, 79 insertions(+), 493 deletions(-) delete mode 100644 src/epd7in5_v3/command.rs delete mode 100644 src/epd7in5_v3/mod.rs diff --git a/src/epd7in5_v3/command.rs b/src/epd7in5_v3/command.rs deleted file mode 100644 index cc7dcdc7..00000000 --- a/src/epd7in5_v3/command.rs +++ /dev/null @@ -1,153 +0,0 @@ -//! SPI Commands for the Waveshare 7.5" V3 E-Ink Display - -use crate::traits; - -/// Epd7in5 commands -/// -/// Should rarely (never?) be needed directly. -/// -/// For more infos about the addresses and what they are doing look into the PDFs. -#[allow(dead_code)] -#[derive(Copy, Clone)] -pub(crate) enum Command { - /// Set Resolution, LUT selection, BWR pixels, gate scan direction, source shift - /// direction, booster switch, soft reset. - PanelSetting = 0x00, - - /// Selecting internal and external power - PowerSetting = 0x01, - - /// After the Power Off command, the driver will power off following the Power Off - /// Sequence; BUSY signal will become "0". This command will turn off charge pump, - /// T-con, source driver, gate driver, VCOM, and temperature sensor, but register - /// data will be kept until VDD becomes OFF. Source Driver output and Vcom will remain - /// as previous condition, which may have 2 conditions: 0V or floating. - PowerOff = 0x02, - - /// Setting Power OFF sequence - PowerOffSequenceSetting = 0x03, - - /// Turning On the Power - /// - /// After the Power ON command, the driver will power on following the Power ON - /// sequence. Once complete, the BUSY signal will become "1". - PowerOn = 0x04, - - /// Starting data transmission - BoosterSoftStart = 0x06, - - /// This command makes the chip enter the deep-sleep mode to save power. - /// - /// The deep sleep mode would return to stand-by by hardware reset. - /// - /// The only one parameter is a check code, the command would be excuted if check code = 0xA5. - DeepSleep = 0x07, - - /// This command starts transmitting data and write them into SRAM. To complete data - /// transmission, command DSP (Data Stop) must be issued. Then the chip will start to - /// send data/VCOM for panel. - /// - /// BLACK/WHITE or OLD_DATA - DataStartTransmission1 = 0x10, - - /// To stop data transmission, this command must be issued to check the `data_flag`. - /// - /// After this command, BUSY signal will become "0" until the display update is - /// finished. - DataStop = 0x11, - - /// After this command is issued, driver will refresh display (data/VCOM) according to - /// SRAM data and LUT. - /// - /// After Display Refresh command, BUSY signal will become "0" until the display - /// update is finished. - DisplayRefresh = 0x12, - - /// RED or NEW_DATA - DataStartTransmission2 = 0x13, - - /// Dual SPI - what for? - DualSpi = 0x15, - - /// This command builds the VCOM Look-Up Table (LUTC). - LutForVcom = 0x20, - /// This command builds the Black Look-Up Table (LUTB). - LutBlack = 0x21, - /// This command builds the White Look-Up Table (LUTW). - LutWhite = 0x22, - /// This command builds the Gray1 Look-Up Table (LUTG1). - LutGray1 = 0x23, - /// This command builds the Gray2 Look-Up Table (LUTG2). - LutGray2 = 0x24, - /// This command builds the Red0 Look-Up Table (LUTR0). - LutRed0 = 0x25, - /// This command builds the Red1 Look-Up Table (LUTR1). - LutRed1 = 0x26, - /// This command builds the Red2 Look-Up Table (LUTR2). - LutRed2 = 0x27, - /// This command builds the Red3 Look-Up Table (LUTR3). - LutRed3 = 0x28, - /// This command builds the XON Look-Up Table (LUTXON). - LutXon = 0x29, - - /// The command controls the PLL clock frequency. - PllControl = 0x30, - - /// This command reads the temperature sensed by the temperature sensor. - TemperatureSensor = 0x40, - /// This command selects the Internal or External temperature sensor. - TemperatureCalibration = 0x41, - /// This command could write data to the external temperature sensor. - TemperatureSensorWrite = 0x42, - /// This command could read data from the external temperature sensor. - TemperatureSensorRead = 0x43, - - /// This command indicates the interval of Vcom and data output. When setting the - /// vertical back porch, the total blanking will be kept (20 Hsync). - VcomAndDataIntervalSetting = 0x50, - /// This command indicates the input power condition. Host can read this flag to learn - /// the battery condition. - LowPowerDetection = 0x51, - - /// This command defines non-overlap period of Gate and Source. - TconSetting = 0x60, - /// This command defines alternative resolution and this setting is of higher priority - /// than the RES\[1:0\] in R00H (PSR). - TconResolution = 0x61, - /// This command defines MCU host direct access external memory mode. - SpiFlashControl = 0x65, - - /// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000. - Revision = 0x70, - /// This command reads the IC status. - GetStatus = 0x71, - - /// This command implements related VCOM sensing setting. - AutoMeasurementVcom = 0x80, - /// This command gets the VCOM value. - ReadVcomValue = 0x81, - /// This command sets `VCOM_DC` value. - VcmDcSetting = 0x82, - // /// This is in all the Waveshare controllers for Epd7in5, but it's not documented - // /// anywhere in the datasheet `¯\_(ツ)_/¯` - // FlashMode = 0xE5, -} - -impl traits::Command for Command { - /// Returns the address of the command - fn address(self) -> u8 { - self as u8 - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::traits::Command as CommandTrait; - - #[test] - fn command_addr() { - assert_eq!(Command::PanelSetting.address(), 0x00); - assert_eq!(Command::DisplayRefresh.address(), 0x12); - } -} diff --git a/src/epd7in5_v3/mod.rs b/src/epd7in5_v3/mod.rs deleted file mode 100644 index 79ba7653..00000000 --- a/src/epd7in5_v3/mod.rs +++ /dev/null @@ -1,328 +0,0 @@ -//! A simple Driver for the Waveshare 7.5" E-Ink Display (V3) via SPI -//! -//! # References -//! -//! - [Datasheet](https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT) -//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/702def0/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_7in5_V2.c) -//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/702def0/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5_V2.py) -//! - -use embedded_hal::{ - delay::DelayUs, - digital::{InputPin, OutputPin}, - spi::SpiDevice, -}; - -use crate::color::TriColor; -use crate::interface::DisplayInterface; -use crate::traits::{ - InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay, -}; - -pub(crate) mod command; -use self::command::Command; -use crate::buffer_len; - -/// Full size buffer for use with the 7in5 v3 EPD -#[cfg(feature = "graphics")] -pub type Display7in5 = crate::graphics::Display< - WIDTH, - HEIGHT, - false, - { buffer_len(WIDTH as usize, HEIGHT as usize * 2) }, - TriColor, ->; - -/// Width of the display -pub const WIDTH: u32 = 800; -/// Height of the display -pub const HEIGHT: u32 = 480; -/// Default Background Color -//pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; - -pub const DEFAULT_BACKGROUND_COLOR: TriColor = TriColor::White; - -/// Number of bits for b/w buffer and same for chromatic buffer -const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8; -const IS_BUSY_LOW: bool = true; -const SINGLE_BYTE_WRITE: bool = false; - -/// Epd7in5 (V3) driver -/// -pub struct Epd7in5 { - /// Connection Interface - interface: DisplayInterface, - /// Background Color - color: TriColor, -} - -impl InternalWiAdditions - for Epd7in5 -where - SPI: SpiDevice, - BUSY: InputPin, - DC: OutputPin, - RST: OutputPin, - DELAY: DelayUs, -{ - fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { - // Reset the device - self.interface.reset(delay, 200_000, 4_000); - - // V2 procedure as described here: - // https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5bc_V2.py - // and as per specs: - // https://www.waveshare.com/w/upload/6/60/7.5inch_e-Paper_V2_Specification.pdf - - //self.cmd_with_data(spi, Command::BoosterSoftStart, &[0x17, 0x17, 0x27, 0x17])?; - self.cmd_with_data(spi, Command::PowerSetting, &[0x07, 0x07, 0x3F, 0x3F])?; - self.command(spi, Command::PowerOn)?; - self.wait_until_idle(spi, delay)?; - self.cmd_with_data(spi, Command::PanelSetting, &[0x0F])?; - //self.cmd_with_data(spi, Command::PllControl, &[0x06])?; - self.cmd_with_data(spi, Command::TconResolution, &[0x03, 0x20, 0x01, 0xE0])?; - self.cmd_with_data(spi, Command::DualSpi, &[0x00])?; - self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x11, 0x07])?; - self.cmd_with_data(spi, Command::TconSetting, &[0x22])?; - self.cmd_with_data(spi, Command::SpiFlashControl, &[0x00, 0x00, 0x00, 0x00])?; - self.wait_until_idle(spi, delay)?; - Ok(()) - } -} - -impl WaveshareThreeColorDisplay - for Epd7in5 -where - SPI: SpiDevice, - BUSY: InputPin, - DC: OutputPin, - RST: OutputPin, - DELAY: DelayUs, -{ - fn update_color_frame( - &mut self, - spi: &mut SPI, - delay: &mut DELAY, - black: &[u8], - chromatic: &[u8], - ) -> Result<(), SPI::Error> { - self.update_achromatic_frame(spi, delay, black)?; - self.update_chromatic_frame(spi, delay, chromatic) - } - - /// Update only the black/white data of the display. - /// - /// Finish by calling `update_chromatic_frame`. - fn update_achromatic_frame( - &mut self, - spi: &mut SPI, - _delay: &mut DELAY, - black: &[u8], - ) -> Result<(), SPI::Error> { - self.interface.cmd(spi, Command::DataStartTransmission1)?; - self.interface.data(spi, black)?; - Ok(()) - } - - /// Update only chromatic data of the display. - /// - /// This data takes precedence over the black/white data. - fn update_chromatic_frame( - &mut self, - spi: &mut SPI, - delay: &mut DELAY, - chromatic: &[u8], - ) -> Result<(), SPI::Error> { - self.interface.cmd(spi, Command::DataStartTransmission2)?; - self.interface.data(spi, chromatic)?; - - self.wait_until_idle(spi, delay)?; - Ok(()) - } -} - -impl WaveshareDisplay - for Epd7in5 -where - SPI: SpiDevice, - BUSY: InputPin, - DC: OutputPin, - RST: OutputPin, - DELAY: DelayUs, -{ - type DisplayColor = TriColor; - fn new( - spi: &mut SPI, - busy: BUSY, - dc: DC, - rst: RST, - delay: &mut DELAY, - delay_us: Option, - ) -> Result { - let interface = DisplayInterface::new(busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - - let mut epd = Epd7in5 { interface, color }; - - epd.init(spi, delay)?; - - Ok(epd) - } - - fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { - self.init(spi, delay) - } - - fn sleep(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { - self.wait_until_idle(spi, delay)?; - self.command(spi, Command::PowerOff)?; - self.wait_until_idle(spi, delay)?; - self.cmd_with_data(spi, Command::DeepSleep, &[0xA5])?; - Ok(()) - } - - fn update_frame( - &mut self, - spi: &mut SPI, - buffer: &[u8], - delay: &mut DELAY, - ) -> Result<(), SPI::Error> { - self.wait_until_idle(spi, delay)?; - self.cmd_with_data(spi, Command::DataStartTransmission2, buffer)?; - - self.interface.data(spi, buffer)?; - - // Clear the chromatic layer - let color = self.color.get_byte_value(); - - self.interface.cmd(spi, Command::DataStartTransmission2)?; - self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; - - self.wait_until_idle(spi, delay)?; - - Ok(()) - } - - fn update_partial_frame( - &mut self, - _spi: &mut SPI, - _delay: &mut DELAY, - _buffer: &[u8], - _x: u32, - _y: u32, - _width: u32, - _height: u32, - ) -> Result<(), SPI::Error> { - unimplemented!(); - } - - fn display_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { - self.wait_until_idle(spi, delay)?; - self.command(spi, Command::DisplayRefresh)?; - Ok(()) - } - - 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.command(spi, Command::DisplayRefresh)?; - Ok(()) - } - - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { - self.wait_until_idle(spi, delay)?; - self.send_resolution(spi)?; - - self.command(spi, Command::DataStartTransmission1)?; - self.interface.data_x_times(spi, 0x00, WIDTH * HEIGHT / 8)?; - - self.command(spi, Command::DataStartTransmission2)?; - self.interface.data_x_times(spi, 0x00, WIDTH * HEIGHT / 8)?; - - self.command(spi, Command::DisplayRefresh)?; - Ok(()) - } - - fn set_background_color(&mut self, color: TriColor) { - self.color = color; - } - - fn background_color(&self) -> &TriColor { - &self.color - } - - fn width(&self) -> u32 { - WIDTH - } - - fn height(&self) -> u32 { - HEIGHT - } - - fn set_lut( - &mut self, - _spi: &mut SPI, - _delay: &mut DELAY, - _refresh_rate: Option, - ) -> Result<(), SPI::Error> { - unimplemented!(); - } - - fn wait_until_idle(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { - self.interface - .wait_until_idle_with_cmd(spi, delay, IS_BUSY_LOW, Command::GetStatus) - } -} - -impl Epd7in5 -where - SPI: SpiDevice, - BUSY: InputPin, - DC: OutputPin, - RST: OutputPin, - DELAY: DelayUs, -{ - fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> { - self.interface.cmd(spi, command) - } - - fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> { - self.interface.data(spi, data) - } - - fn cmd_with_data( - &mut self, - spi: &mut SPI, - command: Command, - data: &[u8], - ) -> Result<(), SPI::Error> { - self.interface.cmd_with_data(spi, command, data) - } - - fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { - let w = self.width(); - let h = self.height(); - - self.command(spi, Command::TconResolution)?; - self.send_data(spi, &[(w >> 8) as u8])?; - self.send_data(spi, &[w as u8])?; - self.send_data(spi, &[(h >> 8) as u8])?; - self.send_data(spi, &[h as u8]) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn epd_size() { - assert_eq!(WIDTH, 800); - assert_eq!(HEIGHT, 480); - assert_eq!(DEFAULT_BACKGROUND_COLOR, TriColor::White); - } -} diff --git a/src/epd7in5b_v2/command.rs b/src/epd7in5b_v2/command.rs index da3b16be..fd2d70c4 100644 --- a/src/epd7in5b_v2/command.rs +++ b/src/epd7in5b_v2/command.rs @@ -70,17 +70,25 @@ pub(crate) enum Command { DualSpi = 0x15, /// This command builds the VCOM Look-Up Table (LUTC). - LutC = 0x20, + LutForVcom = 0x20, /// This command builds the Black Look-Up Table (LUTB). - LutWW = 0x21, + LutBlack = 0x21, /// This command builds the White Look-Up Table (LUTW). - LutBW = 0x22, + LutWhite = 0x22, /// This command builds the Gray1 Look-Up Table (LUTG1). - LutWB = 0x23, + LutGray1 = 0x23, /// This command builds the Gray2 Look-Up Table (LUTG2). - LutBB = 0x24, + LutGray2 = 0x24, /// This command builds the Red0 Look-Up Table (LUTR0). - LutBD = 0x25, + LutRed0 = 0x25, + /// This command builds the Red1 Look-Up Table (LUTR1). + LutRed1 = 0x26, + /// This command builds the Red2 Look-Up Table (LUTR2). + LutRed2 = 0x27, + /// This command builds the Red3 Look-Up Table (LUTR3). + LutRed3 = 0x28, + /// This command builds the XON Look-Up Table (LUTXON). + LutXon = 0x29, /// LUT Option LutOpt = 0x2A, diff --git a/src/epd7in5b_v2/mod.rs b/src/epd7in5b_v2/mod.rs index c71d030c..3b204e31 100644 --- a/src/epd7in5b_v2/mod.rs +++ b/src/epd7in5b_v2/mod.rs @@ -18,13 +18,15 @@ use embedded_hal::{ use crate::color::TriColor; use crate::interface::DisplayInterface; -use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; +use crate::traits::{ + InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay, +}; pub(crate) mod command; use self::command::Command; use crate::buffer_len; -/// Full size buffer for use with the 1in54 EPD +/// Full size buffer for use with the 7in5b v2 EPD #[cfg(feature = "graphics")] pub type Display7in5 = crate::graphics::Display< WIDTH, @@ -41,7 +43,8 @@ pub const HEIGHT: u32 = 480; /// Default Background Color pub const DEFAULT_BACKGROUND_COLOR: TriColor = TriColor::White; -const NUM_DISPLAY_BYTES: usize = WIDTH as usize * HEIGHT as usize / 8; +/// Number of bits for b/w buffer and same for chromatic buffer +const NUM_DISPLAY_BITS: usize = WIDTH as usize * HEIGHT as usize / 8; const IS_BUSY_LOW: bool = true; const SINGLE_BYTE_WRITE: bool = false; @@ -103,6 +106,59 @@ where } } +impl WaveshareThreeColorDisplay + for Epd7in5 +where + SPI: SpiDevice, + BUSY: InputPin, + DC: OutputPin, + RST: OutputPin, + DELAY: DelayUs, +{ + fn update_color_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + black: &[u8], + chromatic: &[u8], + ) -> Result<(), SPI::Error> { + self.update_achromatic_frame(spi, delay, black)?; + self.update_chromatic_frame(spi, delay, chromatic) + } + + /// Update only the black/white data of the display. + /// + /// Finish by calling `update_chromatic_frame`. + fn update_achromatic_frame( + &mut self, + spi: &mut SPI, + _delay: &mut DELAY, + black: &[u8], + ) -> Result<(), SPI::Error> { + self.interface.cmd(spi, Command::DataStartTransmission1)?; + self.interface.data(spi, black)?; + self.interface.cmd(spi, Command::DataStop)?; + Ok(()) + } + + /// Update only chromatic data of the display. + /// + /// This data takes precedence over the black/white data. + fn update_chromatic_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + chromatic: &[u8], + ) -> Result<(), SPI::Error> { + self.interface.cmd(spi, Command::DataStartTransmission2)?; + self.interface.data(spi, chromatic)?; + self.interface.cmd(spi, Command::DataStop)?; + + self.wait_until_idle(spi, delay)?; + Ok(()) + } +} + impl WaveshareDisplay for Epd7in5 where @@ -154,13 +210,14 @@ where self.cmd_with_data( spi, Command::DataStartTransmission1, - &buffer[..NUM_DISPLAY_BYTES], + &buffer[..NUM_DISPLAY_BITS], )?; self.cmd_with_data( spi, Command::DataStartTransmission2, - &buffer[NUM_DISPLAY_BYTES..], + &buffer[NUM_DISPLAY_BITS..], )?; + self.interface.cmd(spi, Command::DataStop)?; Ok(()) } @@ -204,6 +261,8 @@ where self.command(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, 0x00, WIDTH * HEIGHT / 8)?; + self.interface.cmd(spi, Command::DataStop)?; + self.command(spi, Command::DisplayRefresh)?; Ok(()) diff --git a/src/lib.rs b/src/lib.rs index bdedf055..4fec13ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,8 +90,8 @@ pub mod epd5in83b_v2; pub mod epd7in5; pub mod epd7in5_hd; pub mod epd7in5_v2; -pub mod epd7in5_v3; pub mod epd7in5b_v2; +pub use epd7in5b_v2 as epd7in5b_v3; pub(crate) mod type_a; From a9e4c915f79f45dfeb8bdab9543fba546d7a1381 Mon Sep 17 00:00:00 2001 From: Alex Martens Date: Thu, 28 Dec 2023 14:44:48 -0800 Subject: [PATCH 3/3] embedded-hal: 1.0.0-rc.1 -> 1.0.0-rc.3 --- Cargo.toml | 8 +++----- examples/epd1in54_no_graphics.rs | 6 +++--- examples/epd2in13_v2.rs | 6 +++--- examples/epd2in13bc.rs | 6 +++--- examples/epd4in2.rs | 6 +++--- examples/epd4in2_variable_size.rs | 6 +++--- src/epd1in54/mod.rs | 6 +++--- src/epd1in54_v2/mod.rs | 6 +++--- src/epd1in54b/mod.rs | 8 ++++---- src/epd1in54c/mod.rs | 8 ++++---- src/epd2in13_v2/mod.rs | 8 ++++---- src/epd2in13bc/mod.rs | 8 ++++---- src/epd2in7b/mod.rs | 8 ++++---- src/epd2in9/mod.rs | 6 +++--- src/epd2in9_v2/mod.rs | 8 ++++---- src/epd2in9bc/mod.rs | 8 ++++---- src/epd3in7/mod.rs | 6 +++--- src/epd4in2/mod.rs | 8 ++++---- src/epd5in65f/mod.rs | 8 ++++---- src/epd5in83b_v2/mod.rs | 10 +++++----- src/epd7in5/mod.rs | 8 ++++---- src/epd7in5_hd/mod.rs | 8 ++++---- src/epd7in5_v2/mod.rs | 8 ++++---- src/epd7in5b_v2/mod.rs | 8 ++++---- src/interface.rs | 4 ++-- src/traits.rs | 8 ++++---- 26 files changed, 93 insertions(+), 95 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6eff17ec..69f4b33c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,20 +17,18 @@ edition = "2021" [dependencies] embedded-graphics-core = { version = "0.4", optional = true } -embedded-hal = { version = "1.0.0-rc.1" } +embedded-hal = "1.0.0-rc.3" bit_field = "0.10.1" [dev-dependencies] embedded-graphics = "0.8" - -embedded-hal-mock = { git = "https://github.com/newAM/embedded-hal-mock", branch = "eh1-rc.1", default-features = false, features = [ +embedded-hal-mock = { version = "=0.10.0-rc.4", default-features = false, features = [ "eh1", ] } -# embedded-hal-mock = "0.9" [target.'cfg(unix)'.dev-dependencies] # linux-embedded-hal = "0.3" -linux-embedded-hal = { git = "https://github.com/rust-embedded/linux-embedded-hal" } +linux-embedded-hal = { git = "https://github.com/rust-embedded/linux-embedded-hal", rev = "a1fb24103e575615a29c6748cdeff1f0e7a3dae3" } [[example]] name = "epd1in54_no_graphics" diff --git a/examples/epd1in54_no_graphics.rs b/examples/epd1in54_no_graphics.rs index 7df04a00..4baac378 100644 --- a/examples/epd1in54_no_graphics.rs +++ b/examples/epd1in54_no_graphics.rs @@ -1,11 +1,11 @@ #![deny(warnings)] -use embedded_hal::delay::DelayUs; +use embedded_hal::delay::DelayNs; use epd_waveshare::{epd1in54::Epd1in54, prelude::*}; use linux_embedded_hal::{ spidev::{self, SpidevOptions}, sysfs_gpio::Direction, - Delay, SPIError, Spidev, SysfsPin, + Delay, SPIError, SpidevDevice, SysfsPin, }; // activate spi, gpio in raspi-config @@ -15,7 +15,7 @@ use linux_embedded_hal::{ fn main() -> Result<(), SPIError> { // Configure SPI // SPI settings are from eink-waveshare-rs documenation - let mut spi = Spidev::open("/dev/spidev0.0")?; + let mut spi = SpidevDevice::open("/dev/spidev0.0")?; let options = SpidevOptions::new() .bits_per_word(8) .max_speed_hz(4_000_000) diff --git a/examples/epd2in13_v2.rs b/examples/epd2in13_v2.rs index d4c63c4c..b3cb64eb 100644 --- a/examples/epd2in13_v2.rs +++ b/examples/epd2in13_v2.rs @@ -6,7 +6,7 @@ use embedded_graphics::{ primitives::{Circle, Line, PrimitiveStyle}, text::{Baseline, Text, TextStyleBuilder}, }; -use embedded_hal::delay::DelayUs; +use embedded_hal::delay::DelayNs; use epd_waveshare::{ color::*, epd2in13_v2::{Display2in13, Epd2in13}, @@ -16,7 +16,7 @@ use epd_waveshare::{ use linux_embedded_hal::{ spidev::{self, SpidevOptions}, sysfs_gpio::Direction, - Delay, SPIError, Spidev, SysfsPin, + Delay, SPIError, SpidevDevice, SysfsPin, }; // The pins in this example are for the Universal e-Paper Raw Panel Driver HAT @@ -27,7 +27,7 @@ use linux_embedded_hal::{ fn main() -> Result<(), SPIError> { // Configure SPI // Settings are taken from - let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory"); + let mut spi = SpidevDevice::open("/dev/spidev0.0").expect("spidev directory"); let options = SpidevOptions::new() .bits_per_word(8) .max_speed_hz(4_000_000) diff --git a/examples/epd2in13bc.rs b/examples/epd2in13bc.rs index 82a23961..8007acf3 100644 --- a/examples/epd2in13bc.rs +++ b/examples/epd2in13bc.rs @@ -6,7 +6,7 @@ use embedded_graphics::{ primitives::{Circle, Line, PrimitiveStyle}, text::{Baseline, Text, TextStyleBuilder}, }; -use embedded_hal::delay::DelayUs; +use embedded_hal::delay::DelayNs; use epd_waveshare::{ color::*, epd2in13bc::{Display2in13bc, Epd2in13bc}, @@ -16,7 +16,7 @@ use epd_waveshare::{ use linux_embedded_hal::{ spidev::{self, SpidevOptions}, sysfs_gpio::Direction, - Delay, SPIError, Spidev, SysfsPin, + Delay, SPIError, SpidevDevice, SysfsPin, }; // activate spi, gpio in raspi-config @@ -61,7 +61,7 @@ fn main() -> Result<(), SPIError> { // Configure SPI // Settings are taken from - let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory"); + let mut spi = SpidevDevice::open("/dev/spidev0.0").expect("spidev directory"); let options = SpidevOptions::new() .bits_per_word(8) .max_speed_hz(10_000_000) diff --git a/examples/epd4in2.rs b/examples/epd4in2.rs index 74a6a992..10576124 100644 --- a/examples/epd4in2.rs +++ b/examples/epd4in2.rs @@ -6,7 +6,7 @@ use embedded_graphics::{ primitives::{Circle, Line, PrimitiveStyleBuilder}, text::{Baseline, Text, TextStyleBuilder}, }; -use embedded_hal::delay::DelayUs; +use embedded_hal::delay::DelayNs; use epd_waveshare::{ color::*, epd4in2::{Display4in2, Epd4in2}, @@ -16,7 +16,7 @@ use epd_waveshare::{ use linux_embedded_hal::{ spidev::{self, SpidevOptions}, sysfs_gpio::Direction, - Delay, SPIError, Spidev, SysfsPin, + Delay, SPIError, SpidevDevice, SysfsPin, }; // activate spi, gpio in raspi-config @@ -26,7 +26,7 @@ use linux_embedded_hal::{ fn main() -> Result<(), SPIError> { // Configure SPI // Settings are taken from - let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory"); + let mut spi = SpidevDevice::open("/dev/spidev0.0").expect("spidev directory"); let options = SpidevOptions::new() .bits_per_word(8) .max_speed_hz(4_000_000) diff --git a/examples/epd4in2_variable_size.rs b/examples/epd4in2_variable_size.rs index e6d92c68..8ff8259d 100644 --- a/examples/epd4in2_variable_size.rs +++ b/examples/epd4in2_variable_size.rs @@ -7,7 +7,7 @@ use embedded_graphics::{ primitives::{Circle, Line, PrimitiveStyleBuilder}, text::{Baseline, Text, TextStyleBuilder}, }; -use embedded_hal::delay::DelayUs; +use embedded_hal::delay::DelayNs; use epd_waveshare::{ color::*, epd4in2::{self, Epd4in2}, @@ -17,7 +17,7 @@ use epd_waveshare::{ use linux_embedded_hal::{ spidev::{self, SpidevOptions}, sysfs_gpio::Direction, - Delay, SPIError, Spidev, SysfsPin, + Delay, SPIError, SpidevDevice, SysfsPin, }; // activate spi, gpio in raspi-config @@ -27,7 +27,7 @@ use linux_embedded_hal::{ fn main() -> Result<(), SPIError> { // Configure SPI // Settings are taken from - let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory"); + let mut spi = SpidevDevice::open("/dev/spidev0.0").expect("spidev directory"); let options = SpidevOptions::new() .bits_per_word(8) .max_speed_hz(4_000_000) diff --git a/src/epd1in54/mod.rs b/src/epd1in54/mod.rs index 9bc1b7fe..4a4514ed 100644 --- a/src/epd1in54/mod.rs +++ b/src/epd1in54/mod.rs @@ -94,7 +94,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { self.interface.reset(delay, 10_000, 10_000); @@ -149,7 +149,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn width(&self) -> u32 { @@ -300,7 +300,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { pub(crate) fn use_full_frame( &mut self, diff --git a/src/epd1in54_v2/mod.rs b/src/epd1in54_v2/mod.rs index 0f0399f7..1208d960 100644 --- a/src/epd1in54_v2/mod.rs +++ b/src/epd1in54_v2/mod.rs @@ -44,7 +44,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { self.interface.reset(delay, 10_000, 10_000); @@ -94,7 +94,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn width(&self) -> u32 { @@ -267,7 +267,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { pub(crate) fn use_full_frame( &mut self, diff --git a/src/epd1in54b/mod.rs b/src/epd1in54b/mod.rs index 0a477bf4..22177db9 100644 --- a/src/epd1in54b/mod.rs +++ b/src/epd1in54b/mod.rs @@ -50,7 +50,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { self.interface.reset(delay, 10_000, 10_000); @@ -96,7 +96,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn update_color_frame( &mut self, @@ -146,7 +146,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( @@ -324,7 +324,7 @@ where 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) diff --git a/src/epd1in54c/mod.rs b/src/epd1in54c/mod.rs index 341baf7d..445f9ab7 100644 --- a/src/epd1in54c/mod.rs +++ b/src/epd1in54c/mod.rs @@ -47,7 +47,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { // Based on Reference Program Code from: @@ -83,7 +83,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn update_color_frame( &mut self, @@ -128,7 +128,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( @@ -265,7 +265,7 @@ where 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) diff --git a/src/epd2in13_v2/mod.rs b/src/epd2in13_v2/mod.rs index 7712835d..5d8d4e0b 100644 --- a/src/epd2in13_v2/mod.rs +++ b/src/epd2in13_v2/mod.rs @@ -16,7 +16,7 @@ //! use embedded_hal::{ - delay::DelayUs, + delay::DelayNs, digital::{InputPin, OutputPin}, spi::SpiDevice, }; @@ -87,7 +87,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { // HW reset @@ -180,7 +180,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( @@ -392,7 +392,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { /// When using partial refresh, the controller uses the provided buffer for /// comparison with new buffer. diff --git a/src/epd2in13bc/mod.rs b/src/epd2in13bc/mod.rs index 280f47a7..b47250de 100644 --- a/src/epd2in13bc/mod.rs +++ b/src/epd2in13bc/mod.rs @@ -104,7 +104,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { // Values taken from datasheet and sample code @@ -147,7 +147,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn update_color_frame( &mut self, @@ -198,7 +198,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = TriColor; fn new( @@ -347,7 +347,7 @@ where 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) diff --git a/src/epd2in7b/mod.rs b/src/epd2in7b/mod.rs index 941d0393..2db23059 100644 --- a/src/epd2in7b/mod.rs +++ b/src/epd2in7b/mod.rs @@ -54,7 +54,7 @@ where 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 @@ -119,7 +119,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( @@ -280,7 +280,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn update_color_frame( &mut self, @@ -335,7 +335,7 @@ where 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) diff --git a/src/epd2in9/mod.rs b/src/epd2in9/mod.rs index 6e3e178d..48c5bdcc 100644 --- a/src/epd2in9/mod.rs +++ b/src/epd2in9/mod.rs @@ -91,7 +91,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { self.interface.reset(delay, 10_000, 10_000); @@ -142,7 +142,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn width(&self) -> u32 { @@ -296,7 +296,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn use_full_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { // choose full frame/ram diff --git a/src/epd2in9_v2/mod.rs b/src/epd2in9_v2/mod.rs index 7004a77e..d9c4bcf0 100644 --- a/src/epd2in9_v2/mod.rs +++ b/src/epd2in9_v2/mod.rs @@ -114,7 +114,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { self.interface.reset(delay, 10_000, 2_000); @@ -155,7 +155,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn width(&self) -> u32 { @@ -297,7 +297,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn use_full_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { // choose full frame/ram @@ -383,7 +383,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { /// To be followed immediately by `update_new_frame`. fn update_old_frame( diff --git a/src/epd2in9bc/mod.rs b/src/epd2in9bc/mod.rs index 121c5680..30611706 100644 --- a/src/epd2in9bc/mod.rs +++ b/src/epd2in9bc/mod.rs @@ -108,7 +108,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { // Values taken from datasheet and sample code @@ -151,7 +151,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn update_color_frame( &mut self, @@ -202,7 +202,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( @@ -351,7 +351,7 @@ where 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) diff --git a/src/epd3in7/mod.rs b/src/epd3in7/mod.rs index c7f06855..c01c49fa 100644 --- a/src/epd3in7/mod.rs +++ b/src/epd3in7/mod.rs @@ -3,7 +3,7 @@ //! //! Build with the help of documentation/code from [Waveshare](https://www.waveshare.com/wiki/3.7inch_e-Paper_HAT), use embedded_hal::{ - delay::DelayUs, + delay::DelayNs, digital::{InputPin, OutputPin}, spi::SpiDevice, }; @@ -57,7 +57,7 @@ where 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 @@ -130,7 +130,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; diff --git a/src/epd4in2/mod.rs b/src/epd4in2/mod.rs index fe43d0ef..a1c2a0d4 100644 --- a/src/epd4in2/mod.rs +++ b/src/epd4in2/mod.rs @@ -101,7 +101,7 @@ where 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 @@ -155,7 +155,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( @@ -354,7 +354,7 @@ where 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) @@ -449,7 +449,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { /// To be followed immediately after by `update_old_frame`. fn update_old_frame( diff --git a/src/epd5in65f/mod.rs b/src/epd5in65f/mod.rs index 6233955b..1a70b78a 100644 --- a/src/epd5in65f/mod.rs +++ b/src/epd5in65f/mod.rs @@ -7,7 +7,7 @@ //! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd5in65f.py) use embedded_hal::{ - delay::DelayUs, + delay::DelayNs, digital::{InputPin, OutputPin}, spi::SpiDevice, }; @@ -55,7 +55,7 @@ where 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 @@ -87,7 +87,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = OctColor; fn new( @@ -213,7 +213,7 @@ where 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) diff --git a/src/epd5in83b_v2/mod.rs b/src/epd5in83b_v2/mod.rs index d1df524e..abafbf3b 100644 --- a/src/epd5in83b_v2/mod.rs +++ b/src/epd5in83b_v2/mod.rs @@ -7,7 +7,7 @@ //! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in83b_V2.py) use embedded_hal::{ - delay::DelayUs, + delay::DelayNs, digital::{InputPin, OutputPin}, spi::SpiDevice, }; @@ -57,7 +57,7 @@ where 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 @@ -101,7 +101,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn update_color_frame( &mut self, @@ -145,7 +145,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( @@ -308,7 +308,7 @@ where 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) diff --git a/src/epd7in5/mod.rs b/src/epd7in5/mod.rs index 5b89e1a1..121b780d 100644 --- a/src/epd7in5/mod.rs +++ b/src/epd7in5/mod.rs @@ -7,7 +7,7 @@ //! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/702def06bcb75983c98b0f9d25d43c552c248eb0/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5.py) use embedded_hal::{ - delay::DelayUs, + delay::DelayNs, digital::{InputPin, OutputPin}, spi::SpiDevice, }; @@ -55,7 +55,7 @@ where 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 @@ -110,7 +110,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( @@ -243,7 +243,7 @@ where 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) diff --git a/src/epd7in5_hd/mod.rs b/src/epd7in5_hd/mod.rs index 5ef9cd47..c566b56c 100644 --- a/src/epd7in5_hd/mod.rs +++ b/src/epd7in5_hd/mod.rs @@ -10,7 +10,7 @@ //! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_HD.py) //! use embedded_hal::{ - delay::DelayUs, + delay::DelayNs, digital::{InputPin, OutputPin}, spi::SpiDevice, }; @@ -58,7 +58,7 @@ where 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 @@ -110,7 +110,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( @@ -240,7 +240,7 @@ where 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) diff --git a/src/epd7in5_v2/mod.rs b/src/epd7in5_v2/mod.rs index f971bf43..26fa9dba 100644 --- a/src/epd7in5_v2/mod.rs +++ b/src/epd7in5_v2/mod.rs @@ -11,7 +11,7 @@ //! The hardware and interface of V2 are compatible with V1, however, the related software should be updated. use embedded_hal::{ - delay::DelayUs, + delay::DelayNs, digital::{InputPin, OutputPin}, spi::SpiDevice, }; @@ -59,7 +59,7 @@ where 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,7 +92,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( @@ -217,7 +217,7 @@ where 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) diff --git a/src/epd7in5b_v2/mod.rs b/src/epd7in5b_v2/mod.rs index 3b204e31..767bb9ff 100644 --- a/src/epd7in5b_v2/mod.rs +++ b/src/epd7in5b_v2/mod.rs @@ -11,7 +11,7 @@ //! The hardware and interface of V2 are compatible with V1, however, the related software should be updated. use embedded_hal::{ - delay::DelayUs, + delay::DelayNs, digital::{InputPin, OutputPin}, spi::SpiDevice, }; @@ -64,7 +64,7 @@ where 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 @@ -166,7 +166,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = TriColor; fn new( @@ -306,7 +306,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { /// temporary replacement for missing delay in the trait to call wait_until_idle #[allow(clippy::too_many_arguments)] diff --git a/src/interface.rs b/src/interface.rs index e53d9186..f3a9a3d7 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -28,7 +28,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { /// Creates a new `DisplayInterface` struct /// @@ -182,7 +182,7 @@ where /// /// Most likely there was a mistake with the 2in9 busy connection /// //TODO: use the #cfg feature to make this compile the right way for the certain types - pub(crate) fn is_busy(&self, is_busy_low: bool) -> bool { + pub(crate) fn is_busy(&mut self, is_busy_low: bool) -> bool { (is_busy_low && self.busy.is_low().unwrap_or(false)) || (!is_busy_low && self.busy.is_high().unwrap_or(false)) } diff --git a/src/traits.rs b/src/traits.rs index 25df34ad..b1f3f731 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -24,7 +24,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { /// This initialises the EPD and powers it up /// @@ -47,7 +47,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { /// Transmit data to the SRAM of the EPD /// @@ -132,7 +132,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { /// The Color Type used by the Display type DisplayColor; @@ -291,7 +291,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { /// Updates the old frame. fn update_old_frame(