Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ edition = "2018"
# `branch` is optional; default is `master`
travis-ci = { repository = "caemor/epd-waveshare" }


[features]
default = ["epd1in54", "epd1in54b", "epd2in9", "epd4in2", "epd7in5", "graphics"]
default = ["epd1in54", "epd1in54b", "epd2in9", "epd4in2", "epd7in5", "epd7in5_v2", "graphics"]

graphics = ["embedded-graphics"]
epd1in54 = []
epd1in54b = []
epd2in9 = []
epd4in2 = []
epd7in5 = []
epd7in5_v2 = []
# offers an alternative fast full lut for type_a displays, but the refresh isnt as clean looking
type_a_alternative_faster_lut = []

Expand All @@ -36,4 +36,4 @@ version = "0.5.2"

[dependencies.embedded-hal]
features = ["unproven"]
version = "0.2.1"
version = "0.2.3"
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,29 @@ epd.display_frame(&mut spi)?;

| Device (with Link) | Colors | Flexible Display | Partial Refresh | Supported | Tested |
| :---: | --- | :---: | :---: | :---: | :---: |
| [7.5 Inch B/W V2 (A)](https://www.waveshare.com/product/7.5inch-e-paper-hat.htm) [[1](#1-75-inch-bw-v2-a)] | Black, White | ✕ | ✕ | ✔ | ✔ |
| [7.5 Inch B/W (A)](https://www.waveshare.com/product/7.5inch-e-paper-hat.htm) | Black, White | ✕ | ✕ | ✔ | ✔ |
| [4.2 Inch B/W (A)](https://www.waveshare.com/product/4.2inch-e-paper-module.htm) | Black, White | ✕ | Not officially [[1](#42-inch-e-ink-blackwhite)] | ✔ | ✔ |
| [4.2 Inch B/W (A)](https://www.waveshare.com/product/4.2inch-e-paper-module.htm) | Black, White | ✕ | Not officially [[2](#2-42-inch-e-ink-blackwhite---partial-refresh)] | ✔ | ✔ |
| [1.54 Inch B/W (A)](https://www.waveshare.com/1.54inch-e-Paper-Module.htm) | Black, White | ✕ | ✔ | ✔ | ✔ |
| [2.13 Inch B/W (A)](https://www.waveshare.com/product/2.13inch-e-paper-hat.htm) | Black, White | ✕ | ✔ | | |
| [2.9 Inch B/W (A)](https://www.waveshare.com/product/2.9inch-e-paper-module.htm) | Black, White | ✕ | ✔ | ✔ | ✔ [[2](#2-29-inch-e-ink-blackwhite---tests)] |
| [2.9 Inch B/W (A)](https://www.waveshare.com/product/2.9inch-e-paper-module.htm) | Black, White | ✕ | ✔ | ✔ | ✔ [[3](#3-29-inch-e-ink-blackwhite---tests)] |
| [1.54 Inch B/W/R (B)](https://www.waveshare.com/product/modules/oleds-lcds/e-paper/1.54inch-e-paper-module-b.htm) | Black, White, Red | ✕ | ✕ | ✔ | ✔ |

### [1]: 7.5 Inch B/W V2 (A)

### [1]: 4.2 Inch E-Ink Black/White - Partial Refresh
Since November 2019 Waveshare sells their updated version of these displays.
They should have a "V2" marking sticker on the backside of the panel.

Out of the Box the original driver from Waveshare only supports full updates.
Use `epd7in5_v2` instead of `epd7in5`, because the protocol changed.

### [2]: 4.2 Inch E-Ink Black/White - Partial Refresh

Out of the Box the original driver from Waveshare only supports full updates.

That means: Be careful with the quick refresh updates: <br>
It's possible with this driver but might lead to ghosting / burn-in effects therefore it's hidden behind a feature.

### [2]: 2.9 Inch E-Ink Black/White - Tests
### [3]: 2.9 Inch E-Ink Black/White - Tests

Since my 2.9 Inch Display has some blurring issues I am not absolutly sure if everything was working correctly as it should :-)

Expand All @@ -75,7 +82,7 @@ Since my 2.9 Inch Display has some blurring issues I am not absolutly sure if ev
### Display Configs

There are two types of Display Configurations used in Wavedshare EPDs, which also needs to be set on the "new" E-Paper Driver HAT.
They are also called A and B, but you shouldn't get confused and mix it with the Type A,B,C and D of the various Displays, which just describe different types (colored variants) or new versions. In the Display Config the seperation is most likely due to included fast partial refresh of the displays. In a Tabular form:
They are also called A and B, but you shouldn't get confused and mix it with the Type A,B,C and D of the various Displays, which just describe different types (colored variants) or new versions. In the Display Config the seperation is most likely due to included fast partial refresh of the displays. In a Tabular form:

| Type A | Tybe B |
| :---: | :---: |
Expand Down
15 changes: 15 additions & 0 deletions examples/epd7in5_v2_full/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "embedded_linux_eink_example"
version = "0.1.0"
authors = [
"Christoph Groß <christoph-gross@mailbox.org>",
"Jack Grigg <thestr4d@gmail.com>",
"Christoph Grabo <asaaki@mannaz.cc>",
]
edition = "2018"

[dependencies]
embedded-graphics = "0.5.2"
embedded-hal = { version = "0.2.3", features = ["unproven"] }
epd-waveshare = { path = "../../", default-features = false, features = ["epd7in5_v2", "graphics"]}
linux-embedded-hal = "0.3.0"
188 changes: 188 additions & 0 deletions examples/epd7in5_v2_full/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
#![deny(warnings)]

use embedded_graphics::{
coord::Coord,
fonts::{Font12x16, Font6x8},
prelude::*,
primitives::{Circle, Line},
Drawing,
};
use embedded_hal::prelude::*;
use epd_waveshare::{
epd7in5_v2::{Display7in5, EPD7in5},
graphics::{Display, DisplayRotation},
prelude::*,
};
use linux_embedded_hal::{
spidev::{self, SpidevOptions},
sysfs_gpio::Direction,
Delay, Pin, Spidev,
};

// 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() {
if let Err(e) = run() {
eprintln!("Program exited early with error: {}", e);
}
}

fn run() -> Result<(), std::io::Error> {
// Configure SPI
// Settings are taken from
let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory");
let options = SpidevOptions::new()
.bits_per_word(8)
.max_speed_hz(4_000_000)
.mode(spidev::SpiModeFlags::SPI_MODE_0)
.build();
spi.configure(&options).expect("spi configuration");

// Configure Digital I/O Pin to be used as Chip Select for SPI
let cs = Pin::new(8);
cs.export().expect("cs export");
while !cs.is_exported() {}
cs.set_direction(Direction::Out).expect("CS Direction");
cs.set_value(1).expect("CS Value set to 1");

let busy = Pin::new(24);
busy.export().expect("busy export");
while !busy.is_exported() {}
busy.set_direction(Direction::In).expect("busy Direction");

let dc = Pin::new(25);
dc.export().expect("dc export");
while !dc.is_exported() {}
dc.set_direction(Direction::Out).expect("dc Direction");
dc.set_value(1).expect("dc Value set to 1");

let rst = Pin::new(17);
rst.export().expect("rst export");
while !rst.is_exported() {}
rst.set_direction(Direction::Out).expect("rst Direction");
rst.set_value(1).expect("rst Value set to 1");

let mut delay = Delay {};

let mut epd7in5 =
EPD7in5::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error");

println!("Test all the rotations");
let mut display = Display7in5::default();
display.set_rotation(DisplayRotation::Rotate0);
display.draw(
Font6x8::render_str("Rotate 0!")
.stroke(Some(Color::Black))
.fill(Some(Color::White))
.translate(Coord::new(5, 50))
.into_iter(),
);

display.set_rotation(DisplayRotation::Rotate90);
display.draw(
Font6x8::render_str("Rotate 90!")
.stroke(Some(Color::Black))
.fill(Some(Color::White))
.translate(Coord::new(5, 50))
.into_iter(),
);

display.set_rotation(DisplayRotation::Rotate180);
display.draw(
Font6x8::render_str("Rotate 180!")
.stroke(Some(Color::Black))
.fill(Some(Color::White))
.translate(Coord::new(5, 50))
.into_iter(),
);

display.set_rotation(DisplayRotation::Rotate270);
display.draw(
Font6x8::render_str("Rotate 270!")
.stroke(Some(Color::Black))
.fill(Some(Color::White))
.translate(Coord::new(5, 50))
.into_iter(),
);

epd7in5.update_frame(&mut spi, &display.buffer()).unwrap();
epd7in5
.display_frame(&mut spi)
.expect("display frame new graphics");
delay.delay_ms(5000u16);

println!("Now test new graphics with default rotation and some special stuff:");
display.clear_buffer(Color::White);

// draw a analog clock
display.draw(
Circle::new(Coord::new(64, 64), 64)
.stroke(Some(Color::Black))
.into_iter(),
);
display.draw(
Line::new(Coord::new(64, 64), Coord::new(0, 64))
.stroke(Some(Color::Black))
.into_iter(),
);
display.draw(
Line::new(Coord::new(64, 64), Coord::new(80, 80))
.stroke(Some(Color::Black))
.into_iter(),
);

// draw white on black background
display.draw(
Font6x8::render_str("It's working-WoB!")
// Using Style here
.style(Style {
fill_color: Some(Color::Black),
stroke_color: Some(Color::White),
stroke_width: 0u8, // Has no effect on fonts
})
.translate(Coord::new(175, 250))
.into_iter(),
);

// use bigger/different font
display.draw(
Font12x16::render_str("It's working-BoW!")
// Using Style here
.style(Style {
fill_color: Some(Color::White),
stroke_color: Some(Color::Black),
stroke_width: 0u8, // Has no effect on fonts
})
.translate(Coord::new(50, 200))
.into_iter(),
);

// a moving `Hello World!`
let limit = 10;
for i in 0..limit {
println!("Moving Hello World. Loop {} from {}", (i + 1), limit);

display.draw(
Font6x8::render_str(" Hello World! ")
.style(Style {
fill_color: Some(Color::White),
stroke_color: Some(Color::Black),
stroke_width: 0u8, // Has no effect on fonts
})
.translate(Coord::new(5 + i * 12, 50))
.into_iter(),
);

epd7in5.update_frame(&mut spi, &display.buffer()).unwrap();
epd7in5
.display_frame(&mut spi)
.expect("display frame new graphics");

delay.delay_ms(1_000u16);
}

println!("Finished tests - going to sleep");
epd7in5.sleep(&mut spi)
}
2 changes: 1 addition & 1 deletion src/epd1in54/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const IS_BUSY_LOW: bool = false;

use embedded_hal::{
blocking::{delay::*, spi::Write},
digital::*,
digital::v2::*,
};

use crate::type_a::{
Expand Down
2 changes: 1 addition & 1 deletion src/epd1in54b/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use embedded_hal::{
blocking::{delay::*, spi::Write},
digital::*,
digital::v2::*,
};

use crate::interface::DisplayInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/epd2in9/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const IS_BUSY_LOW: bool = false;

use embedded_hal::{
blocking::{delay::*, spi::Write},
digital::*,
digital::v2::*,
};

use crate::type_a::{
Expand Down
2 changes: 1 addition & 1 deletion src/epd4in2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

use embedded_hal::{
blocking::{delay::*, spi::Write},
digital::*,
digital::v2::*,
};

use crate::interface::DisplayInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/epd7in5/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use embedded_hal::{
blocking::{delay::*, spi::Write},
digital::v1::{InputPin, OutputPin},
digital::v2::{InputPin, OutputPin},
};

use crate::color::Color;
Expand Down
Loading