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:
@@ -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, ¤t_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);
|
||||
|
||||
Reference in New Issue
Block a user