Skip to content

Commit 61a2ef0

Browse files
committed
Added input pin impl (requires unproven)
1 parent 4d039af commit 61a2ef0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repository = "https://github.com/japaric/linux-embedded-hal"
99
version = "0.2.0"
1010

1111
[dependencies]
12-
embedded-hal = "0.2.0"
12+
embedded-hal = { version = "0.2.0", features = ["unproven"] }
1313
i2cdev = "0.3.1"
1414
spidev = "0.3.0"
1515
sysfs_gpio = "0.5.1"

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ impl hal::digital::OutputPin for Pin {
119119
}
120120
}
121121

122+
impl hal::digital::InputPin for Pin {
123+
fn is_high(&self) -> bool{
124+
self.0.get_value().unwrap() != 0
125+
}
126+
127+
fn is_low(&self) -> bool{
128+
self.0.get_value().unwrap() == 0
129+
}
130+
}
131+
122132
impl ops::Deref for Pin {
123133
type Target = sysfs_gpio::Pin;
124134

0 commit comments

Comments
 (0)