pub struct Switch<P> { /* private fields */ }Expand description
An on/off part on an output line: a relay, a valve, a lamp.
§Examples
use pamoja_core::Actuator;
use pamoja_gpio::pin::Polarity;
use pamoja_gpio::switch::Switch;
use pamoja_hal::digital::PinState;
use pamoja_hal::script::{block_on, PinScript};
// A relay board whose inputs are pulled low to energize the coil.
let mut valve = Switch::new(PinScript::new([]), Polarity::ActiveLow);
block_on(valve.apply(true))?;
block_on(valve.apply(false))?;
assert_eq!(valve.release().driven(), [PinState::Low, PinState::High]);Implementations§
Source§impl<P> Switch<P>
impl<P> Switch<P>
Sourcepub fn active_high(pin: P) -> Switch<P>
pub fn active_high(pin: P) -> Switch<P>
Sourcepub fn active_low(pin: P) -> Switch<P>
pub fn active_low(pin: P) -> Switch<P>
Sourcepub fn is_asserted(&self) -> bool
pub fn is_asserted(&self) -> bool
Reports whether the part was last driven asserted.
§Returns
true after a successful set(true), false after set(false) or before
the line is first driven.
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for Switch<P>where
P: Freeze,
impl<P> RefUnwindSafe for Switch<P>where
P: RefUnwindSafe,
impl<P> Send for Switch<P>where
P: Send,
impl<P> Sync for Switch<P>where
P: Sync,
impl<P> Unpin for Switch<P>where
P: Unpin,
impl<P> UnsafeUnpin for Switch<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for Switch<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