diff --git a/Cargo.toml b/Cargo.toml index c483225..1f7f95f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/japaric/linux-embedded-hal" version = "0.2.0" [dependencies] -embedded-hal = "0.2.0" +embedded-hal = { version = "0.2.0", features = ["unproven"] } i2cdev = "0.3.1" spidev = "0.3.0" sysfs_gpio = "0.5.1" diff --git a/src/lib.rs b/src/lib.rs index 7ff21f3..0c8782e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,6 +119,20 @@ impl hal::digital::OutputPin for Pin { } } +impl hal::digital::InputPin for Pin { + fn is_high(&self) -> bool{ + if !self.0.get_active_low().unwrap() { + self.0.get_value().unwrap() != 0 + } else { + self.0.get_value().unwrap() == 0 + } + } + + fn is_low(&self) -> bool{ + !self.is_high() + } +} + impl ops::Deref for Pin { type Target = sysfs_gpio::Pin;