added request for light theme
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "CLSAddress.h"
|
||||
#include "BSP_EE24.h"
|
||||
#include "LightTask.h"
|
||||
#include "CanDataHandler.h"
|
||||
|
||||
// Memory for the task
|
||||
StaticTask_t LightTask_cb;
|
||||
@@ -27,6 +28,7 @@ static cls_light_GlobalBrightness msg_cls_light_GlobalBrightness;
|
||||
static cls_light_GlobalTheme msg_cls_light_GlobalTheme;
|
||||
static cls_light_ThemeSettings msg_cls_light_ThemeSettings;
|
||||
static cls_light_SaveThemeSettings msg_cls_light_SaveThemeSettings;
|
||||
static cls_light_RequestThemeSetting msg_cls_light_RequestThemeSetting;
|
||||
|
||||
static volatile struct LightSettings_s {
|
||||
volatile uint8_t brightness;
|
||||
@@ -105,4 +107,36 @@ void DataClbk_cls_light_SaveThemeSettings(void* msg, uint32_t length) {
|
||||
uint16_t msg_light_setting = GENERATE_CLS_ADDRESS(CLS_CODE_CONFIG, device, 4);
|
||||
CLS_BSP_TxHeaderType can_header = CREATE_BSP_CAN_HEADER(msg_light_setting, CLS_BSP_DLC_BYTES_1);
|
||||
CLS_BSP_CAN_AddMessageToSend(&can_header, (uint8_t*)"X");
|
||||
}
|
||||
|
||||
static uint8_t request_theme;
|
||||
static RGB_Theme_t response_theme;
|
||||
static cls_light_ThemeSettings themesettings;
|
||||
void CanData_responseThemeSetting(CanDataId canid, uint8_t* data, uint8_t len) {
|
||||
if(len == 8) {
|
||||
memcpy(&response_theme, data, 8);
|
||||
|
||||
themesettings.animation = response_theme.animation;
|
||||
themesettings.brightness = response_theme.max_brighness;
|
||||
themesettings.deviceId = (canid >> 3) & 0x1F;
|
||||
themesettings.rgb = response_theme.color.r | (response_theme.color.g << 8) | (response_theme.color.b << 16);
|
||||
themesettings.theme = request_theme;
|
||||
USBDataResonse(&themesettings,cls_light_ThemeSettings_fields, cls_usb_PackageType_LIGHT_SETTING_THEME);
|
||||
}
|
||||
|
||||
CanData_removeEvent(canid);
|
||||
}
|
||||
|
||||
void DataClbk_cls_light_RequestThemeSetting(void* msg, uint32_t length) {
|
||||
DATA_CLBK_SETUP(cls_light_RequestThemeSetting);
|
||||
uint8_t device = msg_cls_light_RequestThemeSetting.deviceId;
|
||||
request_theme = (uint8_t)msg_cls_light_RequestThemeSetting.theme;
|
||||
uint16_t msg_light_setting = GENERATE_CLS_ADDRESS(CLS_CODE_CONFIG, device, 7);
|
||||
CLS_BSP_TxHeaderType can_header = CREATE_BSP_CAN_HEADER(msg_light_setting, CLS_BSP_DLC_BYTES_1);
|
||||
|
||||
|
||||
CanData_regEventMsg(msg_light_setting,CanData_responseThemeSetting);
|
||||
|
||||
|
||||
CLS_BSP_CAN_AddMessageToSend(&can_header, (uint8_t*)&request_theme);
|
||||
}
|
||||
Reference in New Issue
Block a user