Skip to content

Commit

Permalink
Add StatefulOutputPin to read and toggle the state of OutputPin
Browse files Browse the repository at this point in the history
  • Loading branch information
astro committed Apr 7, 2018
1 parent 97fac76 commit 3f61ef2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/digital.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ pub trait OutputPin {
fn set_high(&mut self);
}

/// Output pin that can read its output state
#[cfg(feature = "unproven")]
trait StatefulOutputPin: OutputPin {
/// Is the pin set to high?
fn is_set_high(&self) -> bool;

/// Is the pin set to low?
fn is_set_low(&self) -> bool;

/// Toggle pin output
fn toggle(&mut self) {
if self.is_set_low() {
self.set_high();
} else {
self.set_low();
}
}
}

/// Single digital input pin
#[cfg(feature = "unproven")]
pub trait InputPin {
Expand Down

0 comments on commit 3f61ef2

Please sign in to comment.