MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / guiMain

Method guiMain

Tactility/Source/service/gui/GuiService.cpp:41–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41int32_t GuiService::guiMain() {
42 auto service = findServiceById<GuiService>(manifest.id);
43
44 if (!lvgl::lock(5000)) {
45 LOGGER.error("LVGL guiMain start failed as LVGL couldn't be locked");
46 return 0;
47 }
48
49 // The screen root is created in the main task instead of during onStart because
50 // it allows onStart() to succeed faster and allows widget creation to happen in the background
51
52 auto* screen_root = lv_screen_active();
53 if (screen_root == nullptr) {
54 LOGGER.error("No display found, exiting GUI task");
55 lvgl::unlock();
56 return 0;
57 }
58
59 service->keyboardGroup = lv_group_create();
60 lv_obj_set_style_border_width(screen_root, 0, LV_STATE_DEFAULT);
61 lv_obj_set_style_pad_all(screen_root, 0, LV_STATE_DEFAULT);
62
63 lv_obj_t* vertical_container = lv_obj_create(screen_root);
64 lv_obj_set_size(vertical_container, LV_PCT(100), LV_PCT(100));
65 lv_obj_set_flex_flow(vertical_container, LV_FLEX_FLOW_COLUMN);
66 lv_obj_set_style_pad_all(vertical_container, 0, LV_STATE_DEFAULT);
67 lv_obj_set_style_pad_gap(vertical_container, 0, LV_STATE_DEFAULT);
68 lv_obj_set_style_bg_color(vertical_container, lv_color_black(), LV_STATE_DEFAULT);
69 lv_obj_set_style_border_width(vertical_container, 0, LV_STATE_DEFAULT);
70 lv_obj_set_style_radius(vertical_container, 0, LV_STATE_DEFAULT);
71
72 service->statusbarWidget = lvgl::statusbar_create(vertical_container);
73
74 auto* app_container = lv_obj_create(vertical_container);
75 lv_obj_set_style_pad_all(app_container, 0, LV_STATE_DEFAULT);
76 lv_obj_set_style_border_width(app_container, 0, LV_STATE_DEFAULT);
77 lv_obj_set_width(app_container, LV_PCT(100));
78 lv_obj_set_flex_grow(app_container, 1);
79 lv_obj_set_flex_flow(app_container, LV_FLEX_FLOW_COLUMN);
80
81 service->appRootWidget = app_container;
82
83 lvgl::unlock();
84
85 while (true) {
86 uint32_t flags = 0;
87 if (service->threadFlags.wait(GUI_THREAD_FLAG_ALL, false, true, &flags, portMAX_DELAY)) {
88 // When service not started or starting -> exit
89 State service_state = getState(manifest.id);
90 if (service_state != State::Started && service_state != State::Starting) {
91 break;
92 }
93
94 // Process and dispatch draw call
95 if (flags & GUI_THREAD_FLAG_DRAW) {
96 service->threadFlags.clear(GUI_THREAD_FLAG_DRAW);
97 service->redraw();
98 }

Callers

nothing calls this directly

Calls 8

statusbar_createFunction · 0.85
getStateFunction · 0.85
errorMethod · 0.80
waitMethod · 0.80
clearMethod · 0.80
redrawMethod · 0.80
lockFunction · 0.50
unlockFunction · 0.50

Tested by

no test coverage detected