|
SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (ModusToolbox)
|
Functions | |
| void | ui_widget_mgr_init (lv_obj_t *parent) |
| ipc_ui_init() เรียกฟังก์ชันนี้เอง — ห้ามเรียกโดยตรง | |
| void | ui_widget_mgr_set_parent (lv_obj_t *parent) |
| เคลียร์ widget ทั้งหมดแล้วตั้ง parent ใหม่; ถูกเรียกผ่าน ipc_ui_set_container() เท่านั้น | |
| bool | ui_widget_mgr_needs_container (void) |
| คืน true ขณะที่ parent เป็น NULL; ไม่มีผู้เรียกที่ใดเลย | |
| int | ui_widget_mgr_create (const ipc_ui_create_t *cfg) |
| สร้าง widget จาก config; คืน handle 0-31, -1 เมื่อตารางเต็ม, -2 เมื่อชนิดไม่ถูกต้อง | |
| int | ui_widget_mgr_create_sprite (const lv_image_dsc_t *dsc, int16_t x, int16_t y) |
| สร้าง sprite ชนิดภาพลงใน handle table เดียวกัน | |
| void | ui_widget_mgr_set_sprite_image (int handle, const lv_image_dsc_t *dsc) |
| สลับภาพของ sprite; descriptor มาจาก game_sprite_lookup() | |
| void | ui_widget_mgr_delete (int handle) |
| ลบ widget หนึ่งตัวและปล่อย handle ของมันคืน | |
| void | ui_widget_mgr_clear_all (void) |
| ลบ widget ทุกตัวและรีเซ็ต handle table | |
| void | ui_widget_mgr_set_text (int handle, const char *text) |
| ตั้งข้อความของ widget; switch จะตั้ง fast drain ให้พร้อมทำงานหลังจากนั้น | |
| void | ui_widget_mgr_set_value (int handle, int32_t value) |
| ตั้งค่าตัวเลข; ตั้ง fast drain ให้พร้อมทำงานเพื่อไม่ให้แดชบอร์ดถูกตรึงไว้ที่ 5 FPS | |
| void | ui_widget_mgr_set_position (int handle, int16_t x, int16_t y) |
| ย้ายตำแหน่ง widget; ตั้ง fast drain ให้พร้อมทำงานเพื่ออัตราเฟรมระหว่างเล่นเกม | |
| void | ui_widget_mgr_set_size (int handle, int16_t w, int16_t h) |
| เปลี่ยนขนาดของ widget | |
| void | ui_widget_mgr_set_color (int handle, uint32_t color) |
| ตั้งสีหลัก 0xRRGGBB | |
| void | ui_widget_mgr_set_visible (int handle, bool visible) |
| แสดงหรือซ่อน widget หนึ่งตัว | |
| void | ui_widget_mgr_set_all_visible (bool visible) |
| แสดงหรือซ่อน widget ที่จัดการอยู่ทุกตัว; เป็นตัวสลับมุมมองของการสลับคอนโซลบนหน้า Playground | |
| int32_t | ui_widget_mgr_get_value (int handle) |
| อ่านค่าปัจจุบันของ widget; ค่า 0 หมายถึง handle ไม่ถูกต้องได้ด้วย | |
| void | ui_widget_mgr_set_dotmatrix (int handle, const uint8_t *bitmap, uint8_t len) |
| โหลดบิตแมปเข้าไปใน widget ชนิด DotMatrix | |
| void | ui_widget_mgr_set_image (int handle, uint16_t offset, const uint8_t *data, uint8_t len) |
| การส่ง RGB565 เป็นก้อน ๆ เข้าไปใน canvas ของ widget ชนิด Image | |
| void | ui_widget_mgr_event_push (uint8_t handle, uint8_t event_type, int32_t value) |
| ฝั่งผู้ผลิตข้อมูลของ event ring; เฉพาะ LVGL event callback ภายในเท่านั้น | |
| int | ui_widget_mgr_event_drain (ipc_ui_event_t *out, int max_events) |
| ระบาย event ออกให้ POLL_EVENTS — เป็น backend ของ ui.poll() | |
| int | ui_widget_mgr_count (void) |
| จำนวน handle ที่ยังใช้งานอยู่; ไม่มีผู้เรียกเลยที่ใด | |
| int | ui_widget_mgr_list (ipc_ui_widget_info_t *out, int max_items) |
| handle และชนิดของ widget ที่ทำงานอยู่ทุกตัว — เป็น backend ของ ui.list() | |
| lv_obj_t * | ui_widget_mgr_get_parent (void) |
| parent ปัจจุบันที่เป็น null ได้; ทุก call site ตรวจ null ของค่านี้ | |
| void | ui_widget_mgr_set_screen (int16_t width, int16_t height) |
| ตั้งขนาดหน้าจอและรีเซ็ตกริดของ auto-layout | |
| int | ui_widget_mgr_chart_add_series (int handle, uint32_t color) |
| เพิ่มชุดข้อมูลให้ Chart; คืนดัชนี 0-3 หรือ -1 | |
| void | ui_widget_mgr_chart_set_next (int handle, uint8_t series_idx, int32_t value) |
| ต่อค่าถัดไปเข้าไปในชุดข้อมูลของ chart ชุดหนึ่ง | |
| int | ui_widget_mgr_item_add (const ipc_ui_item_add_t *it) |
| ต่อรายการหนึ่งรายการ; ค่าที่คืนมีหลายความหมาย และมีกฎเรื่องตัวโค้ดที่ทำงานจริง 2 ชุด | |
| void | ui_widget_mgr_item_clear (int handle) |
| ล้าง widget ชนิดคอลเล็กชันให้ว่าง | |
| void | ui_widget_mgr_set_prop (int handle, uint8_t prop_id, int32_t value) |
| ตั้งคุณสมบัติ UI_PROP_* หนึ่งรายการ; เป็นกลไกที่ .listen() ใช้สมัครรับ event | |
| lv_obj_t * | ui_widget_mgr_get_object (int handle) |
| อ็อบเจ็กต์ LVGL ที่อยู่หลัง handle; เป็นเส้นทาง GET_TEXT สำหรับข้อความที่ผู้ใช้พิมพ์ | |
Header: ui_widget_mgr.h ตัวโค้ดที่ทำงานจริง: ui_widget_mgr.c ที่อยู่ใน archive (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)
อ่านย่อหน้านี้ก่อน — ว่าใครเป็นผู้เรียกฟังก์ชันเหล่านี้จริง ๆ ฟังก์ชันพื้นฐานชุดนี้ ไม่ใช่ ส่วนที่แอปพลิเคชันภาษา C เรียกใช้ ภายใน archive ผู้เรียกเพียงรายเดียวของพวกมันคือ IPC command switch process_ui_command() ใน ipc_ui.c (นิยามอยู่ที่ :393 และถูกระบายคิวจาก LVGL timer 50 ms ที่ :875) ผู้เรียกจริงคือสคริปต์ MicroPython บน CM33_NS: การเรียก ui.* แต่ละครั้งใน modui.c จะแพ็ก payload ส่งผ่าน pipe แล้ว switch ด้านล่างจึงแกะออกมาและเรียกฟังก์ชันพื้นฐานหนึ่งตัว การเขียนเอกสารว่า "call this from your page code" จะบิดเบือนสถาปัตยกรรม — หน้า (page) ที่เรียก ui_widget_mgr_create() โดยตรงคือการข้ามเจ้าของ handle table ไป และจะเกิด race condition กับ CLEAR_ALL ของสคริปต์ตัวถัดไป
แต่ละรายการจึงให้ข้อมูล 3 อย่าง: จุด dispatch ใน switch ที่ปักหมุดไว้ (ป้าย case และบรรทัดที่เรียก อ่านจากซอร์สในรอบสกัดจุดปักหมุด) ส่วนที่เรียกใช้ได้ฝั่ง MicroPython ui.* ที่เข้าถึงมัน และข้อกำหนดการเรียกใช้ มีสี่ case — CREATE, DELETE, SET_TEXT, SET_VALUE — ที่ทำซ้ำไว้แบบคัดมาตามตัวอักษรในข้อความตัดตอน (excerpt) Tier-2 ส่วน case ที่เหลือจงใจไม่ทำซ้ำ (เพื่อจำกัดการเปิดเผย) และอ้างถึงเป็นข้อความแทน ฟังก์ชันพื้นฐาน 2 ตัวถูกเรียกจากนอก switch (init โดย ipc_ui_init() และ set_parent โดย ipc_ui_set_container()) อีก 2 ตัวไม่มีผู้เรียกที่ใดเลย (count, needs_container) และอีก 2 ตัวถูกเรียกจากหน้า (page) Playground ของเทมเพลตเอง (clear_all, set_all_visible)
| void ui_widget_mgr_init | ( | lv_obj_t * | parent | ) |
ipc_ui_init() เรียกฟังก์ชันนี้เอง — ห้ามเรียกโดยตรง
Initialize the widget manager.
| parent | The LVGL parent object (UX/UI tab scrollable container). |
ipc_ui_init() เรียกฟังก์ชันนี้เองเป็นคำสั่งแรกของตน (ipc_ui.c:890 ภายใน ipc_ui_init() ที่ :885) — ห้ามเรียกโดยตรง ไม่ใช่ case หนึ่งใน switch รับ NULL ของ deferred binding (การผูกแบบเลื่อนเวลา) ตอนบูต ส่วน parent ตัวจริงนั้นหน้า (page) จะจัดหาให้ภายหลังผ่าน ipc_ui_set_container() ipc_ui.c:890 — ui_widget_mgr_init(parent); ใต้คอมเมนต์ "Initialize widget manager with parent container" | void ui_widget_mgr_set_parent | ( | lv_obj_t * | parent | ) |
เคลียร์ widget ทั้งหมดแล้วตั้ง parent ใหม่; ถูกเรียกผ่าน 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) ให้ส่ง NULL เข้ามาเพื่อทำให้เป็นโมฆะ ผู้เรียกเพียงรายเดียวคือ ipc_ui_set_container() (ipc_ui.c:918-921) — เป็นการนำทางตามหน้า (page) ไม่ใช่ dispatch switch การทบทวนการออกแบบครั้งหนึ่งบันทึกการแก้ไขนี้ไว้: ข้อความเหมารวมว่า "sole caller is the IPC command switch" นั้นผิดสำหรับแถวนี้แถวเดียว ผู้ใช้ไลบรารี (consumer) เรียก ipc_ui_set_container() ห้ามเรียกฟังก์ชันนี้ ทำงานใน GFX-task context คืนค่า void ipc_ui.c:920 — เนื้อทั้งหมดของ ipc_ui_set_container() คือ ui_widget_mgr_set_parent(parent);. ส่วน call site ของ wrapper ตัวนั้นในเทมเพลตอยู่ที่ container ของ UI | bool ui_widget_mgr_needs_container | ( | void | ) |
คืน true ขณะที่ parent เป็น NULL; ไม่มีผู้เรียกที่ใดเลย
Check if the widget manager has no parent container.
NULL — คือช่วงระหว่าง ipc_ui_set_container(NULL) ตอนทำลายหน้า (page) กับการผูกของหน้าถัดไป กล่าวคือช่วงที่ CREATE จะล้มเหลว ไม่มีผู้เรียกที่ใดเลย ตัวอย่างที่เขียนขึ้นเองโยงฟังก์ชันนี้เข้ากับข้อกำหนดของ deferred binding: หน้า (page) ที่ต้องการทราบว่า widget ของสคริปต์วางลงได้แล้วหรือยัง ให้ถามฟังก์ชันนี้ ใน GFX-task context | int ui_widget_mgr_create | ( | const ipc_ui_create_t * | cfg | ) |
สร้าง widget จาก config; คืน handle 0-31, -1 เมื่อตารางเต็ม, -2 เมื่อชนิดไม่ถูกต้อง
Create a widget from IPC CREATE payload.
| cfg | Parsed CREATE payload. |
-1 เมื่อตารางเต็ม และ -2 เมื่อชนิดไม่ถูกต้อง switch จับค่าเหล่านั้นให้เป็น UI_STATUS_OK / UI_STATUS_TABLE_FULL / UI_STATUS_INVALID_TYPE ในคำตอบแบบสองทาง ตั้ง fast drain ให้พร้อมทำงาน (ui_arm_fast_mode()) และเมื่อ CREATE ครั้งแรก จะซ่อน container ไว้จนกว่า POLL_EVENTS หรือการหมดเวลาจะเปิดให้เห็นอีกครั้ง (เพื่อให้การสร้างเป็นชุดรวดปรากฏขึ้นพร้อมกันทีเดียว) ทำงานใน GFX-task context ui.Button(...), ui.Label(...), ui.Slider(...), ui.Chart(...) และตัวอื่นที่เหลือในตารางคลาส ui (modui.c:1226, แบบสองทาง) ipc_ui.c:420 case IPC_CMD_UI_CREATE: / :422 int handle = ui_widget_mgr_create(cfg); — ทำซ้ำไว้ในข้อความตัดตอนที่เป็นตัวแทนที่ Widget manager (IPC dispatch) | int ui_widget_mgr_create_sprite | ( | const lv_image_dsc_t * | dsc, |
| int16_t | x, | ||
| int16_t | y ) |
สร้าง sprite ชนิดภาพลงใน 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 เมื่อตารางเต็ม, -2 เมื่อไม่ถูกต้องหรือไม่มี sprite engine — กรณีหลังคือสิ่งที่ค่าปริยายชนิด weak ของ game_sprite_create ให้ออกมา (ดู Weak hook (ให้นิยามเอง ห้ามเรียก)) ทำงานใน GFX-task context ui.sprite(id, x, y) (modui.c:1731, แบบสองทาง) 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 ) |
สลับภาพของ sprite; descriptor มาจาก game_sprite_lookup()
Swap a sprite's image (directional head, enemy kind, explosion frame). No-op on invalid handle or NULL descriptor.
NULL ตัว descriptor มาจาก game_sprite_lookup() ที่โปรเจกต์เขียนทับไว้ ซึ่งถูกเรียกก่อนหน้าหนึ่งบรรทัดใน switch ทำงานใน GFX-task context w.frame(sprite_id) บน handle ของ sprite (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 | ) |
ลบ widget หนึ่งตัวและปล่อย 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); — ทำซ้ำไว้ในข้อความตัดตอนที่เป็นตัวแทนที่ Widget manager (IPC dispatch) | void ui_widget_mgr_clear_all | ( | void | ) |
ลบ widget ทุกตัวและรีเซ็ต handle table
Delete all widgets and reset the handle table.
CLEAR_ALL ของ switch (เมื่อมีสคริปต์ใหม่) และหน้า (page) Playground ของเทมเพลต ซึ่งเรียกจาก LVGL callback ชนิด LV_EVENT_CLICKED — ทำงานใน GFX-task context ในหน้านั้น widget ถูกรื้อทิ้ง ก่อนที่คำสั่ง restart ทาง IPC จะถูกส่งออกไป CM33_NS จึงดัน widget ใหม่เข้าไปในตารางที่เคลียร์ไปได้ครึ่งเดียวไม่ได้ คืนค่า void ไม่มีเส้นทางแจ้งข้อผิดพลาด รูปแบบที่ทำลายข้อมูลที่ page_playground.c:105 จะเคลียร์ ส่ง IPC_CMD_DELETE_MAIN_PY แล้วรีเซ็ต MCU ui.clear() (modui.c:1553) และยังถูกสั่งโดย ui.program() กับเส้นทาง deploy ของ IDE ด้วย (:1641, :1975) ipc_ui.c:553 case IPC_CMD_UI_CLEAR_ALL: / :554 ui_widget_mgr_clear_all(); ตามด้วยการรีเซ็ต auto-navigate | void ui_widget_mgr_set_text | ( | int | handle, |
| const char * | text ) |
ตั้งข้อความของ widget; switch จะตั้ง fast drain ให้พร้อมทำงานหลังจากนั้น
Set text on a widget.
w.text("...") (modui.c:396 และ :527 กับ :1261 สำหรับข้อความตอนสร้าง) ให้สังเกตขีดจำกัดของ payload ที่ 95 ไบต์สำหรับตัวสร้าง และ 126 ไบต์สำหรับ .text() ซึ่งบังคับใช้ที่ฝั่ง CM33_NS ipc_ui.c:459 case IPC_CMD_UI_SET_TEXT: / :462 ui_widget_mgr_set_text(handle, text); + :463 ui_arm_fast_mode(); — ทำซ้ำไว้ในข้อความตัดตอนที่เป็นตัวแทนที่ Widget manager (IPC dispatch) | void ui_widget_mgr_set_value | ( | int | handle, |
| int32_t | value ) |
ตั้งค่าตัวเลข; ตั้ง fast drain ให้พร้อมทำงานเพื่อไม่ให้แดชบอร์ดถูกตรึงไว้ที่ 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); — ทำซ้ำไว้ในข้อความตัดตอนที่เป็นตัวแทนที่ Widget manager (IPC dispatch) | void ui_widget_mgr_set_position | ( | int | handle, |
| int16_t | x, | ||
| int16_t | y ) |
ย้ายตำแหน่ง widget; ตั้ง fast drain ให้พร้อมทำงานเพื่ออัตราเฟรมระหว่างเล่นเกม
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 ) |
เปลี่ยนขนาดของ 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 ) |
ตั้งสีหลัก 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 ) |
แสดงหรือซ่อน 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 | ) |
แสดงหรือซ่อน widget ที่จัดการอยู่ทุกตัว; เป็นตัวสลับมุมมองของการสลับคอนโซลบนหน้า Playground
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 | ) |
อ่านค่าปัจจุบันของ widget; ค่า 0 หมายถึง handle ไม่ถูกต้องได้ด้วย
Get current value of a widget.
w.value() ที่ไม่ใส่อาร์กิวเมนต์ (modui.c:409, แบบสองทาง) 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 ) |
โหลดบิตแมปเข้าไปใน widget ชนิด DotMatrix
Set dot matrix bitmap data.
DotMatrix โดยข้อมูล len ไบต์ตามหลัง handle อยู่ใน payload ทำงานใน GFX-task context w.set_pixels(bytes) บน 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 ) |
การส่ง RGB565 เป็นก้อน ๆ เข้าไปใน canvas ของ widget ชนิด Image
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 : offset คือระยะเยื้องเป็นไบต์ในบัฟเฟอร์พิกเซล ส่วน len คือความยาวของก้อนข้อมูล handle ต้องเป็น UI_WIDGET_IMAGE ฝั่งสคริปต์วนส่งก้อนข้อมูลที่ใหญ่ไม่เกินงบของ payload ทำงานใน GFX-task context w.set_image(data) บน ui.Image (modui.c:558 หนึ่งข้อความ IPC ต่อหนึ่งก้อนข้อมูล) 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 ) |
ฝั่งผู้ผลิตข้อมูลของ event ring; เฉพาะ LVGL event callback ภายในเท่านั้น
Push an event into the ring buffer (called from LVGL event callbacks).
ui_widget_mgr_event_drain() ถูกเรียกจาก LVGL event callback ภายใน widget manager ที่อยู่ใน archive — มี 2 จุด และทั้งสองเป็นจุดภายใน: widget event callback ตัวทั่วไป (ui_widget_mgr.c:333 มีตัวกัน if (event_type != 0)) และ input event callback สำหรับ input event ทั้ง 12 แบบ (:406) ซึ่งจะตรวจ mask การสมัครรับประจำ widget ก่อน (s_widget_event_mask[handle] & UI_EVENT_MASK(event_type)) แล้วคืนกลับโดยไม่ผลักข้อมูลเข้าคิว เมื่อสคริปต์ไม่ได้ .listen() event นั้นไว้ ที่นี่ยังเป็นจุดที่มีการเรียก ipc_ui_input_activity() ด้วย ทำงานใน GFX-task context w.listen("pressed", cb) และ w.bind(...) เป็นตัวตั้ง mask ที่ยอมให้การผลักข้อมูลผ่านเข้ามา ส่วน ui.poll() เป็นตัวระบายคิว BENTO-TESAIoT-libraries/claw/common/modules/ipc_ui/ui_widget_mgr.c:333 และ :406 (คอมไพล์รวมอยู่ใน archive ที่สร้างไว้ล่วงหน้า ไม่ได้ส่งมอบมาเป็นซอร์ส) — ปักหมุดไว้ ไม่ได้ทำซ้ำ | int ui_widget_mgr_event_drain | ( | ipc_ui_event_t * | out, |
| int | max_events ) |
ระบาย event ออกให้ POLL_EVENTS — เป็น backend ของ ui.poll()
Drain events from the ring buffer.
| out | Output array. |
| max_events | Maximum events to drain. |
max_events รายการลงในอาร์เรย์ที่ผู้เรียกเป็นเจ้าของ แล้วคืนค่าเป็นจำนวนที่ระบายได้ switch ตอบ POLL_EVENTS ด้วยไบต์ชุดนั้นพอดี case เดียวกันนี้ยังเปิดให้เห็น container ที่ถูกซ่อนไว้จาก CREATE ครั้งแรกด้วย — ผ่าน ui_widget_mgr_get_parent() ที่ตรวจ null แล้ว — เพื่อให้ widget ของสคริปต์ปรากฏขึ้นพร้อมกันทีเดียว ทำงานใน GFX-task context ui.poll() (modui.c:1324, แบบสองทาง) — เป็นการเรียกที่ทุก event loop ต้องทำ callback ของ .listen() ถูกเรียกจากผลลัพธ์ของมัน 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 | ) |
จำนวน handle ที่ยังใช้งานอยู่; ไม่มีผู้เรียกเลยที่ใด
Get current widget count.
ui_widget_mgr.h:142) กับการนิยามอีก 3 แห่ง — ไม่มีผู้เรียกเลย ตัวอย่างที่เขียนขึ้นเองอ่านค่านี้ใน GFX-task context หลัง clear_all() ในฐานะข้อยืนยันตอนรื้อถอน ส่วนการอ่านจำนวนจาก task อื่นจะเกิด race condition กับเส้นทาง dispatch ui.list() ใช้ ui_widget_mgr_list() ไม่ใช่ฟังก์ชันนี้) | int ui_widget_mgr_list | ( | ipc_ui_widget_info_t * | out, |
| int | max_items ) |
handle และชนิดของ widget ที่ทำงานอยู่ทุกตัว — เป็น backend ของ ui.list()
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 ใน switch) แล้วคืนค่าเป็นจำนวนที่เขียนได้ ทำงานใน GFX-task context ui.list() (modui.c:1432, แบบสองทาง) และ ui.get(id) (:1519) รวมถึงการ re-sync ภายในที่ modui.c:138-153 และ :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 | ) |
parent ปัจจุบันที่เป็น null ได้; ทุก call site ตรวจ null ของค่านี้
Get the current parent container object.
NULL เมื่อใดก็ตามที่ยังไม่มีหน้า (page) ใดผูก container ไว้ คือช่วงระหว่าง ipc_ui_set_container(NULL) ตอนทำลาย กับการผูกของหน้าถัดไป ตัวกัน 3 บรรทัดชุดเดียวกันนี้ปรากฏซ้ำที่ ipc_ui.c:443 (ซ่อนตอน CREATE ครั้งแรก) :519 (เปิดให้เห็นตอน POLL_EVENTS) :560 และ :859 (การเปิดให้เห็นเมื่อหมดเวลานิรภัย ในกรณีที่ POLL_EVENTS ไม่มาเลย) ทำงานใน GFX-task context | void ui_widget_mgr_set_screen | ( | int16_t | width, |
| int16_t | height ) |
ตั้งขนาดหน้าจอและรีเซ็ตกริดของ auto-layout
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 สงวนไว้) ทำงานใน 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 ) |
เพิ่มชุดข้อมูลให้ Chart; คืนดัชนี 0-3 หรือ -1
Add a series to a chart widget.
| handle | Widget handle (must be UI_WIDGET_CHART). |
| color | Series color (0xRRGGBB). |
Chart แล้วคืนค่าดัชนีของชุดข้อมูลเป็น 0-3 หรือ -1 ตัว handle ต้องเป็น UI_WIDGET_CHART เป็นแบบสองทางเพื่อให้สคริปต์ทราบดัชนี ทำงานใน GFX-task context w.add_series(color) บน ui.Chart (modui.c:605, แบบสองทาง) 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 ) |
ต่อค่าถัดไปเข้าไปในชุดข้อมูลของ chart ชุดหนึ่ง
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 | ) |
ต่อรายการหนึ่งรายการ; ค่าที่คืนมีหลายความหมาย และมีกฎเรื่องตัวโค้ดที่ทำงานจริง 2 ชุด
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 คือ handle ของหน้า (page) ลูกที่ container สร้างขึ้น (Tabview / Tileview / Win); UI_ITEM_ADD_OK_NO_CHILD (-3) หมายความว่ารายการถูกต่อเข้าไปแล้วโดยไม่มีอ็อบเจ็กต์ลูก; -1 คือตารางเต็ม; -2 คือ handle ไม่ถูกต้อง ชนิดผิด หรือเพิ่มรายการนั้นไม่ได้ คอมเมนต์แบบบล็อกใน header มีผลผูกพัน: ฟังก์ชันนี้ "MUST exist, and behave the same way for the same widget type, in BOTH ui_widget_mgr.c implementations — claw's and game's" เพราะชุดคิต Game คอมไพล์ ipc_ui.c ของ claw เข้ากับ widget manager ของ game และชนิดที่ฝ่ายหนึ่งรองรับแต่อีกฝ่ายไม่รองรับจะคืนค่า UI_STATUS_INVALID_TYPE บนบอร์ดบางรุ่น โดยไม่มีข้อผิดพลาดตอน build ที่ใดเลย ทำงานใน 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 แบบสองทางสำหรับรูปที่เป็น container) 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 | ) |
ล้าง 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 ) |
ตั้งคุณสมบัติ UI_PROP_* หนึ่งรายการ; เป็นกลไกที่ .listen() ใช้สมัครรับ event
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_*) มีสองคุณสมบัติที่บรรจุคู่ hi16/lo16 ไว้ใน value ใช้กฎเรื่องตัวโค้ดที่ทำงานจริง 2 ชุดเดียวกันกับ item_add คุณสมบัติ UI_PROP_EVENT_MASK คือกลไกที่ .listen() ใช้สมัครให้ widget รับ input event ทำงานใน GFX-task context w.prop(ui.PROP_*, value) และตัวช่วยที่มีชื่อเฉพาะ 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 ที่อยู่หลัง handle; เป็นเส้นทาง GET_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 เมื่อช่องนั้นว่าง มีข้อเท็จจริง 2 ข้อ ทั้งคู่เป็นจริงและต้องอ่านคู่กัน: header ระบุว่า "Nothing on the device calls it — it exists so a host harness can drive an object the way a finger would" และรอบสกัดจุดปักหมุดพบว่ามันถูก dispatch จาก handler ของ GET_TEXT ที่ ipc_ui.c:606 — ไม่ใช่จาก opcode GET_OBJECT — ซึ่งเป็นจุดที่อ็อบเจ็กต์นั้นถูกใช้อ่านข้อความที่ผู้ใช้พิมพ์ลงใน textarea คอมเมนต์ของ handler เองบรรยายเส้นทางนั้นว่าเป็น "the only route by which anything a user TYPED reaches MicroPython" (ipc_ui.c:595-596) ทำงานใน GFX-task context w.text() ที่ไม่ใส่อาร์กิวเมนต์ (modui.c:366, แบบสองทาง) บน ui.Textarea หรือ widget ที่มีคีย์บอร์ดรองรับ ipc_ui.c:594 case IPC_CMD_UI_GET_TEXT: / :606 lv_obj_t *obj = ui_widget_mgr_get_object((int)handle);.