Merge pull request #20 from Caemor/update-linux-embedded-hal
Update to linux-embedded-hal v0.2.1 and remove hackinputpinembedded-hal-1.0
commit
63d1de0417
|
|
@ -94,16 +94,17 @@ install:
|
||||||
- cargo install cargo-travis || true
|
- cargo install cargo-travis || true
|
||||||
- rustup override set nightly
|
- rustup override set nightly
|
||||||
- rustup target add thumbv7m-none-eabi
|
- rustup target add thumbv7m-none-eabi
|
||||||
|
- rustup component add clippy-preview
|
||||||
|
|
||||||
|
#TODO: remove -A clippy::new_ret_no_self when new version of clippy gets released!
|
||||||
script:
|
script:
|
||||||
- cargo check
|
- cargo check
|
||||||
- cargo build --release
|
- cargo clippy --all-targets --all-features -- -D warnings -A clippy::new_ret_no_self
|
||||||
- cargo test
|
|
||||||
- cargo test --all-features --release
|
- cargo test --all-features --release
|
||||||
- cargo doc --all-features --release
|
- cargo doc --all-features --release
|
||||||
- cd examples/embedded_linux_epd4in2 && cargo check && cd ../../
|
- cd examples/embedded_linux_epd4in2 && cargo check && cd ../../
|
||||||
- cd examples/embedded_linux_epd1in54 && cargo check && cd ../../
|
- cd examples/embedded_linux_epd1in54 && cargo check && cd ../../
|
||||||
- cd examples/stm32f3discovery && cargo check --target thumbv7m-none-eabi && cd ../../
|
# - cd examples/stm32f3discovery && cargo check --target thumbv7m-none-eabi && cd ../../
|
||||||
#- cd ../f3_stm32f30x && cargo build
|
#- cd ../f3_stm32f30x && cargo build
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,9 @@ authors = ["Christoph Groß <christoph-gross@mailbox.org>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
#eink_waveshare_rs = { git = "https://github.com/Caemor/eink-waveshare-rs"}
|
|
||||||
#eink_waveshare_rs = { path = "../../"}
|
|
||||||
eink_waveshare_rs = { path = "../../", default-features = false, features = ["epd1in54", "graphics"]}
|
eink_waveshare_rs = { path = "../../", default-features = false, features = ["epd1in54", "graphics"]}
|
||||||
|
|
||||||
linux-embedded-hal = "0.2.0"
|
linux-embedded-hal = "0.2.1"
|
||||||
|
|
||||||
embedded-graphics = "0.4.3"
|
embedded-graphics = "0.4.3"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
// the library for the embedded linux device
|
// the library for the embedded linux device
|
||||||
extern crate linux_embedded_hal as lin_hal;
|
extern crate linux_embedded_hal as lin_hal;
|
||||||
|
use lin_hal::spidev::{self, SpidevOptions};
|
||||||
|
use lin_hal::{Pin, Spidev};
|
||||||
|
use lin_hal::sysfs_gpio::Direction;
|
||||||
|
use lin_hal::Delay;
|
||||||
|
|
||||||
// the eink library
|
// the eink library
|
||||||
extern crate eink_waveshare_rs;
|
extern crate eink_waveshare_rs;
|
||||||
|
|
||||||
|
|
||||||
use eink_waveshare_rs::{
|
use eink_waveshare_rs::{
|
||||||
epd1in54::{
|
epd1in54::{
|
||||||
EPD1in54,
|
EPD1in54,
|
||||||
|
|
@ -14,11 +16,7 @@ use eink_waveshare_rs::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use lin_hal::spidev::{self, SpidevOptions};
|
// Graphics
|
||||||
use lin_hal::{Pin, Spidev};
|
|
||||||
use lin_hal::sysfs_gpio::Direction;
|
|
||||||
use lin_hal::Delay;
|
|
||||||
|
|
||||||
extern crate embedded_graphics;
|
extern crate embedded_graphics;
|
||||||
use embedded_graphics::coord::Coord;
|
use embedded_graphics::coord::Coord;
|
||||||
use embedded_graphics::fonts::{Font6x8};
|
use embedded_graphics::fonts::{Font6x8};
|
||||||
|
|
@ -26,6 +24,7 @@ use embedded_graphics::prelude::*;
|
||||||
//use embedded_graphics::primitives::{Circle, Line};
|
//use embedded_graphics::primitives::{Circle, Line};
|
||||||
use embedded_graphics::Drawing;
|
use embedded_graphics::Drawing;
|
||||||
|
|
||||||
|
// HAL (Traits)
|
||||||
extern crate embedded_hal;
|
extern crate embedded_hal;
|
||||||
use embedded_hal::prelude::*;
|
use embedded_hal::prelude::*;
|
||||||
|
|
||||||
|
|
@ -33,43 +32,7 @@ use embedded_hal::prelude::*;
|
||||||
// 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
|
||||||
|
|
||||||
|
|
||||||
// DigitalIn Hack as long as it's not in the linux_embedded_hal
|
|
||||||
// from https://github.com/rudihorn/max31865/blob/extra_examples/examples/rpi.rs
|
|
||||||
// (slightly changed now as OutputPin doesn't provide is_high and is_low anymore)
|
|
||||||
use embedded_hal::digital::{InputPin};
|
|
||||||
|
|
||||||
//TODO: Remove when linux_embedded_hal implements InputPin
|
|
||||||
struct HackInputPin<'a> {
|
|
||||||
pin: &'a Pin
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Remove when linux_embedded_hal implements InputPin
|
|
||||||
impl<'a> HackInputPin<'a> {
|
|
||||||
fn new(p : &'a Pin) -> HackInputPin {
|
|
||||||
HackInputPin {
|
|
||||||
pin: p
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Remove when linux_embedded_hal implements InputPin
|
|
||||||
// for now it defaults to is_low if an error appears
|
|
||||||
// could be handled better!
|
|
||||||
impl<'a> InputPin for HackInputPin<'a> {
|
|
||||||
fn is_low(&self) -> bool {
|
|
||||||
self.pin.get_value().unwrap_or(0) == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_high(&self) -> bool {
|
|
||||||
!self.is_low()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Test this implemenation
|
|
||||||
//BE CAREFUL: this wasn't tested yet
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
run().unwrap();
|
run().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,7 +60,6 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
while !busy.is_exported() {}
|
while !busy.is_exported() {}
|
||||||
busy.set_direction(Direction::In).expect("busy Direction");
|
busy.set_direction(Direction::In).expect("busy Direction");
|
||||||
//busy.set_value(1).expect("busy Value set to 1");
|
//busy.set_value(1).expect("busy Value set to 1");
|
||||||
let busy_in = HackInputPin::new(&busy);
|
|
||||||
|
|
||||||
// Configure Data/Command OutputPin
|
// Configure Data/Command OutputPin
|
||||||
let dc = Pin::new(6); //pin 31 //bcm6
|
let dc = Pin::new(6); //pin 31 //bcm6
|
||||||
|
|
@ -119,7 +81,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
// Setup of the needed pins is finished here
|
// Setup of the needed pins is finished here
|
||||||
// Now the "real" usage of the eink-waveshare-rs crate begins
|
// Now the "real" usage of the eink-waveshare-rs crate begins
|
||||||
let mut epd = EPD1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
|
let mut epd = EPD1in54::new(&mut spi, cs_pin, busy, dc, rst, &mut delay)?;
|
||||||
|
|
||||||
// Clear the full screen
|
// Clear the full screen
|
||||||
epd.clear_frame(&mut spi).expect("clear frame 1");
|
epd.clear_frame(&mut spi).expect("clear frame 1");
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ authors = ["Christoph Groß <christoph-gross@mailbox.org>"]
|
||||||
|
|
||||||
eink_waveshare_rs = { path = "../../", default-features = false, features = ["epd2in9", "graphics"]}
|
eink_waveshare_rs = { path = "../../", default-features = false, features = ["epd2in9", "graphics"]}
|
||||||
|
|
||||||
linux-embedded-hal = "0.2.0"
|
linux-embedded-hal = "0.2.1"
|
||||||
|
|
||||||
embedded-graphics = "0.4.3"
|
embedded-graphics = "0.4.3"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
// the library for the embedded linux device
|
// the library for the embedded linux device
|
||||||
extern crate linux_embedded_hal as lin_hal;
|
extern crate linux_embedded_hal as lin_hal;
|
||||||
|
use lin_hal::spidev::{self, SpidevOptions};
|
||||||
|
use lin_hal::{Pin, Spidev};
|
||||||
|
use lin_hal::sysfs_gpio::Direction;
|
||||||
|
use lin_hal::Delay;
|
||||||
|
|
||||||
// the eink library
|
// the eink library
|
||||||
extern crate eink_waveshare_rs;
|
extern crate eink_waveshare_rs;
|
||||||
|
|
||||||
|
|
||||||
use eink_waveshare_rs::{
|
use eink_waveshare_rs::{
|
||||||
epd2in9::{
|
epd2in9::{
|
||||||
EPD2in9,
|
EPD2in9,
|
||||||
|
|
@ -14,11 +16,7 @@ use eink_waveshare_rs::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use lin_hal::spidev::{self, SpidevOptions};
|
// Graphics
|
||||||
use lin_hal::{Pin, Spidev};
|
|
||||||
use lin_hal::sysfs_gpio::Direction;
|
|
||||||
use lin_hal::Delay;
|
|
||||||
|
|
||||||
extern crate embedded_graphics;
|
extern crate embedded_graphics;
|
||||||
use embedded_graphics::coord::Coord;
|
use embedded_graphics::coord::Coord;
|
||||||
use embedded_graphics::fonts::{Font6x8};
|
use embedded_graphics::fonts::{Font6x8};
|
||||||
|
|
@ -26,6 +24,7 @@ use embedded_graphics::prelude::*;
|
||||||
//use embedded_graphics::primitives::{Circle, Line};
|
//use embedded_graphics::primitives::{Circle, Line};
|
||||||
use embedded_graphics::Drawing;
|
use embedded_graphics::Drawing;
|
||||||
|
|
||||||
|
// HAL (Traits)
|
||||||
extern crate embedded_hal;
|
extern crate embedded_hal;
|
||||||
use embedded_hal::prelude::*;
|
use embedded_hal::prelude::*;
|
||||||
|
|
||||||
|
|
@ -33,43 +32,8 @@ use embedded_hal::prelude::*;
|
||||||
// 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
|
||||||
|
|
||||||
|
//TODO: Test this implemenation with a new display
|
||||||
// DigitalIn Hack as long as it's not in the linux_embedded_hal
|
|
||||||
// from https://github.com/rudihorn/max31865/blob/extra_examples/examples/rpi.rs
|
|
||||||
// (slightly changed now as OutputPin doesn't provide is_high and is_low anymore)
|
|
||||||
use embedded_hal::digital::{InputPin};
|
|
||||||
|
|
||||||
//TODO: Remove when linux_embedded_hal implements InputPin
|
|
||||||
struct HackInputPin<'a> {
|
|
||||||
pin: &'a Pin
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Remove when linux_embedded_hal implements InputPin
|
|
||||||
impl<'a> HackInputPin<'a> {
|
|
||||||
fn new(p : &'a Pin) -> HackInputPin {
|
|
||||||
HackInputPin {
|
|
||||||
pin: p
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Remove when linux_embedded_hal implements InputPin
|
|
||||||
// for now it defaults to is_low if an error appears
|
|
||||||
// could be handled better!
|
|
||||||
impl<'a> InputPin for HackInputPin<'a> {
|
|
||||||
fn is_low(&self) -> bool {
|
|
||||||
self.pin.get_value().unwrap_or(0) == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_high(&self) -> bool {
|
|
||||||
!self.is_low()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Test this implemenation
|
|
||||||
//BE CAREFUL: this wasn't tested yet
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
run().unwrap();
|
run().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,7 +61,6 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
while !busy.is_exported() {}
|
while !busy.is_exported() {}
|
||||||
busy.set_direction(Direction::In).expect("busy Direction");
|
busy.set_direction(Direction::In).expect("busy Direction");
|
||||||
//busy.set_value(1).expect("busy Value set to 1");
|
//busy.set_value(1).expect("busy Value set to 1");
|
||||||
let busy_in = HackInputPin::new(&busy);
|
|
||||||
|
|
||||||
// Configure Data/Command OutputPin
|
// Configure Data/Command OutputPin
|
||||||
let dc = Pin::new(6); //pin 31 //bcm6
|
let dc = Pin::new(6); //pin 31 //bcm6
|
||||||
|
|
@ -119,7 +82,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
// Setup of the needed pins is finished here
|
// Setup of the needed pins is finished here
|
||||||
// Now the "real" usage of the eink-waveshare-rs crate begins
|
// Now the "real" usage of the eink-waveshare-rs crate begins
|
||||||
let mut epd = EPD2in9::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
|
let mut epd = EPD2in9::new(&mut spi, cs_pin, busy, dc, rst, &mut delay)?;
|
||||||
|
|
||||||
// Clear the full screen
|
// Clear the full screen
|
||||||
epd.clear_frame(&mut spi).expect("clear frame 1");
|
epd.clear_frame(&mut spi).expect("clear frame 1");
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,8 @@ authors = ["Christoph Groß <christoph-gross@mailbox.org>"]
|
||||||
#eink_waveshare_rs = { path = "../../"}
|
#eink_waveshare_rs = { path = "../../"}
|
||||||
eink_waveshare_rs = { path = "../../", default-features = false, features = ["epd4in2", "graphics"]}
|
eink_waveshare_rs = { path = "../../", default-features = false, features = ["epd4in2", "graphics"]}
|
||||||
|
|
||||||
linux-embedded-hal = "0.2.0"
|
linux-embedded-hal = "0.2.1"
|
||||||
|
|
||||||
embedded-graphics = "0.4.3"
|
embedded-graphics = "0.4.3"
|
||||||
# embedded-graphics = {git = "https://github.com/caemor/embedded-graphics", branch = "master"}
|
|
||||||
# embedded-graphics = {git = "https://github.com/jamwaffles/embedded-graphics", branch = "master"}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
embedded-hal = { version = "0.2.1", features = ["unproven"] }
|
embedded-hal = { version = "0.2.1", features = ["unproven"] }
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
// the library for the embedded linux device
|
// the library for the embedded linux device
|
||||||
extern crate linux_embedded_hal as lin_hal;
|
extern crate linux_embedded_hal as lin_hal;
|
||||||
|
use lin_hal::spidev::{self, SpidevOptions};
|
||||||
|
use lin_hal::{Pin, Spidev};
|
||||||
|
use lin_hal::sysfs_gpio::Direction;
|
||||||
|
use lin_hal::Delay;
|
||||||
|
|
||||||
// the eink library
|
// the eink library
|
||||||
extern crate eink_waveshare_rs;
|
extern crate eink_waveshare_rs;
|
||||||
|
|
||||||
|
|
||||||
use eink_waveshare_rs::{
|
use eink_waveshare_rs::{
|
||||||
epd4in2::{
|
epd4in2::{
|
||||||
EPD4in2,
|
EPD4in2,
|
||||||
|
|
@ -14,6 +16,7 @@ use eink_waveshare_rs::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Graphics
|
||||||
extern crate embedded_graphics;
|
extern crate embedded_graphics;
|
||||||
use embedded_graphics::coord::Coord;
|
use embedded_graphics::coord::Coord;
|
||||||
use embedded_graphics::fonts::{Font6x8, Font12x16};
|
use embedded_graphics::fonts::{Font6x8, Font12x16};
|
||||||
|
|
@ -21,54 +24,18 @@ use embedded_graphics::prelude::*;
|
||||||
use embedded_graphics::primitives::{Circle, Line};
|
use embedded_graphics::primitives::{Circle, Line};
|
||||||
use embedded_graphics::Drawing;
|
use embedded_graphics::Drawing;
|
||||||
|
|
||||||
use lin_hal::spidev::{self, SpidevOptions};
|
// HAL (Traits)
|
||||||
use lin_hal::{Pin, Spidev};
|
extern crate embedded_hal;
|
||||||
use lin_hal::sysfs_gpio::Direction;
|
use embedded_hal::prelude::*;
|
||||||
use lin_hal::Delay;
|
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
|
|
||||||
// DigitalIn Hack as long as it's not in the linux_embedded_hal
|
|
||||||
// from https://github.com/rudihorn/max31865/blob/extra_examples/examples/rpi.rs
|
|
||||||
// (slightly changed now as OutputPin doesn't provide is_high and is_low anymore)
|
|
||||||
extern crate embedded_hal;
|
|
||||||
use embedded_hal::{
|
|
||||||
digital::{InputPin},
|
|
||||||
};
|
|
||||||
use embedded_hal::prelude::*;
|
|
||||||
|
|
||||||
struct HackInputPin<'a> {
|
|
||||||
pin: &'a Pin
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> HackInputPin<'a> {
|
|
||||||
fn new(p : &'a Pin) -> HackInputPin {
|
|
||||||
HackInputPin {
|
|
||||||
pin: p
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> InputPin for HackInputPin<'a> {
|
|
||||||
fn is_low(&self) -> bool {
|
|
||||||
self.pin.get_value().unwrap_or(0) == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_high(&self) -> bool {
|
|
||||||
self.pin.get_value().unwrap_or(0) == 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
run().map_err(|e| println!("{}", e.to_string())).unwrap();
|
run().map_err(|e| println!("{}", e.to_string())).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn run() -> Result<(), std::io::Error> {
|
fn run() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
// Configure SPI
|
// Configure SPI
|
||||||
|
|
@ -93,7 +60,6 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
while !busy.is_exported() {}
|
while !busy.is_exported() {}
|
||||||
busy.set_direction(Direction::In).expect("busy Direction");
|
busy.set_direction(Direction::In).expect("busy Direction");
|
||||||
//busy.set_value(1).expect("busy Value set to 1");
|
//busy.set_value(1).expect("busy Value set to 1");
|
||||||
let busy_in = HackInputPin::new(&busy);
|
|
||||||
|
|
||||||
let dc = Pin::new(6); //pin 31 //bcm6
|
let dc = Pin::new(6); //pin 31 //bcm6
|
||||||
dc.export().expect("dc export");
|
dc.export().expect("dc export");
|
||||||
|
|
@ -115,7 +81,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
//TODO: wait for Digital::InputPin
|
//TODO: wait for Digital::InputPin
|
||||||
//fixed currently with the HackInputPin, see further above
|
//fixed currently with the HackInputPin, see further above
|
||||||
let mut epd4in2 = EPD4in2::new(&mut spi, cs, busy_in, dc, rst, &mut delay).expect("eink initalize error");
|
let mut epd4in2 = EPD4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error");
|
||||||
|
|
||||||
println!("Test all the rotations");
|
println!("Test all the rotations");
|
||||||
let mut buffer = Buffer4in2::default();
|
let mut buffer = Buffer4in2::default();
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ pub enum Color {
|
||||||
|
|
||||||
impl Color {
|
impl Color {
|
||||||
/// Get the color encoding of the color for one bit
|
/// Get the color encoding of the color for one bit
|
||||||
pub fn get_bit_value(&self) -> u8 {
|
pub fn get_bit_value(self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
Color::White => 1u8,
|
Color::White => 1u8,
|
||||||
Color::Black => 0u8,
|
Color::Black => 0u8,
|
||||||
|
|
@ -22,7 +22,7 @@ impl Color {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a full byte of black or white pixels
|
/// Gets a full byte of black or white pixels
|
||||||
pub fn get_byte_value(&self) -> u8 {
|
pub fn get_byte_value(self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
Color::White => 0xff,
|
Color::White => 0xff,
|
||||||
Color::Black => 0x00,
|
Color::Black => 0x00,
|
||||||
|
|
@ -41,7 +41,7 @@ impl Color {
|
||||||
/// Returns the inverse of the given color.
|
/// Returns the inverse of the given color.
|
||||||
///
|
///
|
||||||
/// Black returns White and White returns Black
|
/// Black returns White and White returns Black
|
||||||
pub fn inverse(&self) -> Color {
|
pub fn inverse(self) -> Color {
|
||||||
match self {
|
match self {
|
||||||
Color::White => Color::Black,
|
Color::White => Color::Black,
|
||||||
Color::Black => Color::White,
|
Color::Black => Color::White,
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ pub const WIDTH: u32 = 400;
|
||||||
pub const HEIGHT: u32 = 300;
|
pub const HEIGHT: u32 = 300;
|
||||||
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
|
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
|
||||||
|
|
||||||
|
|
||||||
pub(crate) const LUT_VCOM0: [u8; 44] = [
|
pub(crate) const LUT_VCOM0: [u8; 44] = [
|
||||||
0x00, 0x17, 0x00, 0x00, 0x00, 0x02,
|
0x00, 0x17, 0x00, 0x00, 0x00, 0x02,
|
||||||
0x00, 0x17, 0x17, 0x00, 0x00, 0x02,
|
0x00, 0x17, 0x17, 0x00, 0x00, 0x02,
|
||||||
|
|
@ -14,6 +15,7 @@ pub(crate) const LUT_VCOM0: [u8; 44] = [
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[cfg(feature = "epd4in2_fast_update")]
|
#[cfg(feature = "epd4in2_fast_update")]
|
||||||
pub(crate) const LUT_VCOM0_QUICK: [u8; 44] = [
|
pub(crate) const LUT_VCOM0_QUICK: [u8; 44] = [
|
||||||
0x00, 0x0E, 0x00, 0x00, 0x00, 0x01,
|
0x00, 0x0E, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
|
@ -36,6 +38,7 @@ pub(crate) const LUT_WW: [u8; 42] =[
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[cfg(feature = "epd4in2_fast_update")]
|
#[cfg(feature = "epd4in2_fast_update")]
|
||||||
pub(crate) const LUT_WW_QUICK: [u8; 42] =[
|
pub(crate) const LUT_WW_QUICK: [u8; 42] =[
|
||||||
0xA0, 0x0E, 0x00, 0x00, 0x00, 0x01,
|
0xA0, 0x0E, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
|
@ -58,6 +61,7 @@ pub(crate) const LUT_BW: [u8; 42] =[
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[cfg(feature = "epd4in2_fast_update")]
|
#[cfg(feature = "epd4in2_fast_update")]
|
||||||
pub(crate) const LUT_BW_QUICK: [u8; 42] =[
|
pub(crate) const LUT_BW_QUICK: [u8; 42] =[
|
||||||
0xA0, 0x0E, 0x00, 0x00, 0x00, 0x01,
|
0xA0, 0x0E, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
|
@ -80,6 +84,7 @@ pub(crate) const LUT_BB: [u8; 42] =[
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[cfg(feature = "epd4in2_fast_update")]
|
#[cfg(feature = "epd4in2_fast_update")]
|
||||||
pub(crate) const LUT_BB_QUICK: [u8; 42] =[
|
pub(crate) const LUT_BB_QUICK: [u8; 42] =[
|
||||||
0x50, 0x0E, 0x00, 0x00, 0x00, 0x01,
|
0x50, 0x0E, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
|
@ -102,6 +107,7 @@ pub(crate) const LUT_WB: [u8; 42] =[
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[cfg(feature = "epd4in2_fast_update")]
|
#[cfg(feature = "epd4in2_fast_update")]
|
||||||
pub(crate) const LUT_WB_QUICK: [u8; 42] =[
|
pub(crate) const LUT_WB_QUICK: [u8; 42] =[
|
||||||
0x50, 0x0E, 0x00, 0x00, 0x00, 0x01,
|
0x50, 0x0E, 0x00, 0x00, 0x00, 0x01,
|
||||||
|
|
|
||||||
|
|
@ -323,18 +323,18 @@ where
|
||||||
self.send_data(spi, &[h as u8])
|
self.send_data(spi, &[h as u8])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fill the look-up table for the EPD
|
/// Fill the look-up table for the EPD for a full refresh (slower)
|
||||||
//TODO: make public?
|
pub fn set_lut(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
fn set_lut(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
|
||||||
self.set_lut_helper(spi, &LUT_VCOM0, &LUT_WW, &LUT_BW, &LUT_WB, &LUT_BB)
|
self.set_lut_helper(spi, &LUT_VCOM0, &LUT_WW, &LUT_BW, &LUT_WB, &LUT_BB)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fill the look-up table for a quick display (partial refresh)
|
/// Fill the look-up table for a quick refresh (partial refresh)
|
||||||
///
|
///
|
||||||
/// Is automatically done by [EPD4in2::display_frame_quick()](EPD4in2::display_frame_quick())
|
/// WARNING: Might lead to ghosting-effects
|
||||||
/// //TODO: make public?
|
#[allow(dead_code)]
|
||||||
|
#[deprecated(note = "Might lead to ghosting-effects/problems with your display. Use set_lut instead!")]
|
||||||
#[cfg(feature = "epd4in2_fast_update")]
|
#[cfg(feature = "epd4in2_fast_update")]
|
||||||
fn set_lut_quick(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
pub fn set_lut_quick(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
self.set_lut_helper(
|
self.set_lut_helper(
|
||||||
spi,
|
spi,
|
||||||
&LUT_VCOM0_QUICK,
|
&LUT_VCOM0_QUICK,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue