Frame loop and time#

Declared in ui.h. See the frame loop for how these fit together.

ui_init#

void ui_init(void);

Starts CEUI. It clears CEUI’s state, starts graphx in 8 bits per pixel mode with the back buffer in the second half of video memory, loads the theme’s palette (ui_palette_default) into the UI’s slots, sets up the fonts, switches the keypad to continuous scanning and starts hardware timer 1 for ui_ms. The first ui_frame after it runs at once and draws the whole screen.

Call it once, before the frame loop.

ui_frame#

bool ui_frame(void);

Ends the frame before it, waits for something to happen, and starts the next frame.

Ending a frame closes open containers, runs focus navigation, compares the recorded commands with the frame before and draws the changed parts of the screen. Waiting ends with a key event, the time set by ui_wake, or an expiring toast. A settle frame runs without waiting.

Returns true to run another frame, or false once ui_quit was called.

ui_quit#

void ui_quit(void);

Asks the loop to end. The current frame is finished and drawn, and the next ui_frame returns false.

ui_exit#

void ui_exit(void);

Stops CEUI: waits until every key is released, so the last key does not reach the OS, restores the keypad mode that was set before ui_init, stops timer 1 and ends graphx. Call it once after the loop.

ui_invalidate#

void ui_invalidate(void);

Makes the next frame redraw the whole screen instead of only what changed. Call it after drawing to the screen outside CEUI.

ui_wake#

void ui_wake(unsigned ms);

Asks for a frame ms milliseconds from now, even when no key is pressed. ui_wake(0) asks for the next frame at once. When it is called more than once in a frame, the earliest time wins. The request is for one frame only; call it again in that frame to keep animating.

Parameter

Meaning

ms

Milliseconds from now

ui_ms#

unsigned long ui_ms(void);

Returns the milliseconds since ui_init, read from hardware timer 1 at 32768 Hz. The timer wraps around after about 36 hours. Use it to time animations and work between frames.