Struct ModeButton

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

Simple abstraction around the MODE button connected to the MD/P0.11 pin.

Implementations§

Source§

impl ModeButton

Source

pub fn new(pin: P0_11<Disconnected>) -> Self

Initialize the button.

Examples found in repository?
examples/blink.rs (line 21)
16fn main() -> ! {
17    rtt_init_print!();
18    let p = hal::pac::Peripherals::take().unwrap();
19    let port0 = hal::gpio::p0::Parts::new(p.P0);
20    let port1 = hal::gpio::p1::Parts::new(p.P1);
21    let button = ModeButton::new(port0.p0_11);
22    let mut led  = Led::new(port1.p1_12);
23
24    rprintln!("Blinky button demo starting");
25    loop {
26        if button.is_held_down() {
27            led.on();
28        } else {
29            led.off();
30        }
31    }
32}
Source

pub fn is_held_down(&self) -> bool

Returns true iff button is physically held down.

Examples found in repository?
examples/blink.rs (line 26)
16fn main() -> ! {
17    rtt_init_print!();
18    let p = hal::pac::Peripherals::take().unwrap();
19    let port0 = hal::gpio::p0::Parts::new(p.P0);
20    let port1 = hal::gpio::p1::Parts::new(p.P1);
21    let button = ModeButton::new(port0.p0_11);
22    let mut led  = Led::new(port1.p1_12);
23
24    rprintln!("Blinky button demo starting");
25    loop {
26        if button.is_held_down() {
27            led.on();
28        } else {
29            led.off();
30        }
31    }
32}

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.