pub struct Monitor<A: PollButton, B: PollButton> { /* private fields */ }Expand description
Wrapper for two PollButtons generating click events on release.
The buttons don’t have to be the micro:bit’s built-in buttons, though the
generated Events include ‘A’ and ‘B’ in their names.
Implementations§
Source§impl<A: PollButton, B: PollButton> Monitor<A, B>
impl<A: PollButton, B: PollButton> Monitor<A, B>
Sourcepub fn new(button_a: A, button_b: B) -> Monitor<A, B>
pub fn new(button_a: A, button_b: B) -> Monitor<A, B>
Takes ownership of two PollButtons and returns a Monitor.
Sourcepub fn free(self) -> (A, B)
pub fn free(self) -> (A, B)
Gives the underlying PollButton instances back.
Sourcepub fn poll(&mut self) -> Option<Event>
pub fn poll(&mut self) -> Option<Event>
Polls both buttons and filters for events.
If both buttons have been pressed, returns Some(ClickAB) when the
second one is released.
Otherwise, returns Some(ClickA) if the first button was released or
Some(ClickB) if the second button was released.
Otherwise returns None.
Auto Trait Implementations§
impl<A, B> Freeze for Monitor<A, B>
impl<A, B> RefUnwindSafe for Monitor<A, B>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for Monitor<A, B>
impl<A, B> Sync for Monitor<A, B>
impl<A, B> Unpin for Monitor<A, B>
impl<A, B> UnsafeUnpin for Monitor<A, B>where
A: UnsafeUnpin,
B: UnsafeUnpin,
impl<A, B> UnwindSafe for Monitor<A, B>where
A: UnwindSafe,
B: UnwindSafe,
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