Fixes and improvements (#620)
- Standardized keyboard input using Unicode-based key codes across supported devices and the simulator. Keyboards don't emit `LV_KEY_*` anymore. - Refactored lilygo encoder driver into a reusable GPIO rotary encoder driver (see `Drivers/gpio-encoder-module/`). Added more features to the config file. - Improved LVGL keyboard device management, including duplicate prevention and reliable reconnects. - LVGL file mutex now registers with lvgl start/stop - Improved LVGL startup/shutdown stability and memory allocation reliability. - Increased simulator LVGL memory capacity and improved USB device-class handling.
This commit is contained in:
committed by
GitHub
parent
4fea48f433
commit
db48dfe812
@@ -63,21 +63,25 @@ void onKeyboardDeviceStarted(Device* device) {
|
||||
void onKeyboardDeviceStopped(Device* device) {
|
||||
auto lock = bindingsMutex().asScopedLock();
|
||||
lock.lock();
|
||||
lv_indev_t* indev = nullptr;
|
||||
auto& list = bindings();
|
||||
for (auto it = list.begin(); it != list.end(); ++it) {
|
||||
if (it->device == device) {
|
||||
indev = it->indev;
|
||||
list.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (indev == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Not every indev bound to a keyboard device goes through onKeyboardDeviceStarted() and
|
||||
// bindings() above. lvgl_devices_attach() also binds whatever KEYBOARD_TYPE devices are
|
||||
// already started at LVGL startup, before this listener is even registered (see
|
||||
// startKeyboardDeviceListener()'s call site). Look the indev up directly so that path's
|
||||
// devices still get detached before the kernel device is destructed, instead of leaving a
|
||||
// dangling indev that reads a freed device on the next LVGL tick.
|
||||
lvgl_lock();
|
||||
lvgl_keyboard_remove(indev);
|
||||
lv_indev_t* indev = lvgl_keyboard_find_by_device(device);
|
||||
if (indev != nullptr) {
|
||||
lvgl_keyboard_remove(indev);
|
||||
}
|
||||
lvgl_unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -126,11 +126,12 @@ static void statusbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
|
||||
LV_TRACE_OBJ_CREATE("begin");
|
||||
lv_obj_remove_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
|
||||
LV_TRACE_OBJ_CREATE("finished");
|
||||
auto* statusbar = (Statusbar*)obj;
|
||||
statusbar->pubsub_subscription = statusbar_data.pubsub->subscribe([statusbar](auto) {
|
||||
statusbar_pubsub_event(statusbar);
|
||||
});
|
||||
|
||||
// Deliberately does NOT subscribe to statusbar_data.pubsub here - that happens at the end of
|
||||
// statusbar_create(), once statusbar->icons[] is actually populated. Subscribing this early
|
||||
// would let a concurrent statusbar_icon_add()/_remove()/_set_image()/_set_visibility() call
|
||||
// from another task publish and run update_icon() on a still-null icons[] slot before this
|
||||
// instance's own creation loop below has had a chance to fill it in.
|
||||
if (!statusbar_data.time_update_timer->isRunning()) {
|
||||
statusbar_data.time_update_timer->start();
|
||||
system_event_callback_add(KERNEL_EVENT_TIME_CHANGED, onTimeChanged, nullptr);
|
||||
@@ -190,7 +191,16 @@ lv_obj_t* statusbar_create(lv_obj_t* parent) {
|
||||
|
||||
update_icon(image, &(statusbar_data.icons[i]));
|
||||
}
|
||||
// Only now is statusbar->icons[] fully populated - see statusbar_constructor()'s comment for
|
||||
// why the subscription can't be registered any earlier. Subscribing before unlocking (rather
|
||||
// than after) closes a narrow window where a concurrent statusbar_icon_add()/_remove()/
|
||||
// _set_image()/_set_visibility() call could publish - and be missed by this instance - after
|
||||
// the icons are populated but before it's subscribed.
|
||||
statusbar->pubsub_subscription = statusbar_data.pubsub->subscribe([statusbar](auto) {
|
||||
statusbar_pubsub_event(statusbar);
|
||||
});
|
||||
statusbar_data.mutex.unlock();
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user