BlinkState represents two discrete states: visible and hidden. The application only needs to query isVisible() while drawing.
1 |
|
API
start()begins blinking in the visible phase; repeated calls do not restart the timer.stop()stops immediately and switches to hidden.stopWhenVisible()waits for the next visible phase before stopping when currently hidden; when already visible, it stops immediately and remains visible.setInterval(ms)changes the toggle interval. While running, it restarts timing from the current time.isVisible()andisRunning()are read-only state queries.interval()returns the normalized effective interval.
The interval is clamped to 1..INT32_MAX milliseconds. This excludes a zero interval and keeps deadline comparison using 32-bit unsigned timestamps unambiguous across wraparound.
Scheduling and lifetime
BlinkState automatically registers with UiDeadlineScheduler during construction. PixelUI marks the UI dirty only when the deadline is reached and visibility actually changes, so no manual update() or continuous drawing is required. Tickless mode can sleep directly until the next toggle.
The object unregisters from the scheduler during destruction. Because it stores a reference to its PixelUI, a BlinkState must not outlive that PixelUI. Making it an App or Widget member is normally the most natural choice.
Use the animation system when coordinates or other values must change continuously. BlinkState only handles discrete show/hide state.
