pub struct Led { /* private fields */ }
Expand description
Simple abstraction around the user LED at the top right of the board connected to the D7/P1.12 pin.
Implementations§
Source§impl Led
impl Led
Sourcepub fn new(pin: P1_12<Disconnected>) -> Self
pub fn new(pin: P1_12<Disconnected>) -> Self
Initialize the LED, LED remains off.
Examples found in repository?
examples/blink.rs (line 22)
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 on(&mut self)
pub fn on(&mut self)
Turn the LED on.
Examples found in repository?
examples/blink.rs (line 27)
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 off(&mut self)
pub fn off(&mut self)
Turn the LED off.
Examples found in repository?
examples/blink.rs (line 29)
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 Led
impl RefUnwindSafe for Led
impl Send for Led
impl Sync for Led
impl Unpin for Led
impl UnwindSafe for Led
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.