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

Method lateStart

Devices/m5stack-tab5/Source/devices/Tab5Keyboard.cpp:413–441  ·  view source on GitHub ↗

--------------------------------------------------------------------------- lateStart - see header comment. Brings up LVGL input handling for a keyboard that wasn't attached at boot (startLvgl() wasn't called from attachDevices()). ---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

411// that wasn't attached at boot (startLvgl() wasn't called from attachDevices()).
412// ---------------------------------------------------------------------------
413bool Tab5Keyboard::lateStart() {
414 if (kbHandle != nullptr) {
415 return true; // already started
416 }
417
418 auto* display = lv_display_get_default();
419 if (display == nullptr) {
420 return false; // LVGL not ready yet
421 }
422
423 if (!tt::lvgl::lock(pdMS_TO_TICKS(100))) {
424 return false; // try again on the next attach-state check
425 }
426
427 bool started = startLvgl(display);
428 if (started) {
429 tt::lvgl::hardware_keyboard_set_indev(kbHandle);
430
431 // redraw() assigns every indev that exists at the time to the active screen's
432 // input group. This indev didn't exist yet at the last redraw(), so it has no
433 // group and won't deliver key events until the next app switch. Join the
434 // current default group now so input works immediately on the visible screen.
435 lv_indev_set_group(kbHandle, lv_group_get_default());
436 }
437
438 tt::lvgl::unlock();
439
440 return started;
441}
442
443// ---------------------------------------------------------------------------
444// LVGL read callback - called from the LVGL task

Callers 1

keyboardDetectCallbackFunction · 0.80

Calls 3

lockFunction · 0.50
unlockFunction · 0.50

Tested by

no test coverage detected