- 添加新的UI页面基础架构(ui_page.h),包含页面操作接口 - 创建设置页面控制器(ui_settings_controller.h/.c)来管理页面导航 - 实现具体的设置页面类型:根页面、BLE页面、主题页面 - 修改display_module.c以使用新的页面系统替代旧的状态机 - 移除过时的settings_ui.h头文件和相关状态结构 - 更新事件处理逻辑以使用页面指针而非状态数据传递 - 修改主界面实现以适配统一的页面接口标准
65 lines
1.4 KiB
C
65 lines
1.4 KiB
C
#include <lvgl.h>
|
|
|
|
#include <zephyr/sys/util.h>
|
|
|
|
#include "ui/ui_settings_controller.h"
|
|
#include "ui_settings_pages.h"
|
|
|
|
static uint8_t root_get_count(struct ui_settings_page *page)
|
|
{
|
|
ARG_UNUSED(page);
|
|
return 2U;
|
|
}
|
|
|
|
static void root_get_item(struct ui_settings_page *page, uint8_t index,
|
|
struct ui_settings_item *item)
|
|
{
|
|
ARG_UNUSED(page);
|
|
|
|
if (index == 0U) {
|
|
item->icon = LV_SYMBOL_BLUETOOTH;
|
|
item->title = "Bluetooth";
|
|
item->value = ui_settings_ble_current_label();
|
|
return;
|
|
}
|
|
|
|
item->icon = LV_SYMBOL_TINT;
|
|
item->title = "Theme";
|
|
item->value = ui_settings_theme_current_name();
|
|
}
|
|
|
|
static void root_on_enter(struct ui_settings_page *page)
|
|
{
|
|
page->selected = 0U;
|
|
}
|
|
|
|
static void root_on_select(struct ui_settings_page *page, uint8_t index)
|
|
{
|
|
ui_settings_controller_switch_to(
|
|
(index == 0U) ? &ui_settings_ble_page : &ui_settings_theme_page,
|
|
&page->base);
|
|
}
|
|
|
|
static void root_on_back(struct ui_settings_page *page)
|
|
{
|
|
ARG_UNUSED(page);
|
|
ui_settings_controller_close();
|
|
}
|
|
|
|
static const struct ui_settings_page_ops root_ops = {
|
|
.get_count = root_get_count,
|
|
.get_item = root_get_item,
|
|
.on_enter = root_on_enter,
|
|
.on_select = root_on_select,
|
|
.on_back = root_on_back,
|
|
};
|
|
|
|
struct ui_settings_page ui_settings_root_page = {
|
|
.base = {
|
|
.ops = &root_ops.base,
|
|
},
|
|
.ops = &root_ops,
|
|
.title = LV_SYMBOL_SETTINGS " Settings",
|
|
.hint = "Rotate select Tap OK Hold exit",
|
|
};
|