pub struct Attention { /* private fields */ }Expand description
Display-attention state machine.
Pure logic driven by a monotonic millisecond clock: no timers, no
hardware. Every method that can change state takes now_ms so the
whole thing is testable with synthetic time.
Implementations§
Source§impl Attention
impl Attention
Sourcepub fn new(kind: DisplayKind, config: AttentionConfig, now_ms: u64) -> Self
pub fn new(kind: DisplayKind, config: AttentionConfig, now_ms: u64) -> Self
Start in DisplayState::Active — boot is itself a wake event.
pub fn kind(&self) -> DisplayKind
pub fn state(&self) -> DisplayState
pub fn config(&self) -> AttentionConfig
Sourcepub fn set_config(&mut self, config: AttentionConfig)
pub fn set_config(&mut self, config: AttentionConfig)
Replace the timing policy. The new timeout is measured from the
existing activity mark, so shortening it below the time already
elapsed lapses at the next poll rather than
retroactively.
Sourcepub fn accepts_redraw(&self) -> bool
pub fn accepts_redraw(&self) -> bool
Whether the panel can show a redraw right now.
False only for an emissive panel that has been powered off: pushing pixels at a dark panel wastes bus traffic and, on a board that samples its battery on a timer, would otherwise run forever. Persistent panels always accept a redraw — that is how their lapse is rendered.
Sourcepub fn wake(&mut self, now_ms: u64) -> Option<Transition>
pub fn wake(&mut self, now_ms: u64) -> Option<Transition>
Register user-driven activity.
Returns Transition::Woke when this actually brought the panel
back, so the caller can order its redraw and power-on correctly;
returns None when the display was already active and only the
inactivity timer moved.
Sourcepub fn set_hold(
&mut self,
reason: HoldReason,
active: bool,
now_ms: u64,
) -> Option<Transition>
pub fn set_hold( &mut self, reason: HoldReason, active: bool, now_ms: u64, ) -> Option<Transition>
Assert or release a hold.
Asserting one also counts as activity, so an event like a pairing window opening both wakes the panel and pins it. Releasing the last hold restarts the inactivity window from that moment, so the user gets a full timeout to read whatever the hold was showing.
Sourcepub fn poll(&mut self, now_ms: u64) -> Option<Transition>
pub fn poll(&mut self, now_ms: u64) -> Option<Transition>
Advance time. Returns a transition when one becomes due.
Sourcepub fn next_deadline(&self) -> Option<u64>
pub fn next_deadline(&self) -> Option<u64>
Absolute monotonic-millisecond deadline for the next
poll, if any is pending.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Attention
impl RefUnwindSafe for Attention
impl Send for Attention
impl Sync for Attention
impl Unpin for Attention
impl UnwindSafe for Attention
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)