Browse Source

Update to linux-embedded-hal v0.2.1 and remove hackinputpin

embedded-hal-1.0
Chris 7 years ago
parent
commit
40506b580c
  1. 2
      examples/embedded_linux_epd1in54/Cargo.toml
  2. 34
      examples/embedded_linux_epd1in54/src/main.rs
  3. 2
      examples/embedded_linux_epd2in9/Cargo.toml
  4. 28
      examples/embedded_linux_epd2in9/src/main.rs
  5. 2
      examples/embedded_linux_epd4in2/Cargo.toml
  6. 34
      examples/embedded_linux_epd4in2/src/main.rs

2
examples/embedded_linux_epd1in54/Cargo.toml

@ -9,7 +9,7 @@ authors = ["Christoph Groß <christoph-gross@mailbox.org>"]
#eink_waveshare_rs = { path = "../../"}
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"

34
examples/embedded_linux_epd1in54/src/main.rs

@ -34,40 +34,6 @@ use embedded_hal::prelude::*;
// 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() {
run().unwrap();

2
examples/embedded_linux_epd2in9/Cargo.toml

@ -7,7 +7,7 @@ authors = ["Christoph Groß <christoph-gross@mailbox.org>"]
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"

28
examples/embedded_linux_epd2in9/src/main.rs

@ -39,35 +39,9 @@ use embedded_hal::prelude::*;
// (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
//TODO: Test this implemenation with a new display
fn main() {
run().unwrap();

2
examples/embedded_linux_epd4in2/Cargo.toml

@ -9,7 +9,7 @@ authors = ["Christoph Groß <christoph-gross@mailbox.org>"]
#eink_waveshare_rs = { path = "../../"}
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 = {git = "https://github.com/caemor/embedded-graphics", branch = "master"}

34
examples/embedded_linux_epd4in2/src/main.rs

@ -30,40 +30,6 @@ use lin_hal::Delay;
// 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
// 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() {
run().map_err(|e| println!("{}", e.to_string())).unwrap();
}

Loading…
Cancel
Save