[][src]Struct rmicrobit::buttons::monitors::dual_with_hold::Monitor

pub struct Monitor<A: PollButton, B: PollButton, H: HoldDescriptor> { /* fields omitted */ }

Wrapper for two PollButtons generating click and hold events.

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.

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 PollButtons 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

impl<A, B, H> Send for Monitor<A, B, H> where
    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

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self