feat(protocol): 添加时间同步和主题颜色协议支持

- 添加CDC_PROTO_TYPE_LED_STATE、CDC_PROTO_TYPE_TIME_SYNC和
  CDC_PROTO_TYPE_THEME_RGB协议类型定义
- 在protobuf中定义LedState、TimeSync和ThemeRgb消息结构
- 更新CdcPacketBody消息以包含新的协议类型
- 增加协议能力标志位以支持新功能
This commit is contained in:
2026-04-13 16:43:17 +08:00
parent 23e23f63a7
commit c342a8d3f0
13 changed files with 579 additions and 5 deletions

View File

@@ -18,6 +18,7 @@
#include "led_effect/led_effect.h"
#include "led_strip_en_event.h"
#include "theme_rgb_update_event.h"
#include "theme_color.h"
LOG_MODULE_REGISTER(MODULE, LOG_LEVEL_INF);
@@ -276,6 +277,21 @@ static bool handle_led_strip_en_event(const struct led_strip_en_event *event)
return false;
}
static bool handle_theme_rgb_update_event(const struct theme_rgb_update_event *event)
{
current_theme = event->theme;
if ((effect != NULL) && (effect->ops != NULL)) {
effect->ops->set_theme(effect, &current_theme);
}
if (running && enabled && (effect != NULL) && effect->ops->is_active(effect)) {
schedule_effect_tick(K_NO_WAIT);
}
return false;
}
static bool app_event_handler(const struct app_event_header *aeh)
{
if (is_button_event(aeh)) {
@@ -286,6 +302,10 @@ static bool app_event_handler(const struct app_event_header *aeh)
return handle_led_strip_en_event(cast_led_strip_en_event(aeh));
}
if (is_theme_rgb_update_event(aeh)) {
return handle_theme_rgb_update_event(cast_theme_rgb_update_event(aeh));
}
if (is_module_state_event(aeh)) {
const struct module_state_event *event = cast_module_state_event(aeh);
@@ -343,5 +363,6 @@ APP_EVENT_LISTENER(MODULE, app_event_handler);
APP_EVENT_SUBSCRIBE_EARLY(MODULE, button_event);
APP_EVENT_SUBSCRIBE(MODULE, led_strip_en_event);
APP_EVENT_SUBSCRIBE(MODULE, module_state_event);
APP_EVENT_SUBSCRIBE(MODULE, theme_rgb_update_event);
APP_EVENT_SUBSCRIBE_EARLY(MODULE, power_down_event);
APP_EVENT_SUBSCRIBE(MODULE, wake_up_event);