Replace Tactility SystemEvents with new kernel implementation (#598)
TactilityKernel now has a system event API to replace the one from the Tactility subproject. It also implements several tests for it.
This commit is contained in:
committed by
GitHub
parent
6e55e71e67
commit
acb2f1d4c7
@@ -1,7 +1,8 @@
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <tactility/module.h>
|
||||
|
||||
#include <Tactility/SystemEvents.h>
|
||||
#include <tactility/system_event.h>
|
||||
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
|
||||
#include <lilygo/drivers/tpager_encoder_input.h>
|
||||
@@ -10,22 +11,21 @@ constexpr auto* TAG = "T-Lora Pager";
|
||||
|
||||
extern "C" {
|
||||
|
||||
tt::kernel::SystemEventSubscription event_subscription = tt::kernel::NoSystemEventSubscription;
|
||||
static void on_boot_completed(struct SystemEvent* /*event*/, void* /*context*/) {
|
||||
// The kernel tpager_encoder device is already started by kernel_init(); this just
|
||||
// registers it as an LVGL input device, which requires LVGL to be up first.
|
||||
lvgl_lock();
|
||||
tpager_encoder::init();
|
||||
lvgl_unlock();
|
||||
}
|
||||
|
||||
static error_t start() {
|
||||
event_subscription = tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent) {
|
||||
// The kernel tpager_encoder device is already started by kernel_init(); this just
|
||||
// registers it as an LVGL input device, which requires LVGL to be up first.
|
||||
lvgl_lock();
|
||||
tpager_encoder::init();
|
||||
lvgl_unlock();
|
||||
});
|
||||
system_event_subscribe(KERNEL_EVENT_BOOT_COMPLETED, on_boot_completed, nullptr);
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
static error_t stop() {
|
||||
tt::kernel::unsubscribeSystemEvent(event_subscription);
|
||||
event_subscription = tt::kernel::NoSystemEventSubscription;
|
||||
system_event_unsubscribe(KERNEL_EVENT_BOOT_COMPLETED, on_boot_completed);
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user