feat: 添加设置模块和相关UI功能
- 新增settings_module.c实现设置菜单逻辑,包括蓝牙配对槽位管理和主题颜色选择 - 添加settings_mode_event.h/.c和settings_view_event.h/.c事件定义用于设置模式切换 - 创建settings_ui.h定义设置界面状态结构体和页面枚举 - 修改display_module.c集成设置UI显示逻辑,支持主界面和设置界面切换 - 在keyboard_core_module.c中添加设置活动状态检查,避免设置模式下键盘输入冲突 - 更新CMakeLists.txt包含新的源文件:settings_module.c、ui_settings.c及新事件文件 - 修改prj.conf调整LVGL内存池大小从16KB到32KB以支持更复杂UI渲染 - 移除BLE配对擦除相关配置选项并增加长按检测时间到1500毫秒 - 更新ui_main.c添加可见性控制函数用于界面切换
This commit is contained in:
@@ -19,6 +19,7 @@ enum {
|
||||
};
|
||||
|
||||
struct ui_main_ctx {
|
||||
lv_obj_t *content;
|
||||
lv_obj_t *status_badges[UI_STATUS_COUNT];
|
||||
lv_obj_t *status_labels[UI_STATUS_COUNT];
|
||||
lv_obj_t *battery_icon;
|
||||
@@ -116,6 +117,10 @@ static void ui_main_create_status_chip(lv_obj_t *parent, enum ui_status_id id)
|
||||
|
||||
void ui_main_refresh_status_bar(const struct ui_main_model *model)
|
||||
{
|
||||
if (!ui_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < UI_STATUS_COUNT; i++) {
|
||||
lv_obj_t *badge = g_ui.status_badges[i];
|
||||
lv_obj_t *label = g_ui.status_labels[i];
|
||||
@@ -145,7 +150,8 @@ void ui_main_refresh_battery(const struct ui_main_model *model)
|
||||
lv_color_t battery_color;
|
||||
lv_color_t state_color = lv_color_white();
|
||||
|
||||
if ((g_ui.battery_icon == NULL) || (g_ui.battery_label == NULL) ||
|
||||
if (!ui_initialized ||
|
||||
(g_ui.battery_icon == NULL) || (g_ui.battery_label == NULL) ||
|
||||
(g_ui.battery_state_label == NULL)) {
|
||||
return;
|
||||
}
|
||||
@@ -171,7 +177,8 @@ void ui_main_refresh_battery(const struct ui_main_model *model)
|
||||
|
||||
void ui_main_refresh_datetime(const char *date_text, const char *time_text)
|
||||
{
|
||||
if ((g_ui.date_label == NULL) || (g_ui.time_label == NULL)) {
|
||||
if (!ui_initialized ||
|
||||
(g_ui.date_label == NULL) || (g_ui.time_label == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -200,6 +207,7 @@ void ui_main_init(const struct ui_main_model *model,
|
||||
lv_obj_t *bottom_row;
|
||||
|
||||
if (ui_initialized) {
|
||||
ui_main_refresh_all(model, date_text, time_text);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -213,6 +221,7 @@ void ui_main_init(const struct ui_main_model *model,
|
||||
lv_obj_set_scrollbar_mode(screen, LV_SCROLLBAR_MODE_OFF);
|
||||
|
||||
content = lv_obj_create(screen);
|
||||
g_ui.content = content;
|
||||
lv_obj_remove_style_all(content);
|
||||
lv_obj_set_size(content, LV_PCT(100), LV_PCT(100));
|
||||
lv_obj_set_style_bg_opa(content, LV_OPA_TRANSP, 0);
|
||||
@@ -287,3 +296,16 @@ void ui_main_init(const struct ui_main_model *model,
|
||||
ui_main_refresh_all(model, date_text, time_text);
|
||||
ui_initialized = true;
|
||||
}
|
||||
|
||||
void ui_main_set_visible(bool visible)
|
||||
{
|
||||
if (!ui_initialized || (g_ui.content == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
lv_obj_clear_flag(g_ui.content, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(g_ui.content, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user