pub struct Contact<P> { /* private fields */ }Expand description
An on/off part on an input line: a button, a float switch, a motion detector.
§Examples
use pamoja_core::Sensor;
use pamoja_gpio::pin::Polarity;
use pamoja_gpio::switch::Contact;
use pamoja_hal::digital::PinState;
use pamoja_hal::script::{block_on, PinScript};
// A float switch pulled up, which closes to ground when the tank is full.
let line = PinScript::new([PinState::High, PinState::Low]);
let mut full = Contact::new(line, Polarity::ActiveLow);
assert!(!block_on(full.read())?);
assert!(block_on(full.read())?);Implementations§
Source§impl<P> Contact<P>
impl<P> Contact<P>
Sourcepub fn active_high(pin: P) -> Contact<P>
pub fn active_high(pin: P) -> Contact<P>
Sourcepub fn active_low(pin: P) -> Contact<P>
pub fn active_low(pin: P) -> Contact<P>
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for Contact<P>where
P: Freeze,
impl<P> RefUnwindSafe for Contact<P>where
P: RefUnwindSafe,
impl<P> Send for Contact<P>where
P: Send,
impl<P> Sync for Contact<P>where
P: Sync,
impl<P> Unpin for Contact<P>where
P: Unpin,
impl<P> UnsafeUnpin for Contact<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for Contact<P>where
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more