[−][src]Struct rmicrobit::buttons::monitors::holding::HoldAnnotator
A hold-detection algorithm and associated state.
Methods
impl<T: HoldDescriptor> HoldAnnotator<T>
[src]
pub fn new() -> HoldAnnotator<T>
[src]
Returns a new HoldAnnotator
.
pub fn annotate(&mut self, transition: Transition) -> Option<Event>
[src]
Convert the result of a button poll to an event.
Returns events similar to those from PollButton::poll_event
, but
with Hold
as possibility as well as Press
and Release
.
If the button has been down for longer than HOLD_TICKS
, immediately
reports Hold
, and reports no event when the button is next released.
See DefaultHoldDescriptor
for the default HOLD_TICKS
.
Example
ⓘThis example is not tested
match hold_annotator.annotate(button.poll_transition()) { Some(holding::Event::Press) => ..., Some(holding::Event::Release) => ..., Some(holding::Event::Hold) => ..., None => ..., }
Trait Implementations
impl<T: Debug + HoldDescriptor> Debug for HoldAnnotator<T> where
T::width: Debug,
[src]
T::width: Debug,
Auto Trait Implementations
impl<T> Unpin for HoldAnnotator<T> where
<T as HoldDescriptor>::width: Unpin,
<T as HoldDescriptor>::width: Unpin,
impl<T> Send for HoldAnnotator<T> where
<T as HoldDescriptor>::width: Send,
<T as HoldDescriptor>::width: Send,
impl<T> Sync for HoldAnnotator<T> where
<T as HoldDescriptor>::width: Sync,
<T 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