|
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 switch arms 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 ui_widget_mgr.c (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 command switch process_ui_command() in ipc_ui.c (definition at :393, drained from the 50 ms LVGL timer at :875). 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 pinned dispatch site in the switch (case label and call line, read from the source in the pin-extraction pass), the MicroPython ui.* surface that reaches it, and the contract. Four cases — CREATE, DELETE, SET_TEXT, SET_VALUE — are replicated verbatim in the Tier-2 excerpt; the remaining cases are deliberately not replicated (disclosure minimisation) and are cited as text. 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 (ipc_ui.c:890, inside ipc_ui_init() at :885) — never call it directly. Not a switch case. Takes the deferred-binding NULL at boot; the page supplies the real parent later through ipc_ui_set_container(). ipc_ui.c:890 — ui_widget_mgr_init(parent); under the comment "Initialize widget manager with parent container". | 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() (ipc_ui.c:918-921) — page-based navigation, not the dispatch switch. A design revision recorded this correction: the blanket "sole caller is the
IPC command switch" claim is wrong for this one row. Consumers call ipc_ui_set_container(), never this. GFX-task context; void. ipc_ui.c:920 — the whole body of ipc_ui_set_container() is ui_widget_mgr_set_parent(parent);. 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 switch maps those to UI_STATUS_OK / UI_STATUS_TABLE_FULL / UI_STATUS_INVALID_TYPE in a bidirectional response, arms fast drain (ui_arm_fast_mode()), 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_ui.c:420 case IPC_CMD_UI_CREATE: / :422 int handle = ui_widget_mgr_create(cfg); — replicated in the representative excerpt on Widget manager (IPC dispatch). | 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_ui.c:758 case IPC_CMD_UI_SPRITE_NEW: / :763 int handle = ui_widget_mgr_create_sprite(dsc, s->x, s->y);. | 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, called one line earlier in the switch. GFX-task context. w.frame(sprite_id) on a sprite handle (modui.c:651). ipc_ui.c:819 case IPC_CMD_UI_SPRITE_FRAME: / :822 game_sprite_lookup(item->data[1]) / :823 ui_widget_mgr_set_sprite_image(handle, dsc);. | 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_ui.c:453 case IPC_CMD_UI_DELETE: / :455 ui_widget_mgr_delete(handle); — replicated in the representative excerpt on Widget manager (IPC dispatch). | 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 case (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_ui.c:553 case IPC_CMD_UI_CLEAR_ALL: / :554 ui_widget_mgr_clear_all(); followed by the auto-navigate reset. | void ui_widget_mgr_set_text | ( | int | handle, |
| const char * | text ) |
Sets a widget's text; the switch arms 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_ui.c:459 case IPC_CMD_UI_SET_TEXT: / :462 ui_widget_mgr_set_text(handle, text); + :463 ui_arm_fast_mode(); — replicated in the representative excerpt on Widget manager (IPC dispatch). | 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_ui.c:467 case IPC_CMD_UI_SET_VALUE: / :471 ui_widget_mgr_set_value(handle, value); — replicated in the representative excerpt on Widget manager (IPC dispatch). | 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_ui.c:479 case IPC_CMD_UI_SET_POSITION: / :484 ui_widget_mgr_set_position(handle, x, y); + :485 ui_arm_fast_mode();. | 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_ui.c:489 case IPC_CMD_UI_SET_SIZE: / :494 ui_widget_mgr_set_size(handle, w, h);. | 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_ui.c:499 case IPC_CMD_UI_SET_COLOR: / :503 ui_widget_mgr_set_color(handle, color);. | 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_ui.c:508 case IPC_CMD_UI_SET_VISIBLE: / :511 ui_widget_mgr_set_visible(handle, visible);. | 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_ui.c:586 case IPC_CMD_UI_GET_VALUE: / :588 int32_t value = ui_widget_mgr_get_value(handle);. | 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_ui.c:578 case IPC_CMD_UI_SET_DOTMATRIX: / :582 ui_widget_mgr_set_dotmatrix(handle, bitmap, len);. | 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_ui.c:647 case IPC_CMD_UI_SET_IMAGE: / :656 ui_widget_mgr_set_image(handle, offset, pixel_data, chunk_len);. | 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 (ui_widget_mgr.c:333, guarded if (event_type != 0)) and the input event callback for the twelve input events (:406), which first checks the per-widget subscription mask (s_widget_event_mask[handle] & UI_EVENT_MASK(event_type)) 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. BENTO-TESAIoT-libraries/claw/common/modules/ipc_ui/ui_widget_mgr.c:333 and :406 (compiled into the prebuilt archive; not shipped as source) — pinned, not replicated. | 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 switch answers POLL_EVENTS with exactly those bytes. The same case 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_ui.c:516 case IPC_CMD_UI_POLL_EVENTS: / :527 int count = ui_widget_mgr_event_drain(events, 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 (UI_MAX_WIDGETS in the switch), 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_ui.c:660 case IPC_CMD_UI_LIST: / :664 int count = ui_widget_mgr_list(info, UI_MAX_WIDGETS);. | 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 identical three-line guard recurs at ipc_ui.c:443 (hide on first CREATE), :519 (unhide on POLL_EVENTS), :560 and :859 (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_ui.c:672 case IPC_CMD_UI_SET_SCREEN: / :676 ui_widget_mgr_set_screen(w, h);. | 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_ui.c:686 case IPC_CMD_UI_CHART_ADD_SERIES: / :691 int idx = ui_widget_mgr_chart_add_series(handle, color);. | 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_ui.c:700 case IPC_CMD_UI_CHART_SET_NEXT: / :706 ui_widget_mgr_chart_set_next(handle, series_idx, value);. | 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 ui_widget_mgr.c
implementations — claw's and game's", because the Game kits compile claw's ipc_ui.c 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_ui.c:772 case IPC_CMD_UI_ITEM_ADD: / :782 int child = ui_widget_mgr_item_add(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_ui.c:804 case IPC_CMD_UI_ITEM_CLEAR: / :805 ui_widget_mgr_item_clear(item->data[0]);. | 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_ui.c:810 case IPC_CMD_UI_SET_PROP: / :814 ui_widget_mgr_set_prop(p->handle, p->prop_id, value);. | 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 pin-extraction pass found it dispatched from the GET_TEXT handler at ipc_ui.c:606 — not from a GET_OBJECT opcode — where the object is used to read the text a user typed into a textarea. The handler's own comment describes that route as "the only route by which
anything a user TYPED reaches MicroPython" (ipc_ui.c:595-596). GFX-task context. w.text() with no argument (modui.c:366, bidirectional) on a ui.Textarea / keyboard-backed widget. ipc_ui.c:594 case IPC_CMD_UI_GET_TEXT: / :606 lv_obj_t *obj = ui_widget_mgr_get_object((int)handle);.