Skip to content

Commit

Permalink
do not use polling to wait for idle
Browse files Browse the repository at this point in the history
  • Loading branch information
vhdirk committed Nov 6, 2023
1 parent 83878fc commit 2ac5b9f
Show file tree
Hide file tree
Showing 23 changed files with 110 additions and 108 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ edition = "2021"
[dependencies]
embedded-graphics-core = { version = "0.4", optional = true }
embedded-hal = { version = "1.0.0-rc.1" }
embedded-hal-async = { optional = true, version = "1.0.0-rc.1", git="https://github.com/rust-embedded/embedded-hal" }
embedded-hal-async = { optional = true, version = "1.0.0-rc.1" }

bit_field = "0.10.1"

Expand Down
6 changes: 3 additions & 3 deletions examples/epd1in54_no_graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ fn main() -> Result<(), SPIError> {

// Setup of the needed pins is finished here
// Now the "real" usage of the eink-waveshare-rs crate begins
let mut epd = Epd1in54::new(&mut spi, busy, dc, rst, &mut delay, Some(5))?;
let mut epd = Epd1in54::new(&mut spi, busy, dc, rst, &mut delay, Some(5)).await?;

// Clear the full screen
epd.clear_frame(&mut spi, &mut delay)?;
epd.display_frame(&mut spi, &mut delay)?;
epd.clear_frame(&mut spi, &mut delay).await?;
epd.display_frame(&mut spi, &mut delay).await?;

// Speeddemo
epd.set_lut(&mut spi, &mut delay, Some(RefreshLut::Quick))?;
Expand Down
8 changes: 4 additions & 4 deletions src/epd1in54/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const IS_BUSY_LOW: bool = false;
const SINGLE_BYTE_WRITE: bool = true;

use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal_async::{delay::DelayUs, spi::SpiDevice};
use embedded_hal_async::{delay::DelayUs, digital::Wait, spi::SpiDevice};

use crate::type_a::{
command::Command,
Expand Down Expand Up @@ -92,7 +92,7 @@ pub struct Epd1in54<SPI, BUSY, DC, RST, DELAY> {
impl<SPI, BUSY, DC, RST, DELAY> Epd1in54<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -154,7 +154,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, BUSY, DC, RST, DELAY>
for Epd1in54<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -315,7 +315,7 @@ where
impl<SPI, BUSY, DC, RST, DELAY> Epd1in54<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down
8 changes: 4 additions & 4 deletions src/epd1in54_v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const IS_BUSY_LOW: bool = false;
const SINGLE_BYTE_WRITE: bool = true;

use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal_async::{delay::DelayUs, spi::SpiDevice};
use embedded_hal_async::{delay::DelayUs, digital::Wait, spi::SpiDevice};

use crate::type_a::command::Command;

Expand Down Expand Up @@ -42,7 +42,7 @@ pub struct Epd1in54<SPI, BUSY, DC, RST, DELAY> {
impl<SPI, BUSY, DC, RST, DELAY> Epd1in54<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -100,7 +100,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, BUSY, DC, RST, DELAY>
for Epd1in54<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -289,7 +289,7 @@ where
impl<SPI, BUSY, DC, RST, DELAY> Epd1in54<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down
10 changes: 5 additions & 5 deletions src/epd1in54b/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! A simple Driver for the Waveshare 1.54" (B) E-Ink Display via SPI
use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal_async::{delay::DelayUs, spi::SpiDevice};
use embedded_hal_async::{delay::DelayUs, digital::Wait, spi::SpiDevice};

use crate::interface::DisplayInterface;
use crate::traits::{
Expand Down Expand Up @@ -48,7 +48,7 @@ impl<SPI, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, BUSY, DC, RST, DELAY>
for Epd1in54b<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -100,7 +100,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, BUSY, DC, RST, D
for Epd1in54b<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -154,7 +154,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, BUSY, DC, RST, DELAY>
for Epd1in54b<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -359,7 +359,7 @@ where
impl<SPI, BUSY, DC, RST, DELAY> Epd1in54b<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down
10 changes: 5 additions & 5 deletions src/epd1in54c/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! A simple Driver for the Waveshare 1.54" (C) E-Ink Display via SPI
use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal_async::{delay::DelayUs, spi::SpiDevice};
use embedded_hal_async::{delay::DelayUs, digital::Wait, spi::SpiDevice};

use crate::interface::DisplayInterface;
use crate::traits::{
Expand Down Expand Up @@ -45,7 +45,7 @@ impl<SPI, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, BUSY, DC, RST, DELAY>
for Epd1in54c<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -84,7 +84,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, BUSY, DC, RST, D
for Epd1in54c<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -131,7 +131,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, BUSY, DC, RST, DELAY>
for Epd1in54c<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -278,7 +278,7 @@ where
impl<SPI, BUSY, DC, RST, DELAY> Epd1in54c<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down
8 changes: 4 additions & 4 deletions src/epd2in13_v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//!
use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal_async::{delay::DelayUs, spi::SpiDevice};
use embedded_hal_async::{delay::DelayUs, digital::Wait, spi::SpiDevice};

use crate::buffer_len;
use crate::color::Color;
Expand Down Expand Up @@ -81,7 +81,7 @@ impl<SPI, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, BUSY, DC, RST, DELAY>
for Epd2in13<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -181,7 +181,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, BUSY, DC, RST, DELAY>
for Epd2in13<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -407,7 +407,7 @@ where
impl<SPI, BUSY, DC, RST, DELAY> Epd2in13<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down
10 changes: 5 additions & 5 deletions src/epd2in13bc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
//!# }
//!```
use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal_async::{delay::DelayUs, spi::SpiDevice};
use embedded_hal_async::{delay::DelayUs, digital::Wait, spi::SpiDevice};

use crate::interface::DisplayInterface;
use crate::traits::{
Expand Down Expand Up @@ -102,7 +102,7 @@ impl<SPI, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, BUSY, DC, RST, DELAY>
for Epd2in13bc<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -149,7 +149,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, BUSY, DC, RST, D
for Epd2in13bc<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -204,7 +204,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, BUSY, DC, RST, DELAY>
for Epd2in13bc<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -373,7 +373,7 @@ where
impl<SPI, BUSY, DC, RST, DELAY> Epd2in13bc<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down
10 changes: 5 additions & 5 deletions src/epd2in7b/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! [Documentation](https://www.waveshare.com/wiki/2.7inch_e-Paper_HAT_(B))
use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal_async::{delay::DelayUs, spi::SpiDevice};
use embedded_hal_async::{delay::DelayUs, digital::Wait, spi::SpiDevice};

use crate::interface::DisplayInterface;
use crate::traits::{
Expand Down Expand Up @@ -52,7 +52,7 @@ impl<SPI, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, BUSY, DC, RST, DELAY>
for Epd2in7b<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -126,7 +126,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, BUSY, DC, RST, DELAY>
for Epd2in7b<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -310,7 +310,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, BUSY, DC, RST, D
for Epd2in7b<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -369,7 +369,7 @@ where
impl<SPI, BUSY, DC, RST, DELAY> Epd2in7b<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down
8 changes: 4 additions & 4 deletions src/epd2in9/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const IS_BUSY_LOW: bool = false;
const SINGLE_BYTE_WRITE: bool = true;

use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal_async::{delay::DelayUs, spi::SpiDevice};
use embedded_hal_async::{delay::DelayUs, digital::Wait, spi::SpiDevice};

use crate::type_a::{
command::Command,
Expand Down Expand Up @@ -89,7 +89,7 @@ pub struct Epd2in9<SPI, BUSY, DC, RST, DELAY> {
impl<SPI, BUSY, DC, RST, DELAY> Epd2in9<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -146,7 +146,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, BUSY, DC, RST, DELAY>
for Epd2in9<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -309,7 +309,7 @@ where
impl<SPI, BUSY, DC, RST, DELAY> Epd2in9<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down
10 changes: 5 additions & 5 deletions src/epd2in9_v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const LUT_PARTIAL_2IN9: [u8; 159] = [
];

use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal_async::{delay::DelayUs, spi::SpiDevice};
use embedded_hal_async::{delay::DelayUs, digital::Wait, spi::SpiDevice};

use crate::type_a::command::Command;

Expand Down Expand Up @@ -112,7 +112,7 @@ pub struct Epd2in9<SPI, BUSY, DC, RST, DELAY> {
impl<SPI, BUSY, DC, RST, DELAY> Epd2in9<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -156,7 +156,7 @@ impl<SPI, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, BUSY, DC, RST, DELAY>
for Epd2in9<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -310,7 +310,7 @@ where
impl<SPI, BUSY, DC, RST, DELAY> Epd2in9<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down Expand Up @@ -404,7 +404,7 @@ impl<SPI, BUSY, DC, RST, DELAY> QuickRefresh<SPI, BUSY, DC, RST, DELAY>
for Epd2in9<SPI, BUSY, DC, RST, DELAY>
where
SPI: SpiDevice,
BUSY: InputPin,
BUSY: InputPin + Wait,
DC: OutputPin,
RST: OutputPin,
DELAY: DelayUs,
Expand Down
Loading

0 comments on commit 2ac5b9f

Please sign in to comment.