Refactored events (#621)
Event handling: - Added unified event handling for application, system, and Wi‑Fi events. - Updated all apps to reflect event handling changes Wi-Fi: - Refactored event handling from listener interface to task & event group. - Added direct Wi‑Fi radio controls and improved event subscriptions. - Wi‑Fi screens now refresh asynchronously and handle unavailable devices more gracefully. - Enabled Wi‑Fi by default on in dts files, but radio on/off is still done by code. The main reason was reliable event subscription and consistent devicetree states. - Improved Wi‑Fi shutdown cleanup and radio-state handling. Other: - Renamed the Kernel Display app to Display.
This commit is contained in:
committed by
GitHub
parent
db48dfe812
commit
ab75d2022d
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <lvgl_window_manager/window_manager.h>
|
||||
|
||||
#include <tactility/check.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <lvgl/widgets/toolbar.h>
|
||||
|
||||
@@ -21,24 +23,30 @@ static void create_widgets(lv_obj_t* parent, void* userData) {
|
||||
int main(int argc, char* argv[]) {
|
||||
AppInstanceId app_instance_id = app_scheduler_current_app_id();
|
||||
|
||||
struct AppEventSubscription sub = { .app_instance_id = app_instance_id };
|
||||
app_event_subscribe(&sub);
|
||||
struct TaskEventGroup event_group = {0};
|
||||
task_event_group_construct(&event_group);
|
||||
|
||||
struct AppEventSubscription sub = {0};
|
||||
check(app_event_subscribe(&sub, &event_group) == ERROR_NONE);
|
||||
|
||||
WindowId window = window_manager_create(app_instance_id, create_widgets, NULL);
|
||||
|
||||
bool should_close = false;
|
||||
while (!should_close) {
|
||||
task_event_group_wait_any(&event_group, NULL, portMAX_DELAY);
|
||||
|
||||
struct AppEvent event;
|
||||
if (app_event_await(&sub, &event, portMAX_DELAY) != ERROR_NONE) {
|
||||
break;
|
||||
}
|
||||
if (event.type == APP_EVENT_CLOSE) {
|
||||
should_close = true;
|
||||
while (app_event_poll(&sub, &event) == ERROR_NONE) {
|
||||
if (event.type == APP_EVENT_CLOSE) {
|
||||
should_close = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window_manager_remove(window);
|
||||
app_event_unsubscribe(&sub);
|
||||
check(app_event_unsubscribe(&sub) == ERROR_NONE);
|
||||
task_event_group_destruct(&event_group);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user