[−][src]Struct rmicrobit::buttons::monitors::dual_with_hold::Monitor
Wrapper for two PollButton
s generating click and hold events.
The buttons don't have to be the micro:bit's built-in buttons, though the
generated Event
s include 'A' and 'B' in their names.
Methods
impl<A: PollButton, B: PollButton, H: HoldDescriptor> Monitor<A, B, H>
[src]
pub fn new(button_a: A, button_b: B) -> Monitor<A, B, H>
[src]
Takes ownership of two PollButton
s and returns a Monitor
.
pub fn free(self) -> (A, B)
[src]
Gives the underlying PollButton
instances back.
pub fn poll(&mut self) -> Option<Event>
[src]
Polls both buttons and filters for events.
If one button has been down for longer than the hold threshold and the
other button hasn't been pressed, returns Some(HoldA)
or
Some(HoldB)
.
If both buttons have been held down for longer than the hold
threshold, returns Some(HoldAB)
.
Otherwise, 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
.
Once a hold event has been reported, doesn't report any further events until after both buttons have been released.
The hold threshold is determined by the monitor's HoldDescriptor
.
Auto Trait Implementations
impl<A, B, H> Unpin for Monitor<A, B, H> where
A: Unpin,
B: Unpin,
<H as HoldDescriptor>::width: Unpin,
A: Unpin,
B: Unpin,
<H as HoldDescriptor>::width: Unpin,
impl<A, B, H> Send for Monitor<A, B, H> where
A: Send,
B: Send,
<H as HoldDescriptor>::width: Send,
A: Send,
B: Send,
<H as HoldDescriptor>::width: Send,
impl<A, B, H> Sync for Monitor<A, B, H> where
A: Sync,
B: Sync,
<H as HoldDescriptor>::width: Sync,
A: Sync,
B: Sync,
<H as HoldDescriptor>::width: Sync,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self