[−][src]Trait switch_hal::IntoSwitch
Convenience functions for converting InputPin and OutputPin to a Switch.
The type of Switch returned,
InputSwitch or OutputSwitch is
determined by whether the IoPin being consumed is an InputPin
or OutputPin.
Required methods
fn into_switch<ActiveLevel>(self) -> Switch<Self, ActiveLevel> where
Self: Sized,
Self: Sized,
Consumes the IoPin returning a Switch of the appropriate ActiveLevel.
This method exists so other, more convenient functions, can have blanket implementations.
Prefer into_active_low_switch and into_active_high_switch.
Examples
Active High
use switch_hal::{ActiveHigh, OutputSwitch, IntoSwitch}; let led = pin.into_switch::<ActiveHigh>();
Active Low
use switch_hal::{ActiveLow, InputSwitch, IntoSwitch}; let button = pin.into_switch::<ActiveLow>();
Provided methods
fn into_active_low_switch(self) -> Switch<Self, ActiveLow> where
Self: Sized,
Self: Sized,
Consumes the IoPin returning a Switch<IoPin, ActiveLow>.
Examples
use switch_hal::IntoSwitch; let led = pin.into_active_low_switch();
fn into_active_high_switch(self) -> Switch<Self, ActiveHigh> where
Self: Sized,
Self: Sized,
Consumes the IoPin returning a Switch<IoPin, ActiveHigh>.
Examples
use switch_hal::IntoSwitch; let button = pin.into_active_high_switch();