Browse Source

Update to e.h 1.0a6 & linux e.h

embedded-hal-1.0
Caemor 4 years ago
parent
commit
9c1bfa3663
  1. 2
      Cargo.toml
  2. 7
      examples/epd1in54_no_graphics.rs
  3. 10
      examples/epd2in13_v2.rs
  4. 10
      examples/epd2in13bc.rs
  5. 10
      examples/epd4in2.rs
  6. 10
      examples/epd4in2_variable_size.rs
  7. 2
      src/epd1in54/mod.rs
  8. 2
      src/epd2in13_v2/mod.rs
  9. 2
      src/epd5in65f/mod.rs
  10. 2
      src/epd7in5/mod.rs
  11. 2
      src/epd7in5_hd/mod.rs
  12. 2
      src/epd7in5_v2/mod.rs
  13. 2
      src/interface.rs
  14. 6
      src/lib.rs
  15. 2
      src/traits.rs

2
Cargo.toml

@ -22,7 +22,7 @@ bit_field = "0.10.1"
[dev-dependencies] [dev-dependencies]
embedded-graphics = "0.7.1" 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" embedded-hal-mock = "0.8"
[features] [features]

7
examples/epd1in54_no_graphics.rs

@ -1,17 +1,18 @@
#![deny(warnings)] #![deny(warnings)]
use embedded_hal::delay::blocking::DelayUs;
use epd_waveshare::{epd1in54::Epd1in54, prelude::*}; use epd_waveshare::{epd1in54::Epd1in54, prelude::*};
use linux_embedded_hal::{ use linux_embedded_hal::{
spidev::{self, SpidevOptions}, spidev::{self, SpidevOptions},
sysfs_gpio::Direction, sysfs_gpio::Direction,
Delay, Pin, Spidev, Delay, Spidev, SysfsPin as Pin,
}; };
// activate spi, gpio in raspi-config // activate spi, gpio in raspi-config
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems // 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 // 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 // Configure SPI
// SPI settings are from eink-waveshare-rs documenation // SPI settings are from eink-waveshare-rs documenation
let mut spi = Spidev::open("/dev/spidev0.0")?; let mut spi = Spidev::open("/dev/spidev0.0")?;
@ -89,7 +90,7 @@ fn main() -> Result<(), std::io::Error> {
// Display updated frame // Display updated frame
epd.display_frame(&mut spi, &mut delay)?; epd.display_frame(&mut spi, &mut delay)?;
delay.delay_ms(5000u16); delay.delay_ms(5000).expect("delay");
// Set the EPD to sleep // Set the EPD to sleep
epd.sleep(&mut spi, &mut delay)?; epd.sleep(&mut spi, &mut delay)?;

10
examples/epd2in13_v2.rs

@ -6,7 +6,7 @@ use embedded_graphics::{
primitives::{Circle, Line, PrimitiveStyle}, primitives::{Circle, Line, PrimitiveStyle},
text::{Baseline, Text, TextStyleBuilder}, text::{Baseline, Text, TextStyleBuilder},
}; };
use embedded_hal::prelude::*; use embedded_hal::delay::blocking::DelayUs;
use epd_waveshare::{ use epd_waveshare::{
color::*, color::*,
epd2in13_v2::{Display2in13, Epd2in13}, epd2in13_v2::{Display2in13, Epd2in13},
@ -16,14 +16,14 @@ use epd_waveshare::{
use linux_embedded_hal::{ use linux_embedded_hal::{
spidev::{self, SpidevOptions}, spidev::{self, SpidevOptions},
sysfs_gpio::Direction, sysfs_gpio::Direction,
Delay, Pin, Spidev, Delay, Spidev, SysfsPin as Pin,
}; };
// activate spi, gpio in raspi-config // activate spi, gpio in raspi-config
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems // 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 // 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 // Configure SPI
// Settings are taken from // Settings are taken from
let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory"); let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory");
@ -83,7 +83,7 @@ fn main() -> Result<(), std::io::Error> {
epd2in13 epd2in13
.display_frame(&mut spi, &mut delay) .display_frame(&mut spi, &mut delay)
.expect("display frame new graphics"); .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:"); //println!("Now test new graphics with default rotation and some special stuff:");
display.clear_buffer(Color::White); display.clear_buffer(Color::White);
@ -135,7 +135,7 @@ fn main() -> Result<(), std::io::Error> {
epd2in13 epd2in13
.update_and_display_frame(&mut spi, display.buffer(), &mut delay) .update_and_display_frame(&mut spi, display.buffer(), &mut delay)
.expect("display frame new graphics"); .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» // Show a spinning bar without any delay between frames. Shows how «fast»

10
examples/epd2in13bc.rs

@ -6,7 +6,7 @@ use embedded_graphics::{
primitives::{Circle, Line, PrimitiveStyle}, primitives::{Circle, Line, PrimitiveStyle},
text::{Baseline, Text, TextStyleBuilder}, text::{Baseline, Text, TextStyleBuilder},
}; };
use embedded_hal::prelude::*; use embedded_hal::delay::blocking::DelayUs;
use epd_waveshare::{ use epd_waveshare::{
color::*, color::*,
epd2in13bc::{Display2in13bc, Epd2in13bc}, epd2in13bc::{Display2in13bc, Epd2in13bc},
@ -16,7 +16,7 @@ use epd_waveshare::{
use linux_embedded_hal::{ use linux_embedded_hal::{
spidev::{self, SpidevOptions}, spidev::{self, SpidevOptions},
sysfs_gpio::Direction, sysfs_gpio::Direction,
Delay, Pin, Spidev, Delay, Spidev, SysfsPin as Pin,
}; };
// activate spi, gpio in raspi-config // activate spi, gpio in raspi-config
@ -34,7 +34,7 @@ use linux_embedded_hal::{
// //
// after finishing, put the display to sleep // 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 let busy = Pin::new(24); // GPIO 24, board J-18
busy.export().expect("busy export"); busy.export().expect("busy export");
while !busy.is_exported() {} while !busy.is_exported() {}
@ -98,7 +98,7 @@ fn main() -> Result<(), std::io::Error> {
.expect("display frame new graphics"); .expect("display frame new graphics");
println!("First frame done. Waiting 5s"); 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:"); println!("Now test new graphics with default rotation and three colors:");
display.clear_buffer(TriColor::White); display.clear_buffer(TriColor::White);
@ -143,7 +143,7 @@ fn main() -> Result<(), std::io::Error> {
.expect("display frame new graphics"); .expect("display frame new graphics");
println!("Second frame done. Waiting 5s"); println!("Second frame done. Waiting 5s");
delay.delay_ms(5000u16); delay.delay_ms(5000).expect("delay");
// clear both bw buffer and chromatic buffer // clear both bw buffer and chromatic buffer
display.clear_buffer(TriColor::White); display.clear_buffer(TriColor::White);

10
examples/epd4in2.rs

@ -6,7 +6,7 @@ use embedded_graphics::{
primitives::{Circle, Line, PrimitiveStyleBuilder}, primitives::{Circle, Line, PrimitiveStyleBuilder},
text::{Baseline, Text, TextStyleBuilder}, text::{Baseline, Text, TextStyleBuilder},
}; };
use embedded_hal::prelude::*; use embedded_hal::delay::blocking::DelayUs;
use epd_waveshare::{ use epd_waveshare::{
color::*, color::*,
epd4in2::{Display4in2, Epd4in2}, epd4in2::{Display4in2, Epd4in2},
@ -16,14 +16,14 @@ use epd_waveshare::{
use linux_embedded_hal::{ use linux_embedded_hal::{
spidev::{self, SpidevOptions}, spidev::{self, SpidevOptions},
sysfs_gpio::Direction, sysfs_gpio::Direction,
Delay, Pin, Spidev, Delay, Spidev, SysfsPin as Pin,
}; };
// activate spi, gpio in raspi-config // activate spi, gpio in raspi-config
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems // 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 // 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 // Configure SPI
// Settings are taken from // Settings are taken from
let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory"); let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory");
@ -83,7 +83,7 @@ fn main() -> Result<(), std::io::Error> {
epd4in2 epd4in2
.display_frame(&mut spi, &mut delay) .display_frame(&mut spi, &mut delay)
.expect("display frame new graphics"); .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"); println!("Now test new graphics with default rotation and some special stuff");
display.clear_buffer(Color::White); display.clear_buffer(Color::White);
@ -141,7 +141,7 @@ fn main() -> Result<(), std::io::Error> {
.display_frame(&mut spi, &mut delay) .display_frame(&mut spi, &mut delay)
.expect("display frame new graphics"); .expect("display frame new graphics");
delay.delay_ms(1_000u16); delay.delay_ms(1_000).expect("delay");
} }
println!("Finished tests - going to sleep"); println!("Finished tests - going to sleep");

10
examples/epd4in2_variable_size.rs

@ -7,7 +7,7 @@ use embedded_graphics::{
primitives::{Circle, Line, PrimitiveStyleBuilder}, primitives::{Circle, Line, PrimitiveStyleBuilder},
text::{Baseline, Text, TextStyleBuilder}, text::{Baseline, Text, TextStyleBuilder},
}; };
use embedded_hal::prelude::*; use embedded_hal::delay::blocking::DelayUs;
use epd_waveshare::{ use epd_waveshare::{
color::*, color::*,
epd4in2::{self, Epd4in2}, epd4in2::{self, Epd4in2},
@ -17,14 +17,14 @@ use epd_waveshare::{
use linux_embedded_hal::{ use linux_embedded_hal::{
spidev::{self, SpidevOptions}, spidev::{self, SpidevOptions},
sysfs_gpio::Direction, sysfs_gpio::Direction,
Delay, Pin, Spidev, Delay, Spidev, SysfsPin as Pin,
}; };
// activate spi, gpio in raspi-config // activate spi, gpio in raspi-config
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems // 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 // 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 // Configure SPI
// Settings are taken from // Settings are taken from
let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory"); let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory");
@ -89,7 +89,7 @@ fn main() -> Result<(), std::io::Error> {
epd4in2 epd4in2
.display_frame(&mut spi, &mut delay) .display_frame(&mut spi, &mut delay)
.expect("display frame new graphics"); .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:"); println!("Now test new graphics with default rotation and some special stuff:");
display.set_rotation(DisplayRotation::Rotate0); display.set_rotation(DisplayRotation::Rotate0);
@ -146,7 +146,7 @@ fn main() -> Result<(), std::io::Error> {
.display_frame(&mut spi, &mut delay) .display_frame(&mut spi, &mut delay)
.expect("display frame new graphics"); .expect("display frame new graphics");
delay.delay_ms(1_000u16); delay.delay_ms(1_000).expect("delay");
} }
println!("Finished tests - going to sleep"); println!("Finished tests - going to sleep");

2
src/epd1in54/mod.rs

@ -56,7 +56,7 @@ const IS_BUSY_LOW: bool = false;
use crate::eh_prelude::*; use crate::eh_prelude::*;
use crate::type_a::{ use crate::type_a::{
command::Command, command::Command,
constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE} constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE},
}; };
use crate::color::Color; use crate::color::Color;

2
src/epd2in13_v2/mod.rs

@ -8,9 +8,9 @@
//! - [Controller Datasheet SS1780](http://www.e-paper-display.com/download_detail/downloadsId=682.html) //! - [Controller Datasheet SS1780](http://www.e-paper-display.com/download_detail/downloadsId=682.html)
//! //!
use crate::eh_prelude::*;
use crate::buffer_len; use crate::buffer_len;
use crate::color::Color; use crate::color::Color;
use crate::eh_prelude::*;
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};

2
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 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) //! - [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::color::OctColor;
use crate::eh_prelude::*;
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};

2
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 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) //! - [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::color::Color;
use crate::eh_prelude::*;
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};

2
src/epd7in5_hd/mod.rs

@ -9,8 +9,8 @@
//! - [Datasheet](https://www.waveshare.com/w/upload/2/27/7inch_HD_e-Paper_Specification.pdf) //! - [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) //! - [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::color::Color;
use crate::eh_prelude::*;
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};

2
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. //! 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. //! 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::color::Color;
use crate::eh_prelude::*;
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};

2
src/interface.rs

@ -1,6 +1,6 @@
use crate::eh_prelude::*;
use crate::traits::Command; use crate::traits::Command;
use core::marker::PhantomData; use core::marker::PhantomData;
use crate::eh_prelude::*;
/// The Connection Interface of all (?) Waveshare EPD-Devices /// The Connection Interface of all (?) Waveshare EPD-Devices
/// ///

6
src/lib.rs

@ -104,7 +104,11 @@ pub mod prelude {
} }
pub(crate) mod eh_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 /// Computes the needed buffer length. Takes care of rounding up in case width

2
src/traits.rs

@ -1,5 +1,5 @@
use core::marker::Sized;
use crate::eh_prelude::*; use crate::eh_prelude::*;
use core::marker::Sized;
/// All commands need to have this trait which gives the address of the command /// 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) /// which needs to be send via SPI with activated CommandsPin (Data/Command Pin in CommandMode)

Loading…
Cancel
Save