Skip to main content

Module timer

Module timer 

Source
Expand description

Tick-driven timer registry; see timer::Timers. Tick-driven timer registry — no_std + alloc, no wall clock (LPAR-06 §5).

[Timers] is a deterministic, tick-counted callback scheduler. Periods and all durations are expressed in ticks (one dispatch of Event::Tick); no milliseconds or wall-clock instants appear in this module.

§Basic usage

use rlvgl_core::timer::{TimerRepeat, Timers};

let mut timers = Timers::new();

// Infinite repeating timer: fires every 5 ticks.
let _id = timers.add(5, TimerRepeat::Infinite, Box::new(|_ctx| {
    // ... periodic work ...
}));

// One-shot: fires once after 3 ticks, then removes itself.
let _id2 = timers.add_once(3, Box::new(|_ctx| {
    // ... one-shot work ...
}));

// Advance one tick per frame (call once per Event::Tick).
timers.tick();

§Determinism invariant (LPAR-06 §5.8)

For a fixed initial configuration and a fixed tick sequence, the fire sequence (which ids fired, in which order, at which tick count) is bit-identical across runs and hosts. No randomness or wall-clock dependency.

Structs§

TimerContext
Context passed to a timer callback on each fire.
TimerId
Opaque handle to a registered timer, returned by Timers::add and Timers::add_once. Used with pause, resume, delete, and set_ready.
Timers
Registry/scheduler for tick-driven callbacks.

Enums§

TimerRepeat
Controls how many times a timer fires before it is exhausted.