feat: 更新键盘固件的事件系统和模块配置
- 在CMakeLists.txt中添加hid_boot_event.c、keyboard_led_event.c和ble_slot_ctrl_module.c源文件 - 新增Kconfig配置项NEW_KBD_BLE_BOND_ENABLE用于启用应用特定的BLE绑定支持 - 修改prj.conf配置,禁用配对模式下的设备名称广播功能 - 重构电池状态事件结构,将charging和full布尔字段改为flags位域,并提供相应的访问函数 - 添加hid_boot_event事件类型,用于处理HID Boot协议输入报告 - 重命名keyboard_led_state_event为keyboard_led_event并改进LED状态处理逻辑 - 移除hid_protocol_event中的transport字段,简化协议事件处理 - 分离hid_report_event和hid_boot_event,明确区分Report和Boot协议报文处理 - 重构battery_module.c代码结构,改用上下文结构体管理电池模块状态 - 更新ble_battery_module.c使用新的电池状态事件访问接口
This commit is contained in:
@@ -10,11 +10,52 @@
|
||||
struct battery_status_event
|
||||
{
|
||||
struct app_event_header header;
|
||||
bool charging;
|
||||
bool full;
|
||||
uint8_t flags;
|
||||
uint8_t soc;
|
||||
};
|
||||
|
||||
#define BATTERY_STATUS_FLAG_CHARGING (1U << 0)
|
||||
#define BATTERY_STATUS_FLAG_FULL (1U << 1)
|
||||
|
||||
#define BATTERY_STATUS_IS_CHARGING(flags) (((flags) & BATTERY_STATUS_FLAG_CHARGING) != 0U)
|
||||
#define BATTERY_STATUS_IS_FULL(flags) (((flags) & BATTERY_STATUS_FLAG_FULL) != 0U)
|
||||
|
||||
APP_EVENT_TYPE_DECLARE(battery_status_event);
|
||||
|
||||
static inline void battery_status_event_submit(bool charging, bool full, uint8_t soc)
|
||||
{
|
||||
struct battery_status_event *event = new_battery_status_event();
|
||||
|
||||
event->flags = 0U;
|
||||
if (charging) {
|
||||
event->flags |= BATTERY_STATUS_FLAG_CHARGING;
|
||||
}
|
||||
if (full) {
|
||||
event->flags |= BATTERY_STATUS_FLAG_FULL;
|
||||
}
|
||||
event->soc = soc;
|
||||
|
||||
APP_EVENT_SUBMIT(event);
|
||||
}
|
||||
|
||||
static inline uint8_t battery_status_event_get_flags(const struct battery_status_event *event)
|
||||
{
|
||||
return event->flags;
|
||||
}
|
||||
|
||||
static inline bool battery_status_event_is_charging(const struct battery_status_event *event)
|
||||
{
|
||||
return BATTERY_STATUS_IS_CHARGING(event->flags);
|
||||
}
|
||||
|
||||
static inline bool battery_status_event_is_full(const struct battery_status_event *event)
|
||||
{
|
||||
return BATTERY_STATUS_IS_FULL(event->flags);
|
||||
}
|
||||
|
||||
static inline uint8_t battery_status_event_get_soc(const struct battery_status_event *event)
|
||||
{
|
||||
return event->soc;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user