pub struct ModeButton { /* private fields */ }
Expand description
Simple abstraction around the MODE button connected to the MD/P0.11 pin.
Implementations§
Source§impl ModeButton
impl ModeButton
Sourcepub fn new(pin: P0_11<Disconnected>) -> Self
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}
Sourcepub fn is_held_down(&self) -> bool
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§
impl Freeze for ModeButton
impl RefUnwindSafe for ModeButton
impl Send for ModeButton
impl Sync for ModeButton
impl Unpin for ModeButton
impl UnwindSafe for ModeButton
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.