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

Method onShow

Tactility/Source/app/boot/Boot.cpp:198–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196 }
197
198 void onShow(AppContext& app, lv_obj_t* parent) override {
199 lvgl::obj_set_style_bg_blacken(parent);
200 lv_obj_set_style_border_width(parent, 0, LV_STATE_DEFAULT);
201 lv_obj_set_style_radius(parent, 0, LV_STATE_DEFAULT);
202
203 auto* image = lv_image_create(parent);
204 lv_obj_set_size(image, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
205 lv_obj_align(image, LV_ALIGN_CENTER, 0, 0);
206
207 const auto paths = app.getPaths();
208 const char* logo;
209 // TODO: Replace with automatic asset buckets like on Android
210 if (getSmallestDimension() < 150) { // e.g. Cardputer
211 logo = isUsbBootSplash ? "logo_usb.png" : "logo_small.png";
212 } else {
213 logo = isUsbBootSplash ? "logo_usb.png" : "logo.png";
214 }
215 const auto logo_path = lvgl::PATH_PREFIX + paths->getAssetsPath(logo);
216 LOGGER.info("{}", logo_path);
217 lv_image_set_src(image, logo_path.c_str());
218
219#ifdef ESP_PLATFORM
220 if (isUsbBootSplash) {
221 auto* button = lv_button_create(parent);
222 lv_obj_align(button, LV_ALIGN_BOTTOM_MID, 0, -16);
223 auto* label = lv_label_create(button);
224 lv_label_set_text(label, "Return to OS");
225 lv_obj_add_event_cb(button, [](lv_event_t*) {
226 hal::usb::stop();
227 esp_restart();
228 }, LV_EVENT_SHORT_CLICKED, nullptr);
229 }
230#endif
231 }
232};
233
234std::atomic<bool> BootApp::isUsbBootSplash = false;

Callers

nothing calls this directly

Calls 5

obj_set_style_bg_blackenFunction · 0.85
infoMethod · 0.80
stopFunction · 0.50
getPathsMethod · 0.45
getAssetsPathMethod · 0.45

Tested by

no test coverage detected