Bedtime. /Notifications

Notifications

Toasts and modal dialogues drawn over your app

The firmware owns one notification. Every function here acts on it, so there is nothing to allocate or free — pass NULL wherever a ui_notify_t* is asked for.

Warning — A modal notification swallows input: while it is up the firmware consumes button events before your on_input() sees them and drains the encoder accumulator, so the first os_controls_encoder_get_delta() afterwards reads 0. Do not drive your UI from on_input() while a modal is showing.

void ui_notify_info(const char* header, const char* hint, const gfx_img_t* icon, uint16_t timeout_ms)

Toast: header + hint + optional icon.

const char*header
const char*hint
const gfx_img_t*icon
uint16_ttimeout_ms0 = stay until hidden
void ui_notify_error(const char* message, uint16_t timeout_ms)

Error toast

const char*message
uint16_ttimeout_ms
void ui_notify_success(const char* message, uint16_t timeout_ms)

Success toast

const char*message
uint16_ttimeout_ms
void ui_notify_warning(const char* message, uint16_t timeout_ms)

Warning toast

const char*message
uint16_ttimeout_ms
void ui_notify_confirm(const char* message, const gfx_img_t* icon, void (*callback)(void*, void*), void* callback_ctx)

Yes/no dialogue; callback fires on confirm

const char*message
const gfx_img_t*icon
void (*callback)(void*, void*)
void*callback_ctx
static void on_erase(void* ctx, void* unused) { (void)unused; wipe(ctx); }
ui_notify_confirm("Erase all?", NULL, on_erase, m);
void ui_notify_dialogue(const char* text, void (*callback)(void*, void*), void* callback_ctx)

Text dialogue with a callback

const char*text
void (*callback)(void*, void*)
void*callback_ctx
void ui_notify_popup_with_cb(const char* header, const char* hint, const gfx_img_t* icon, void (*callback)(void*, bool), void* callback_ctx)

Popup whose callback reports which way it was dismissed

const char*header
const char*hint
const gfx_img_t*icon
void (*callback)(void*, bool)
void*callback_ctx
void ui_notify_hide(ui_notify_t* n)

Hide the current notification. Pass NULL.

ui_notify_t*n
bool ui_notify_is_active(void)

Is a notification showing?

bool ui_notify_is_visible(const ui_notify_t* n)

Is this notification visible? Pass NULL for the current one.

const ui_notify_t*n
void ui_notify_set_modal(bool modal)

Make the next notification modal (swallows input — see the warning above)

boolmodal
void ui_notify_set_show_confirm_btn(bool show)

Show or hide the confirm button

boolshow
void ui_notify_set_pos_global(const uint16_t x, const uint16_t y)

Move the notification on screen

const uint16_tx
const uint16_ty