17static const char*
s_tag =
"ra8_app";
39 for (uint16_t i = 0U; i < reg->
count; ++i) {
40 if ((reg->
apps[i] !=
nullptr) && (reg->
apps[i]->
id ==
id)) {
41 *out_idx = (int16_t)i;
66 if (app->vt->init !=
nullptr) {
67 const ra8_err_t ierr = app->vt->init(app);
72 app->initialized =
true;
89 if (target == reg->
active) {
94 if ((cur !=
nullptr) && (cur->vt->on_leave !=
nullptr)) {
95 cur->vt->on_leave(cur);
109 if ((next !=
nullptr) && (next->vt->on_enter !=
nullptr)) {
110 next->vt->on_enter(next);
129 *out_handled =
false;
134 if ((a !=
nullptr) && (a->vt->on_input !=
nullptr)) {
135 *out_handled = a->vt->on_input(a, ev);
147 if ((a !=
nullptr) && (a->vt->tick !=
nullptr)) {
160 if ((a !=
nullptr) && (a->vt->render !=
nullptr)) {
170 *out_count = reg->
count;
178 if (idx >= reg->
count) {
181 *out_app = reg->
apps[idx];
195 nav->
stack = storage;
214 bool will_push =
false;
215 uint16_t prev_id = 0U;
216 if (cur !=
nullptr) {
257 if (nav->
depth == 0U) {
260 const uint16_t prev_id = nav->
stack[nav->
depth - 1U];
274 *out_depth = nav->
depth;
320 for (uint16_t i = idx; (uint16_t)(i + 1U) < reg->
count; ++i) {
324 if (reg->
active > (int16_t)idx) {
342 if (!app->removable) {
348 if (app->vt->deinit !=
nullptr) {
349 app->vt->deinit(app);
351 app->initialized =
false;
ra8_err_t ra8_app_nav_init(ra8_app_nav_t *nav, ra8_app_registry_t *reg, uint16_t *storage, uint16_t cap)
Bind a navigation back-stack to a registry + caller-owned storage.
ra8_err_t ra8_app_launch(ra8_app_registry_t *reg, uint16_t id)
Launch (focus) the app with id, running the focus lifecycle.
ra8_err_t ra8_app_tick(ra8_app_registry_t *reg)
Run the focused app's per-frame tick (no-op if none / NULL).
ra8_err_t ra8_app_nav_back(ra8_app_nav_t *nav, bool *out_popped)
Return to the most recently pushed app (pop the back-stack).
ra8_err_t ra8_app_register(ra8_app_registry_t *reg, ra8_app_t *app)
Register an app (calls its init once) and add it to the registry.
ra8_err_t ra8_app_nav_go_index(ra8_app_nav_t *nav, uint16_t idx)
Focus the app at registry index idx (launcher select-by-position).
ra8_err_t ra8_app_nav_go(ra8_app_nav_t *nav, uint16_t id)
Focus app id, pushing the outgoing app onto the back-stack.
ra8_err_t ra8_app_count(const ra8_app_registry_t *reg, uint16_t *out_count)
Number of registered apps (for the launcher to list).
ra8_err_t ra8_app_state(const ra8_app_registry_t *reg, uint16_t id, ra8_app_state_t *out_state)
Report an app's lifecycle state, derived from the registry.
ra8_err_t ra8_app_find(const ra8_app_registry_t *reg, uint16_t id, int16_t *out_idx)
Find a registered app's index by id.
ra8_err_t ra8_app_at(const ra8_app_registry_t *reg, uint16_t idx, ra8_app_t **out_app)
Get the app at registry index idx (launcher enumeration).
ra8_err_t ra8_app_uninstall(ra8_app_registry_t *reg, uint16_t id)
Uninstall (unmount) a removable, non-focused app from the registry.
ra8_err_t ra8_app_route_input(ra8_app_registry_t *reg, const ra8_widget_event_t *ev, bool *out_handled)
Route an input event to the focused app.
static void internal_app_remove_at(ra8_app_registry_t *reg, uint16_t idx)
Remove the registry slot at idx and compact the table down one place.
ra8_err_t ra8_app_nav_depth(const ra8_app_nav_t *nav, uint16_t *out_depth)
Current back-stack depth (apps the user can still go back through).
ra8_err_t ra8_app_active(const ra8_app_registry_t *reg, ra8_app_t **out_app)
Get the currently focused app.
ra8_err_t ra8_app_render(ra8_app_registry_t *reg)
Run the focused app's render (on-target; no-op if none / NULL).
ra8_err_t ra8_app_registry_init(ra8_app_registry_t *reg, ra8_app_t **storage, uint16_t cap)
Bind a registry to caller-owned pointer storage (empty, no focus).
static const char * s_tag
Logging / check tag.
Zero-heap app framework: lifecycle + static registry + launcher (#146).
@ k_ra8_app_none
No active app / not found.
ra8_app_state_t
Lifecycle state of one app within the framework's state machine.
@ k_ra8_app_state_background
Mounted (init ran), not focused.
@ k_ra8_app_state_foreground
Mounted and focused (the active app).
@ k_ra8_app_state_unmounted
Not registered (initial / after uninstall).
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_busy
Resource busy – blocking operation cannot proceed.
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
@ k_ra8_err_conflict
Conflict with concurrent access detected.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
A bounded back-stack of app ids layered over a registry (zero-heap).
uint16_t cap
Capacity of stack.
ra8_app_registry_t * reg
Registry the navigation drives (non-NULL).
uint16_t * stack
Caller storage: back-stack of app ids.
uint16_t depth
Number of ids currently on the back-stack.
Fixed table of registered apps + the focused index.
ra8_app_t ** apps
Caller storage (array of app pointers).
int16_t active
Focused app index, or k_ra8_app_none.
uint16_t count
Registered app count.
uint16_t cap
Capacity of apps.
One app instance + its metadata (caller-owned, static).
uint16_t id
Unique app id (launch key).