|
SDK for TESAIoT Dev Kit
API reference & tutorials (ModusToolbox)
|
Functions | |
| void | ui_widget_mgr_init (lv_obj_t *parent) |
| Called by ipc_ui_init() itself — never call it directly. | |
| void | ui_widget_mgr_set_parent (lv_obj_t *parent) |
| Clears all widgets and sets the new parent; called only via ipc_ui_set_container(). | |
| bool | ui_widget_mgr_needs_container (void) |
| True while the parent is NULL; no caller anywhere. | |
| int | ui_widget_mgr_create (const ipc_ui_create_t *cfg) |
| Creates a widget from a config; handle 0-31, -1 table full, -2 invalid type. | |
| int | ui_widget_mgr_create_sprite (const lv_image_dsc_t *dsc, int16_t x, int16_t y) |
| Creates an image sprite in the same handle table. | |
| void | ui_widget_mgr_set_sprite_image (int handle, const lv_image_dsc_t *dsc) |
| Swaps a sprite's image; the descriptor comes from game_sprite_lookup(). | |
| void | ui_widget_mgr_delete (int handle) |
| Deletes one widget and frees its handle. | |
| void | ui_widget_mgr_clear_all (void) |
| Deletes every widget and resets the handle table. | |
| void | ui_widget_mgr_set_text (int handle, const char *text) |
| Sets a widget's text; the dispatch arms the fast drain after it. | |
| void | ui_widget_mgr_set_value (int handle, int32_t value) |
| Sets a numeric value; arms fast drain so dashboards are not pinned to 5 FPS. | |
| void | ui_widget_mgr_set_position (int handle, int16_t x, int16_t y) |
| Moves a widget; arms fast drain for gameplay frame rate. | |
| void | ui_widget_mgr_set_size (int handle, int16_t w, int16_t h) |
| Resizes a widget. | |
| void | ui_widget_mgr_set_color (int handle, uint32_t color) |
| Sets the primary colour, 0xRRGGBB. | |
| void | ui_widget_mgr_set_visible (int handle, bool visible) |
| Shows or hides one widget. | |
| void | ui_widget_mgr_set_all_visible (bool visible) |
| Shows or hides every managed widget; the Playground console toggle's view switch. | |
| int32_t | ui_widget_mgr_get_value (int handle) |
| Reads the widget's current value; 0 also means bad handle. | |
| void | ui_widget_mgr_set_dotmatrix (int handle, const uint8_t *bitmap, uint8_t len) |
| Loads a bitmap into a DotMatrix widget. | |
| void | ui_widget_mgr_set_image (int handle, uint16_t offset, const uint8_t *data, uint8_t len) |
| Chunked RGB565 transfer into an Image widget's canvas. | |
| void | ui_widget_mgr_event_push (uint8_t handle, uint8_t event_type, int32_t value) |
| Producer side of the event ring; internal LVGL event callbacks only. | |
| int | ui_widget_mgr_event_drain (ipc_ui_event_t *out, int max_events) |
| Drains events for POLL_EVENTS — the ui.poll() backend. | |
| int | ui_widget_mgr_count (void) |
| Number of live handles; zero callers anywhere. | |
| int | ui_widget_mgr_list (ipc_ui_widget_info_t *out, int max_items) |
| Handle + type of every active widget — the ui.list() backend. | |
| lv_obj_t * | ui_widget_mgr_get_parent (void) |
| Nullable current parent; every call site null-checks it. | |
| void | ui_widget_mgr_set_screen (int16_t width, int16_t height) |
| Sets screen dimensions and resets the auto-layout grid. | |
| int | ui_widget_mgr_chart_add_series (int handle, uint32_t color) |
| Adds a series to a Chart; returns index 0-3 or -1. | |
| void | ui_widget_mgr_chart_set_next (int handle, uint8_t series_idx, int32_t value) |
| Appends the next value to one chart series. | |
| int | ui_widget_mgr_item_add (const ipc_ui_item_add_t *it) |
| Appends one item; overloaded returns, dual-implementation rule. | |
| void | ui_widget_mgr_item_clear (int handle) |
| Empties a collection widget. | |
| void | ui_widget_mgr_set_prop (int handle, uint8_t prop_id, int32_t value) |
| Sets one UI_PROP_* property; how .listen() subscribes to events. | |
| lv_obj_t * | ui_widget_mgr_get_object (int handle) |
| LVGL object behind a handle; the GET_TEXT route for typed text. | |
Header: ui_widget_mgr.h. Implementation: archived (libbento_ipc.a). "Widget handle table and LVGL widget lifecycle manager.
Maps handle IDs (0-31) to lv_obj_t* pointers. Creates, modifies, deletes LVGL
widgets in GFX task context" (ui_widget_mgr.h).
Read this first — who actually calls these. These primitives are not application-facing in C. Inside the archive their sole caller is the IPC_UI command switch (the UI command dispatch), drained from the 50 ms LVGL timer. The real callers are MicroPython scripts on CM33_NS: each ui.* call in modui.c packs a payload, sends it over the pipe, and the switch below unpacks it and calls one primitive. Documenting them as "call this from your page code" would misrepresent the architecture — a page that calls ui_widget_mgr_create() directly is bypassing the handle table's owner and will race the next script's CLEAR_ALL.
Every entry therefore gives three things: the IPC command that dispatches to it (a constant in ipc_ui_protocol.h), the MicroPython ui.* surface that reaches it, and the contract. Every case is described as text; the switch itself is inside the archive and does not ship as source. Two primitives are called from outside the switch (init by ipc_ui_init(), set_parent by ipc_ui_set_container()), two have no caller anywhere (count, needs_container), and two are called from the template's own Playground page (clear_all, set_all_visible).
| void ui_widget_mgr_init | ( | lv_obj_t * | parent | ) |
Called by ipc_ui_init() itself — never call it directly.
Initialize the widget manager.
| parent | The LVGL parent object (UX/UI tab scrollable container). |
ipc_ui_init() itself, as its first statement — never call it directly. Not called from the UI command dispatch. Takes the deferred-binding NULL at boot; the page supplies the real parent later through ipc_ui_set_container(). ipc_ui_init() only, once at bring-up. | void ui_widget_mgr_set_parent | ( | lv_obj_t * | parent | ) |
Clears all widgets and sets the new parent; called only via ipc_ui_set_container().
Update the parent container (for page-based navigation). Clears all existing widgets and sets new parent.
| parent | New LVGL parent object, or NULL to invalidate. |
ui_widget_mgr.h); pass NULL to invalidate. Its sole caller is ipc_ui_set_container() — page-based navigation, not the UI command dispatch. Consumers call ipc_ui_set_container(), never this. GFX-task context; void. ipc_ui_set_container() only, a thin wrapper that forwards its argument here and does nothing else. The template call sites of that wrapper are on UI containers. | bool ui_widget_mgr_needs_container | ( | void | ) |
True while the parent is NULL; no caller anywhere.
Check if the widget manager has no parent container.
NULL — between ipc_ui_set_container(NULL) on page destroy and the next page's bind — i.e. while CREATE would fail. No caller anywhere. The authored example relates it to the deferred-binding contract: a page that wants to know whether a script's widgets can land yet asks this, in GFX-task context. | int ui_widget_mgr_create | ( | const ipc_ui_create_t * | cfg | ) |
Creates a widget from a config; handle 0-31, -1 table full, -2 invalid type.
Create a widget from IPC CREATE payload.
| cfg | Parsed CREATE payload. |
-1 when the table is full, -2 for an invalid type. The dispatch maps those to UI_STATUS_OK / UI_STATUS_TABLE_FULL / UI_STATUS_INVALID_TYPE in a bidirectional response, arms the fast drain, and on the first CREATE hides the container until POLL_EVENTS or a timeout unhides it (so a burst of creates appears at once). GFX-task context. ui.Button(...), ui.Label(...), ui.Slider(...), ui.Chart(...) and the rest of the ui class table (modui.c:1226, bidirectional). IPC_CMD_UI_CREATE (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | int ui_widget_mgr_create_sprite | ( | const lv_image_dsc_t * | dsc, |
| int16_t | x, | ||
| int16_t | y ) |
Creates an image sprite in the same handle table.
Create an image sprite from a compiled C descriptor. Reuses the widget handle table so position/visibility/delete work through the normal ops.
| dsc | Compiled sprite descriptor (resolved per-project from a SPR id). |
-1 table full, -2 invalid or no sprite engine — the latter is what the weak game_sprite_create default produces (see Weak hooks (implement, don't call)). GFX-task context. ui.sprite(id, x, y) (modui.c:1731, bidirectional). IPC_CMD_UI_SPRITE_NEW (ipc_ui_protocol.h): the UI command dispatch in the GFX task looks up the sprite by id through the weak game_sprite_lookup() hook, then calls this function with the result. | void ui_widget_mgr_set_sprite_image | ( | int | handle, |
| const lv_image_dsc_t * | dsc ) |
Swaps a sprite's image; the descriptor comes from game_sprite_lookup().
Swap a sprite's image (directional head, enemy kind, explosion frame). No-op on invalid handle or NULL descriptor.
NULL descriptor. The descriptor comes from the project's game_sprite_lookup() override, which the dispatch calls just before this function. GFX-task context. w.frame(sprite_id) on a sprite handle (modui.c:651). IPC_CMD_UI_SPRITE_FRAME (ipc_ui_protocol.h): the UI command dispatch in the GFX task looks up the new image by id through game_sprite_lookup(), then calls this function with the result. | void ui_widget_mgr_delete | ( | int | handle | ) |
Deletes one widget and frees its handle.
Delete a widget by handle.
| handle | Handle ID (0-31). |
w.delete() (modui.c:506). IPC_CMD_UI_DELETE (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | void ui_widget_mgr_clear_all | ( | void | ) |
Deletes every widget and resets the handle table.
Delete all widgets and reset the handle table.
CLEAR_ALL command (new script), and the template's Playground page, from an LVGL LV_EVENT_CLICKED callback — GFX-task context. In the page the widgets are torn down before the IPC restart command is sent, so CM33_NS cannot push new widgets into a half-cleared table. Void; no error path. The destructive variant at page_playground.c:105 clears, sends IPC_CMD_DELETE_MAIN_PY, then resets the MCU. ui.clear() (modui.c:1553), also issued by ui.program() and the IDE deploy path (:1641, :1975). IPC_CMD_UI_CLEAR_ALL (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it, then resets the auto-navigate state for the next script. | void ui_widget_mgr_set_text | ( | int | handle, |
| const char * | text ) |
Sets a widget's text; the dispatch arms the fast drain after it.
Set text on a widget.
w.text("...") (modui.c:396; also :527 and :1261 for constructor-time text). Note the 95-byte constructor and 126-byte .text() payload limits enforced on the CM33_NS side. IPC_CMD_UI_SET_TEXT (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it, then arms the fast drain. | void ui_widget_mgr_set_value | ( | int | handle, |
| int32_t | value ) |
Sets a numeric value; arms fast drain so dashboards are not pinned to 5 FPS.
Set numeric value on a widget.
w.value(n) (modui.c:424). IPC_CMD_UI_SET_VALUE (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it, then arms the fast drain. | void ui_widget_mgr_set_position | ( | int | handle, |
| int16_t | x, | ||
| int16_t | y ) |
Moves a widget; arms fast drain for gameplay frame rate.
Set position of a widget.
w.pos(x, y) (modui.c:442). IPC_CMD_UI_SET_POSITION (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it, then arms the fast drain. | void ui_widget_mgr_set_size | ( | int | handle, |
| int16_t | w, | ||
| int16_t | h ) |
Resizes a widget.
Set size of a widget.
w.size(w, h) (modui.c:460). IPC_CMD_UI_SET_SIZE (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | void ui_widget_mgr_set_color | ( | int | handle, |
| uint32_t | color ) |
Sets the primary colour, 0xRRGGBB.
Set primary color of a widget.
0xRRGGBB. GFX-task context. w.color(0xRRGGBB) (modui.c:476). IPC_CMD_UI_SET_COLOR (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | void ui_widget_mgr_set_visible | ( | int | handle, |
| bool | visible ) |
Shows or hides one widget.
Show or hide a widget.
w.show() / w.hide() (modui.c:486, :496). IPC_CMD_UI_SET_VISIBLE (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | void ui_widget_mgr_set_all_visible | ( | bool | visible | ) |
Shows or hides every managed widget; the Playground console toggle's view switch.
Show or hide ALL managed widgets at once. Used by Console/UI toggle to switch between widget view and console view.
| int32_t ui_widget_mgr_get_value | ( | int | handle | ) |
Reads the widget's current value; 0 also means bad handle.
Get current value of a widget.
w.value() with no argument (modui.c:409, bidirectional). IPC_CMD_UI_GET_VALUE (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | void ui_widget_mgr_set_dotmatrix | ( | int | handle, |
| const uint8_t * | bitmap, | ||
| uint8_t | len ) |
Loads a bitmap into a DotMatrix widget.
Set dot matrix bitmap data.
DotMatrix widget; len bytes follow the handle in the payload. GFX-task context. w.set_pixels(bytes) on a ui.DotMatrix (modui.c:589). IPC_CMD_UI_SET_DOTMATRIX (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | void ui_widget_mgr_set_image | ( | int | handle, |
| uint16_t | offset, | ||
| const uint8_t * | data, | ||
| uint8_t | len ) |
Chunked RGB565 transfer into an Image widget's canvas.
Set image pixel data (chunked RGB565 transfer).
| handle | Widget handle (must be UI_WIDGET_IMAGE). |
| offset | Byte offset into the canvas pixel buffer. |
| data | Chunk of RGB565 pixel data. |
| len | Chunk length in bytes. |
Image widget's canvas: offset is the byte offset into the pixel buffer, len the chunk length. The handle must be a UI_WIDGET_IMAGE. The script side loops chunks of at most the payload budget. GFX-task context. w.set_image(data) on a ui.Image (modui.c:558, one IPC message per chunk). IPC_CMD_UI_SET_IMAGE (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | void ui_widget_mgr_event_push | ( | uint8_t | handle, |
| uint8_t | event_type, | ||
| int32_t | value ) |
Producer side of the event ring; internal LVGL event callbacks only.
Push an event into the ring buffer (called from LVGL event callbacks).
ui_widget_mgr_event_drain(). Called from LVGL event callbacks inside the archived widget manager — two sites, both internal: the generic widget event callback, which pushes only non-zero event types, and the input event callback for the twelve input events, which first checks the widget's subscription mask (the UI_EVENT_MASK(event_type) bit) and returns without pushing when the script did not .listen() for that event. It is also where ipc_ui_input_activity() is raised. GFX-task context. w.listen("pressed", cb) and w.bind(...) set the mask that lets a push through; ui.poll() drains it. libbento_ipc.a archive and not shipped as source. | int ui_widget_mgr_event_drain | ( | ipc_ui_event_t * | out, |
| int | max_events ) |
Drains events for POLL_EVENTS — the ui.poll() backend.
Drain events from the ring buffer.
| out | Output array. |
| max_events | Maximum events to drain. |
max_events events into a caller-owned array and returns the count; the dispatch answers POLL_EVENTS with exactly those bytes. The same command also unhides the container hidden by the first CREATE — through the null-checked ui_widget_mgr_get_parent() — so a script's widgets appear all at once. GFX-task context. ui.poll() (modui.c:1324, bidirectional) — the call every event loop makes; .listen() callbacks fire from its result. IPC_CMD_UI_POLL_EVENTS (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it, with max_events set to UI_MAX_EVENTS_PER_POLL. | int ui_widget_mgr_count | ( | void | ) |
Number of live handles; zero callers anywhere.
Get current widget count.
ui_widget_mgr.h:142) and three definitions — zero callers. The authored example reads it in GFX-task context after clear_all(), as a teardown assertion; a count read from another task races the dispatch path. ui.list() uses ui_widget_mgr_list(), not this). | int ui_widget_mgr_list | ( | ipc_ui_widget_info_t * | out, |
| int | max_items ) |
Handle + type of every active widget — the ui.list() backend.
List all active widgets (handle + type).
| out | Output array of ipc_ui_widget_info_t. |
| max_items | Maximum items to fill. |
max_items (the dispatch passes UI_MAX_WIDGETS), and returns the count written. GFX-task context. ui.list() (modui.c:1432, bidirectional) and ui.get(id) (:1519), plus the internal re-sync in modui.c:138-153 and :291. IPC_CMD_UI_LIST (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | lv_obj_t * ui_widget_mgr_get_parent | ( | void | ) |
Nullable current parent; every call site null-checks it.
Get the current parent container object.
NULL whenever no page has bound a container: between ipc_ui_set_container(NULL) on destroy and the next page's bind. The UI command dispatch applies the same null check when it hides the container on the first CREATE, when it unhides it on POLL_EVENTS or CLEAR_ALL, and in the safety-timeout unhide when POLL_EVENTS never arrives. GFX-task context. | void ui_widget_mgr_set_screen | ( | int16_t | width, |
| int16_t | height ) |
Sets screen dimensions and resets the auto-layout grid.
Set screen dimensions and reset auto-layout grid.
| width | Screen width in pixels (auto-layout wraps at width - 100). |
| height | Screen height in pixels (reserved for future use). |
width - 100; height reserved). GFX-task context. ui.screen(w, h) (modui.c:1647). IPC_CMD_UI_SET_SCREEN (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | int ui_widget_mgr_chart_add_series | ( | int | handle, |
| uint32_t | color ) |
Adds a series to a Chart; returns index 0-3 or -1.
Add a series to a chart widget.
| handle | Widget handle (must be UI_WIDGET_CHART). |
| color | Series color (0xRRGGBB). |
Chart widget; returns the series index 0-3 or -1. The handle must be a UI_WIDGET_CHART. Bidirectional so the script learns the index. GFX-task context. w.add_series(color) on a ui.Chart (modui.c:605, bidirectional). IPC_CMD_UI_CHART_ADD_SERIES (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | void ui_widget_mgr_chart_set_next | ( | int | handle, |
| uint8_t | series_idx, | ||
| int32_t | value ) |
Appends the next value to one chart series.
Set next value for a specific chart series.
| handle | Widget handle (must be UI_WIDGET_CHART). |
| series_idx | Series index (0-3). |
| value | Data value. |
w.set_next(series, value) (modui.c:631). IPC_CMD_UI_CHART_SET_NEXT (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | int ui_widget_mgr_item_add | ( | const ipc_ui_item_add_t * | it | ) |
Appends one item; overloaded returns, dual-implementation rule.
Append one item to a collection or container widget.
| it | Parsed ITEM_ADD payload; the meaning of a/b/flags/text is per widget type and is tabulated beside ui_widget_type_t. |
>= 0 is the handle of a child page a container created (Tabview / Tileview / Win); UI_ITEM_ADD_OK_NO_CHILD (-3) means the item was appended with no child object; -1 table full; -2 bad handle, wrong type, or the item could not be added. The header's block comment is binding: this function "MUST exist,
and behave the same way for the same widget type, in BOTH widget-manager
implementations — claw's and game's", because the Game kits compile claw's UI dispatcher against game's widget manager and a type served in one and not the other returns UI_STATUS_INVALID_TYPE on some boards with no build error anywhere. GFX-task context. w.add_item, w.add_row, w.add_option, w.add_button, w.add_point, w.add_tab, w.add_tile, w.add_page, w.add_span, w.row, w.section, w.separator (modui.c:686 fire-and-forget, :694 bidirectional for the container forms). IPC_CMD_UI_ITEM_ADD (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | void ui_widget_mgr_item_clear | ( | int | handle | ) |
Empties a collection widget.
Empty a collection widget (all rows / options / buttons / list entries). No-op on a bad handle or a widget type with no collection.
item_add. GFX-task context. w.clear_items() (modui.c:836). IPC_CMD_UI_ITEM_CLEAR (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | void ui_widget_mgr_set_prop | ( | int | handle, |
| uint8_t | prop_id, | ||
| int32_t | value ) |
Sets one UI_PROP_* property; how .listen() subscribes to events.
Set one per-widget property.
| handle | Widget handle. |
| prop_id | UI_PROP_*. |
| value | Property value; two props carry a hi16/lo16 pair (see header). |
UI_PROP_*); two props carry a hi16/lo16 pair in value. Same dual-implementation rule as item_add. The UI_PROP_EVENT_MASK property is how .listen() subscribes a widget to input events. GFX-task context. w.prop(ui.PROP_*, value) and the named helpers w.ticks(), w.digits(), w.col_width(), w.listen(), w.opens(), w.pen(), w.month() (modui.c:856). IPC_CMD_UI_SET_PROP (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function for it. | lv_obj_t * ui_widget_mgr_get_object | ( | int | handle | ) |
LVGL object behind a handle; the GET_TEXT route for typed text.
The LVGL object behind a handle, or NULL if the slot is empty.
The manager IS the handle table, so answering this is its job. Nothing on the device calls it — it exists so a host harness can drive an object the way a finger would (lv_obj_send_event), which is the only way to photograph behaviour that only a tap can start, such as a menu row loading its page.
NULL for an empty slot. Two facts, both true and to be read together: the header says "Nothing on the
device calls it — it exists so a host harness can drive an object the way a
finger would"; and the UI command dispatch does call it, for GET_TEXT — not for a GET_OBJECT opcode — where the object is used to read the text a user typed into a textarea. The IPC_CMD_UI_GET_TEXT comment in ipc_ui_protocol.h describes that route as "the only way anything a user
TYPES can reach MicroPython". GFX-task context. w.text() with no argument (modui.c:366, bidirectional) on a ui.Textarea / keyboard-backed widget. IPC_CMD_UI_GET_TEXT (ipc_ui_protocol.h): the UI command dispatch in the GFX task calls this function to reach the widget's object and read its text back.