Struct avr_oxide::devices::wallclock::WallClock

source ·
pub struct WallClock<'wc, T, S>
where T: 'static + TimerControl + RtcTimerCalibration, S: EventSink,
{ /* private fields */ }

Implementations§

source§

impl<T, S> WallClock<'_, T, S>
where T: 'static + TimerControl + RtcTimerCalibration, S: EventSink,

source

pub fn using<OT: Into<OwnOrBorrowMut<'static, T>>>(timer: OT) -> Self

Create an instance that will use the given RTC timer device for timing.

source

pub fn static_using<OT: Into<OwnOrBorrowMut<'static, T>>>( timer: OT ) -> &'static mut Self

Return a static reference to an instance that will use the given RTC device for timing.

source

pub fn with_timer(timer: &'static mut T) -> Self

source

pub fn static_with_timer(timer: &'static mut T) -> &'static mut Self

source

pub fn runtime(&self) -> Duration

Return the total duration for which the clock has been running

source

pub fn runtime_overflowed(&self) -> bool

Return true iff the runtime counter has overflowed

source

pub fn clear_runtime_overflow(&mut self)

Clear the flag indicating that the runtime counter overflowed (until the next time…)

source

pub fn wait(&self, delay: Duration)

Block the calling thread for (at least) the given duration.

§Important

Note that the clock must be running - i.e. the supervisor.listen_handle() method was called already - before you use the wait() method, or you can expect to block forever, , and that this method depends on the main supervisor to be running. In other words, this must be used in threads you have spawn()ed, not the main thread.

Trait Implementations§

source§

impl<'wc, T, S> DelayEvents<'wc> for WallClock<'wc, T, S>
where T: 'static + TimerControl + RtcTimerCalibration, S: EventSink,

§

type DelayHandle = DelayQueueHandle

source§

fn after_delay( &self, delay: Duration, bf: Box<dyn DelayCallback + 'wc> ) -> Self::DelayHandle

Call the given callback after /at least/ delay time has passed.
source§

fn cancel_delay(&self, handle: Self::DelayHandle) -> bool

Cancel a given delay event, if possible. Returns true if the event was cancelled, or false if not (because it either never existed, or it has already been executed.)
source§

impl<T, S> EventSource for WallClock<'_, T, S>
where T: 'static + TimerControl + RtcTimerCalibration, S: EventSink,

source§

fn process_event(&self, evt: OxideEvent)

Process the clock events (in userland). This means calling any explicit on-event handlers, but we also do the processing of any delay queue events entirely in userland.

source§

fn listen(&'static self)

source§

impl<'wc, T, S> TickEvents<'wc> for WallClock<'wc, T, S>
where T: 'static + TimerControl + RtcTimerCalibration, S: EventSink,

source§

fn on_tick(&self, bf: Box<dyn TickCallback + 'wc>)

Call the given closure every time the clock ticks.
source§

impl<T, S> Send for WallClock<'_, T, S>
where T: 'static + TimerControl + RtcTimerCalibration, S: EventSink,

source§

impl<T, S> Sync for WallClock<'_, T, S>
where T: 'static + TimerControl + RtcTimerCalibration, S: EventSink,

Auto Trait Implementations§

§

impl<'wc, T, S> !Freeze for WallClock<'wc, T, S>

§

impl<'wc, T, S> !RefUnwindSafe for WallClock<'wc, T, S>

§

impl<'wc, T, S> Unpin for WallClock<'wc, T, S>
where S: Unpin,

§

impl<'wc, T, S> !UnwindSafe for WallClock<'wc, T, S>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.