DigitalOutput

Struct DigitalOutput 

Source
pub struct DigitalOutput { /* private fields */ }
Expand description

Represents a digital actuator of unspecified type: an Output Device that write digital values from an OUTPUT compatible pin. https://docs.arduino.cc/language-reference/en/functions/digital-io/digitalwrite/

Implementations§

Source§

impl DigitalOutput

Source

pub fn new<T: Into<PinIdOrName>>( board: &dyn Hardware, pin: T, default: bool, ) -> Result<Self, Error>

Creates an instance of a DigitalOutput attached to a given board.

§Errors
  • HardwareError::UnknownPin: this function will bail an error if the pin does not exist for this board.
  • HardwareError::IncompatiblePin: this function will bail an error if the pin does not support OUTPUT mode.
Source

pub fn turn_on(&mut self) -> Result<&Self, Error>

Turn the output HIGH.

Source

pub fn turn_off(&mut self) -> Result<&Self, Error>

Turn the output LOW.

Source

pub fn toggle(&mut self) -> Result<&Self, Error>

Toggle the current state, if on then turn off, if off then turn on.

Source

pub fn get_pin(&self) -> u8

Returns the pin (id) used by the device.

Source

pub fn get_pin_info(&self) -> Result<Pin, Error>

Returns Pin information.

Source

pub fn is_high(&self) -> bool

Indicates if the device state is HIGH.

Source

pub fn is_low(&self) -> bool

Indicates if the device state is LOW.

Trait Implementations§

Source§

impl Clone for DigitalOutput

Source§

fn clone(&self) -> DigitalOutput

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DigitalOutput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for DigitalOutput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Output for DigitalOutput

Source§

fn set_state(&mut self, state: State) -> Result<State, Error>

Internal only: you should rather use Self::turn_on(), Self::turn_off() functions.

Source§

fn get_state(&self) -> State

Returns the actuator current state.
Source§

fn get_default(&self) -> State

Returns the actuator default (or neutral) state.
Source§

fn animate<S: Into<State>>( &mut self, state: S, duration: u64, transition: Easing, )

Animates the output of the device. In other word: the state of the device will be animated from current step to targeted step through an interpolation of in-between states. The function will last for the required duration and the interpolation will follow an easing transition function. Read more
Source§

fn is_busy(&self) -> bool

Indicates the busy status, ie if the device is running an animation.
Source§

fn stop(&mut self)

Stops the current animation, if any.
Source§

fn reset(&mut self) -> Result<State, Error>

Resets the actuator to default (or neutral) state.
Source§

fn scale_state( &mut self, previous: State, target: State, progress: f32, ) -> State

Internal only.
Source§

impl Device for DigitalOutput

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.