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:
30
inc/events/settings_mode_event.h
Normal file
30
inc/events/settings_mode_event.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef BLINKY_SETTINGS_MODE_EVENT_H_
|
||||
#define BLINKY_SETTINGS_MODE_EVENT_H_
|
||||
|
||||
#include <app_event_manager.h>
|
||||
#include <app_event_manager_profiler_tracer.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct settings_mode_event {
|
||||
struct app_event_header header;
|
||||
bool active;
|
||||
};
|
||||
|
||||
APP_EVENT_TYPE_DECLARE(settings_mode_event);
|
||||
|
||||
static inline void submit_settings_mode_event(bool active)
|
||||
{
|
||||
struct settings_mode_event *event = new_settings_mode_event();
|
||||
|
||||
event->active = active;
|
||||
APP_EVENT_SUBMIT(event);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLINKY_SETTINGS_MODE_EVENT_H_ */
|
||||
40
inc/events/settings_view_event.h
Normal file
40
inc/events/settings_view_event.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef BLINKY_SETTINGS_VIEW_EVENT_H_
|
||||
#define BLINKY_SETTINGS_VIEW_EVENT_H_
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <app_event_manager.h>
|
||||
#include <app_event_manager_profiler_tracer.h>
|
||||
|
||||
#include "settings_ui.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct settings_view_event {
|
||||
struct app_event_header header;
|
||||
struct settings_ui_state state;
|
||||
};
|
||||
|
||||
APP_EVENT_TYPE_DECLARE(settings_view_event);
|
||||
|
||||
static inline void submit_settings_view_event(
|
||||
const struct settings_ui_state *state)
|
||||
{
|
||||
struct settings_view_event *event;
|
||||
|
||||
if (state == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
event = new_settings_view_event();
|
||||
memcpy(&event->state, state, sizeof(event->state));
|
||||
APP_EVENT_SUBMIT(event);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLINKY_SETTINGS_VIEW_EVENT_H_ */
|
||||
56
inc/settings_ui.h
Normal file
56
inc/settings_ui.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef BLINKY_SETTINGS_UI_H_
|
||||
#define BLINKY_SETTINGS_UI_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "theme_color.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SETTINGS_UI_ROOT_ITEM_COUNT 2U
|
||||
#define SETTINGS_UI_BLE_SLOT_COUNT 3U
|
||||
#define SETTINGS_UI_BLE_ITEM_COUNT 4U
|
||||
#define SETTINGS_UI_THEME_OPTION_COUNT 6U
|
||||
#define SETTINGS_UI_TITLE_MAX 20U
|
||||
#define SETTINGS_UI_VALUE_MAX 24U
|
||||
#define SETTINGS_UI_THEME_NAME_MAX 16U
|
||||
|
||||
enum settings_ui_page {
|
||||
SETTINGS_UI_PAGE_ROOT = 0,
|
||||
SETTINGS_UI_PAGE_BLE,
|
||||
SETTINGS_UI_PAGE_THEME,
|
||||
};
|
||||
|
||||
struct settings_ui_list_item {
|
||||
char title[SETTINGS_UI_TITLE_MAX];
|
||||
char value[SETTINGS_UI_VALUE_MAX];
|
||||
};
|
||||
|
||||
struct settings_ui_theme_option {
|
||||
char name[SETTINGS_UI_THEME_NAME_MAX];
|
||||
struct theme_rgb color;
|
||||
};
|
||||
|
||||
struct settings_ui_state {
|
||||
bool active;
|
||||
enum settings_ui_page page;
|
||||
uint8_t root_selected;
|
||||
uint8_t ble_selected;
|
||||
uint8_t theme_selected;
|
||||
uint8_t active_ble_slot;
|
||||
struct theme_rgb accent;
|
||||
struct settings_ui_list_item root_items[SETTINGS_UI_ROOT_ITEM_COUNT];
|
||||
struct settings_ui_list_item ble_items[SETTINGS_UI_BLE_ITEM_COUNT];
|
||||
struct settings_ui_theme_option
|
||||
theme_options[SETTINGS_UI_THEME_OPTION_COUNT];
|
||||
uint8_t theme_option_count;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLINKY_SETTINGS_UI_H_ */
|
||||
Reference in New Issue
Block a user