Expand description
Time-driven page cycler for small displays.
A Carousel answers one question: given the current millisecond
clock and whether an external trigger fired, should the display show
its idle screen or one of the cycle pages, and which page?
It is pure scheduling. There is no rendering, no I/O, no atomics, and
no timer ownership here. The caller owns the framebuffer, the clock
source, the trigger, and the CarouselState; this crate only maps
(now, triggered) to a Frame. That keeps the timing logic
no_std, allocation-free, and unit-testable without hardware.
use carousel::{Carousel, CarouselState, Frame};
const SCREENS: Carousel = Carousel {
page_count: 4,
page_duration_ms: 5_000,
cycle_window_ms: 60_000,
cycle_period_ms: 5 * 60_000,
};
// Offset the first auto-cycle so the idle screen shows right after boot.
let mut state = CarouselState::new(SCREENS.cycle_period_ms);
// Each render tick, feed the clock and any pending trigger:
match SCREENS.frame_at(&mut state, now_ms(), button_pressed()) {
Frame::Idle => { /* draw the idle screen */ }
Frame::Page(index) => { /* draw page `index` */ }
}Structs§
- Carousel
- Declarative cycle configuration.
- Carousel
State - Mutable carousel state, owned by the caller’s render loop.
Enums§
- Frame
- What the caller should draw this tick.