pub trait IntoSwitch {
    // Required method
    fn into_switch<ActiveLevel>(self) -> Switch<Self, ActiveLevel>
       where Self: Sized;

    // Provided methods
    fn into_active_low_switch(self) -> Switch<Self, ActiveLow>
       where Self: Sized { ... }
    fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>
       where Self: Sized { ... }
Expand description

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,

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.

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,

Consumes the IoPin returning a Switch<IoPin, ActiveLow>.

use switch_hal::IntoSwitch;
let led = pin.into_active_low_switch();

fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>where Self: Sized,

Consumes the IoPin returning a Switch<IoPin, ActiveHigh>.

use switch_hal::IntoSwitch;
let button = pin.into_active_high_switch();



impl<T> IntoSwitch for T