Bedtime. /Application Control

Application Control

Application lifecycle management

These functions control the application lifecycle and provide access to the application's data model.

Lifecycle

1. Firmware allocates memory for model (model_size bytes) 2. init() callback is called if provided 3. App runs with tick() and redraw() callbacks 4. deinit() callback is called before exit 5. Firmware frees model memory

void os_app_exit(void)

Exit the current app and return to launcher

void* os_app_get_model(const os_app_t* app)

Get app's model data

const os_app_t*appApp context

Returns — Pointer to model, or NULL if not allocated

my_model_t* m = (my_model_t*)os_app_get_model(app);
m->counter++;
uint32_t os_tick_get(void)

Milliseconds since boot

uint32_t now = os_tick_get();
if (now - m->last_step >= 120) { m->last_step = now; step(m); }