Skip to content

Commit

Permalink
Include pin active low logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankurte committed Oct 10, 2018
1 parent 61a2ef0 commit 4513004
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,15 @@ impl hal::digital::OutputPin for Pin {

impl hal::digital::InputPin for Pin {
fn is_high(&self) -> bool{
self.0.get_value().unwrap() != 0
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.0.get_value().unwrap() == 0
!self.is_high()
}
}

Expand Down

0 comments on commit 4513004

Please sign in to comment.