Skip to content

Commit 9cd6937

Browse files
bors[bot]ryankurte
andcommitted
Merge #11
11: Added input pin impl (requires unproven hal trait) r=therealprof a=ryankurte Do we have opinions on the use of `unproven` traits in this library? Co-authored-by: Ryan Kurte <[email protected]>
2 parents 4d039af + 4513004 commit 9cd6937

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ impl hal::digital::OutputPin for Pin {
119119
}
120120
}
121121

122+
impl hal::digital::InputPin for Pin {
123+
fn is_high(&self) -> bool{
124+
if !self.0.get_active_low().unwrap() {
125+
self.0.get_value().unwrap() != 0
126+
} else {
127+
self.0.get_value().unwrap() == 0
128+
}
129+
}
130+
131+
fn is_low(&self) -> bool{
132+
!self.is_high()
133+
}
134+
}
135+
122136
impl ops::Deref for Pin {
123137
type Target = sysfs_gpio::Pin;
124138

0 commit comments

Comments
 (0)