pub struct Pin {
pub id: u8,
pub name: String,
pub mode: PinMode,
pub supported_modes: Vec<PinMode>,
pub channel: Option<u8>,
pub value: u16,
}
Expand description
Represents the current state and configuration of a pin.
Fields§
§id: u8
The pin ID, which also corresponds to the index of the IoData::pins
hashmap.
name: String
The pin name: an alternative String representation of the pin name: ‘D13’, ‘A0’, ‘GPIO13’ for instance.
mode: PinMode
Currently configured mode.
supported_modes: Vec<PinMode>
All pin supported modes.
channel: Option<u8>
For analog pin, this is the channel number ie “A0”=>0, “A1”=>1, etc…
value: u16
Pin value.
Implementations§
Source§impl Pin
impl Pin
Sourcepub fn supports_mode(&self, mode: PinModeId) -> Option<PinMode>
pub fn supports_mode(&self, mode: PinModeId) -> Option<PinMode>
Verifies if a pin supports the given mode and returns it if it does.
Sourcepub fn validate_current_mode(&self, mode: PinModeId) -> Result<(), Error>
pub fn validate_current_mode(&self, mode: PinModeId) -> Result<(), Error>
Validates that the pin is in the given mode.
Sourcepub fn get_max_possible_value(&self) -> u16
pub fn get_max_possible_value(&self) -> u16
Get the max value this pin can reach.
This is defined by the resolution of the current pin mode.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pin
impl RefUnwindSafe for Pin
impl Send for Pin
impl Sync for Pin
impl Unpin for Pin
impl UnwindSafe for Pin
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