pub struct InputPin(/* private fields */);
Expand description
Provides embedded_hal::digital
traits for a gpiocdev::Request
containing a single input pin.
Holding the InputPin
grants exclusive access to the pin.
Do NOT drop the InputPin
until you are completely done with it.
Dropping and re-requesting the line is far more expensive than getting the
value.
Implementations§
Source§impl InputPin
impl InputPin
Sourcepub fn new<P>(chip: P, offset: u32) -> Result<Self, Error>
pub fn new<P>(chip: P, offset: u32) -> Result<Self, Error>
Creates a new input pin for the given offset
on the given chip
.
use embedded_hal::digital::InputPin;
let mut pin = gpiocdev_embedded_hal::InputPin::new("/dev/gpiochip0", 4)?;
if pin.is_high()? {
println!("Input is high.");
}
Sourcepub fn into_output_pin(self, state: PinState) -> Result<OutputPin, Error>
pub fn into_output_pin(self, state: PinState) -> Result<OutputPin, Error>
Set this pin to output mode.
Sourcepub fn from_found_line(fl: FoundLine) -> Result<Self, Error>
pub fn from_found_line(fl: FoundLine) -> Result<Self, Error>
Create an InputPin
from a gpiocdev::FoundLine
.
§Examples
use embedded_hal::digital::InputPin;
let sensor0 = gpiocdev::find_named_line("SENSOR0").unwrap();
let mut pin = gpiocdev_embedded_hal::InputPin::from_found_line(sensor0)?;
if pin.is_low()? {
println!("Input is low.");
}
Trait Implementations§
Source§impl TryFrom<Request> for InputPin
impl TryFrom<Request> for InputPin
Source§fn try_from(req: Request) -> Result<Self, Self::Error>
fn try_from(req: Request) -> Result<Self, Self::Error>
Convert any single input line gpiocdev::Request
into a InputPin
.
This allows for advanced configurations such as setting bias
or using the active_low flag to flip the line polarity.
InputPin::new<P>()
should be used for less complex configurations.
Auto Trait Implementations§
impl Freeze for InputPin
impl RefUnwindSafe for InputPin
impl Send for InputPin
impl Sync for InputPin
impl Unpin for InputPin
impl UnwindSafe for InputPin
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