From 9c1bfa3663ea5bb8b871924a78480b495d71e421 Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Tue, 30 Nov 2021 23:53:34 +0100 Subject: [PATCH] Update to e.h 1.0a6 & linux e.h --- Cargo.toml | 2 +- examples/epd1in54_no_graphics.rs | 7 ++++--- examples/epd2in13_v2.rs | 10 +++++----- examples/epd2in13bc.rs | 10 +++++----- examples/epd4in2.rs | 10 +++++----- examples/epd4in2_variable_size.rs | 10 +++++----- src/epd1in54/mod.rs | 2 +- src/epd2in13_v2/mod.rs | 2 +- src/epd2in9bc/mod.rs | 2 +- src/epd5in65f/mod.rs | 2 +- src/epd7in5/mod.rs | 2 +- src/epd7in5_hd/mod.rs | 2 +- src/epd7in5_v2/mod.rs | 2 +- src/interface.rs | 2 +- src/lib.rs | 6 +++++- src/traits.rs | 2 +- 16 files changed, 39 insertions(+), 34 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 65e4efe..51be1d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ bit_field = "0.10.1" [dev-dependencies] embedded-graphics = "0.7.1" -linux-embedded-hal = "0.4.0-alpha.1" +linux-embedded-hal = {path = "../linux-embedded-hal"}# "0.4.0-alpha.1" embedded-hal-mock = "0.8" [features] diff --git a/examples/epd1in54_no_graphics.rs b/examples/epd1in54_no_graphics.rs index 063ef61..40e7e87 100644 --- a/examples/epd1in54_no_graphics.rs +++ b/examples/epd1in54_no_graphics.rs @@ -1,17 +1,18 @@ #![deny(warnings)] +use embedded_hal::delay::blocking::DelayUs; use epd_waveshare::{epd1in54::Epd1in54, prelude::*}; use linux_embedded_hal::{ spidev::{self, SpidevOptions}, sysfs_gpio::Direction, - Delay, Pin, Spidev, + Delay, Spidev, SysfsPin as Pin, }; // activate spi, gpio in raspi-config // needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems // see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues -fn main() -> Result<(), std::io::Error> { +fn main() -> Result<(), linux_embedded_hal::SPIError> { // Configure SPI // SPI settings are from eink-waveshare-rs documenation let mut spi = Spidev::open("/dev/spidev0.0")?; @@ -89,7 +90,7 @@ fn main() -> Result<(), std::io::Error> { // Display updated frame epd.display_frame(&mut spi, &mut delay)?; - delay.delay_ms(5000u16); + delay.delay_ms(5000).expect("delay"); // Set the EPD to sleep epd.sleep(&mut spi, &mut delay)?; diff --git a/examples/epd2in13_v2.rs b/examples/epd2in13_v2.rs index be1b314..badce6c 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::prelude::*; +use embedded_hal::delay::blocking::DelayUs; use epd_waveshare::{ color::*, epd2in13_v2::{Display2in13, Epd2in13}, @@ -16,14 +16,14 @@ use epd_waveshare::{ use linux_embedded_hal::{ spidev::{self, SpidevOptions}, sysfs_gpio::Direction, - Delay, Pin, Spidev, + Delay, Spidev, SysfsPin as Pin, }; // activate spi, gpio in raspi-config // needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems // see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues -fn main() -> Result<(), std::io::Error> { +fn main() -> Result<(), linux_embedded_hal::SPIError> { // Configure SPI // Settings are taken from let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory"); @@ -83,7 +83,7 @@ fn main() -> Result<(), std::io::Error> { epd2in13 .display_frame(&mut spi, &mut delay) .expect("display frame new graphics"); - delay.delay_ms(5000u16); + delay.delay_ms(5000).expect("delay"); //println!("Now test new graphics with default rotation and some special stuff:"); display.clear_buffer(Color::White); @@ -135,7 +135,7 @@ fn main() -> Result<(), std::io::Error> { epd2in13 .update_and_display_frame(&mut spi, display.buffer(), &mut delay) .expect("display frame new graphics"); - delay.delay_ms(1_000u16); + delay.delay_ms(1_000).expect("delay"); } // Show a spinning bar without any delay between frames. Shows how «fast» diff --git a/examples/epd2in13bc.rs b/examples/epd2in13bc.rs index ba45aab..fa2278c 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::prelude::*; +use embedded_hal::delay::blocking::DelayUs; 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, Pin, Spidev, + Delay, Spidev, SysfsPin as Pin, }; // activate spi, gpio in raspi-config @@ -34,7 +34,7 @@ use linux_embedded_hal::{ // // after finishing, put the display to sleep -fn main() -> Result<(), std::io::Error> { +fn main() -> Result<(), linux_embedded_hal::SPIError> { let busy = Pin::new(24); // GPIO 24, board J-18 busy.export().expect("busy export"); while !busy.is_exported() {} @@ -98,7 +98,7 @@ fn main() -> Result<(), std::io::Error> { .expect("display frame new graphics"); println!("First frame done. Waiting 5s"); - delay.delay_ms(5000u16); + delay.delay_ms(5000).expect("delay"); println!("Now test new graphics with default rotation and three colors:"); display.clear_buffer(TriColor::White); @@ -143,7 +143,7 @@ fn main() -> Result<(), std::io::Error> { .expect("display frame new graphics"); println!("Second frame done. Waiting 5s"); - delay.delay_ms(5000u16); + delay.delay_ms(5000).expect("delay"); // clear both bw buffer and chromatic buffer display.clear_buffer(TriColor::White); diff --git a/examples/epd4in2.rs b/examples/epd4in2.rs index 729e03c..612fc24 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::prelude::*; +use embedded_hal::delay::blocking::DelayUs; use epd_waveshare::{ color::*, epd4in2::{Display4in2, Epd4in2}, @@ -16,14 +16,14 @@ use epd_waveshare::{ use linux_embedded_hal::{ spidev::{self, SpidevOptions}, sysfs_gpio::Direction, - Delay, Pin, Spidev, + Delay, Spidev, SysfsPin as Pin, }; // activate spi, gpio in raspi-config // needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems // see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues -fn main() -> Result<(), std::io::Error> { +fn main() -> Result<(), linux_embedded_hal::SPIError> { // Configure SPI // Settings are taken from let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory"); @@ -83,7 +83,7 @@ fn main() -> Result<(), std::io::Error> { epd4in2 .display_frame(&mut spi, &mut delay) .expect("display frame new graphics"); - delay.delay_ms(5000u16); + delay.delay_ms(5000).expect("delay"); println!("Now test new graphics with default rotation and some special stuff"); display.clear_buffer(Color::White); @@ -141,7 +141,7 @@ fn main() -> Result<(), std::io::Error> { .display_frame(&mut spi, &mut delay) .expect("display frame new graphics"); - delay.delay_ms(1_000u16); + delay.delay_ms(1_000).expect("delay"); } println!("Finished tests - going to sleep"); diff --git a/examples/epd4in2_variable_size.rs b/examples/epd4in2_variable_size.rs index 95a39ff..943a52d 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::prelude::*; +use embedded_hal::delay::blocking::DelayUs; use epd_waveshare::{ color::*, epd4in2::{self, Epd4in2}, @@ -17,14 +17,14 @@ use epd_waveshare::{ use linux_embedded_hal::{ spidev::{self, SpidevOptions}, sysfs_gpio::Direction, - Delay, Pin, Spidev, + Delay, Spidev, SysfsPin as Pin, }; // activate spi, gpio in raspi-config // needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems // see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues -fn main() -> Result<(), std::io::Error> { +fn main() -> Result<(), linux_embedded_hal::SPIError> { // Configure SPI // Settings are taken from let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory"); @@ -89,7 +89,7 @@ fn main() -> Result<(), std::io::Error> { epd4in2 .display_frame(&mut spi, &mut delay) .expect("display frame new graphics"); - delay.delay_ms(5000u16); + delay.delay_ms(5000).expect("delay"); println!("Now test new graphics with default rotation and some special stuff:"); display.set_rotation(DisplayRotation::Rotate0); @@ -146,7 +146,7 @@ fn main() -> Result<(), std::io::Error> { .display_frame(&mut spi, &mut delay) .expect("display frame new graphics"); - delay.delay_ms(1_000u16); + delay.delay_ms(1_000).expect("delay"); } println!("Finished tests - going to sleep"); diff --git a/src/epd1in54/mod.rs b/src/epd1in54/mod.rs index 3b3f624..3c95765 100644 --- a/src/epd1in54/mod.rs +++ b/src/epd1in54/mod.rs @@ -56,7 +56,7 @@ const IS_BUSY_LOW: bool = false; use crate::eh_prelude::*; use crate::type_a::{ command::Command, - constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE} + constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE}, }; use crate::color::Color; diff --git a/src/epd2in13_v2/mod.rs b/src/epd2in13_v2/mod.rs index 8c88ee8..6953574 100644 --- a/src/epd2in13_v2/mod.rs +++ b/src/epd2in13_v2/mod.rs @@ -8,9 +8,9 @@ //! - [Controller Datasheet SS1780](http://www.e-paper-display.com/download_detail/downloadsId=682.html) //! -use crate::eh_prelude::*; use crate::buffer_len; use crate::color::Color; +use crate::eh_prelude::*; use crate::interface::DisplayInterface; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; diff --git a/src/epd2in9bc/mod.rs b/src/epd2in9bc/mod.rs index 6ac8233..c583c19 100644 --- a/src/epd2in9bc/mod.rs +++ b/src/epd2in9bc/mod.rs @@ -53,7 +53,7 @@ //!# Ok(()) //!# } //!``` -//! +//! use crate::eh_prelude::*; use crate::interface::DisplayInterface; use crate::traits::{ diff --git a/src/epd5in65f/mod.rs b/src/epd5in65f/mod.rs index 1c325a0..3fc6d97 100644 --- a/src/epd5in65f/mod.rs +++ b/src/epd5in65f/mod.rs @@ -6,8 +6,8 @@ //! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_5in65f.c) //! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd5in65f.py) -use crate::eh_prelude::*; use crate::color::OctColor; +use crate::eh_prelude::*; use crate::interface::DisplayInterface; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; diff --git a/src/epd7in5/mod.rs b/src/epd7in5/mod.rs index aa02272..d8b9a01 100644 --- a/src/epd7in5/mod.rs +++ b/src/epd7in5/mod.rs @@ -6,8 +6,8 @@ //! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/702def06bcb75983c98b0f9d25d43c552c248eb0/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_7in5.c) //! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/702def06bcb75983c98b0f9d25d43c552c248eb0/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5.py) -use crate::eh_prelude::*; use crate::color::Color; +use crate::eh_prelude::*; use crate::interface::DisplayInterface; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; diff --git a/src/epd7in5_hd/mod.rs b/src/epd7in5_hd/mod.rs index 4b248df..da5fb0c 100644 --- a/src/epd7in5_hd/mod.rs +++ b/src/epd7in5_hd/mod.rs @@ -9,8 +9,8 @@ //! - [Datasheet](https://www.waveshare.com/w/upload/2/27/7inch_HD_e-Paper_Specification.pdf) //! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_HD.py) //! -use crate::eh_prelude::*; use crate::color::Color; +use crate::eh_prelude::*; use crate::interface::DisplayInterface; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; diff --git a/src/epd7in5_v2/mod.rs b/src/epd7in5_v2/mod.rs index e0fb254..3d0e263 100644 --- a/src/epd7in5_v2/mod.rs +++ b/src/epd7in5_v2/mod.rs @@ -10,8 +10,8 @@ //! Revision V2 has been released on 2019.11, the resolution is upgraded to 800×480, from 640×384 of V1. //! The hardware and interface of V2 are compatible with V1, however, the related software should be updated. -use crate::eh_prelude::*; use crate::color::Color; +use crate::eh_prelude::*; use crate::interface::DisplayInterface; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; diff --git a/src/interface.rs b/src/interface.rs index 0c9ac71..e56f770 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -1,6 +1,6 @@ +use crate::eh_prelude::*; use crate::traits::Command; use core::marker::PhantomData; -use crate::eh_prelude::*; /// The Connection Interface of all (?) Waveshare EPD-Devices /// diff --git a/src/lib.rs b/src/lib.rs index 7f0eeb6..42678ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,7 +104,11 @@ pub mod prelude { } pub(crate) mod eh_prelude { - pub(crate) use embedded_hal::{delay::blocking::DelayUs, spi::blocking::Write, digital::blocking::{InputPin, OutputPin}}; + pub(crate) use embedded_hal::{ + delay::blocking::DelayUs, + digital::blocking::{InputPin, OutputPin}, + spi::blocking::Write, + }; } /// Computes the needed buffer length. Takes care of rounding up in case width diff --git a/src/traits.rs b/src/traits.rs index 23123a4..bbbff5d 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -1,5 +1,5 @@ -use core::marker::Sized; use crate::eh_prelude::*; +use core::marker::Sized; /// All commands need to have this trait which gives the address of the command /// which needs to be send via SPI with activated CommandsPin (Data/Command Pin in CommandMode)