Fix Domoticz Color regression

Fix Domoticz Color regression (#5310 )
This commit is contained in:
Theo Arends 2019-02-25 19:47:45 +01:00
parent 15419b3e51
commit 9f00978a79
2 changed files with 13 additions and 15 deletions

View File

@ -789,8 +789,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
param_low = 1;
param_high = 250;
break;
case P_RGB_REMAP:
case P_RGB_REMAP:
param_low = 0;
param_high = 119;
break;
@ -798,8 +797,8 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
if ((payload >= param_low) && (payload <= param_high)) {
Settings.param[pindex] = payload;
switch (pindex) {
case P_RGB_REMAP:
LightUpdateColorMapping();
case P_RGB_REMAP:
LightUpdateColorMapping();
break;
}
}

View File

@ -86,8 +86,6 @@ struct LCwColor {
#define MAX_FIXED_COLD_WARM 4
const LCwColor kFixedColdWarm[MAX_FIXED_COLD_WARM] PROGMEM = { 0,0, 255,0, 0,255, 128,128 };
uint8_t color_remap[5];
uint8_t ledTable[] = {
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -111,6 +109,7 @@ uint8_t light_current_color[5];
uint8_t light_new_color[5];
uint8_t light_last_color[5];
uint8_t light_signal_color[5];
uint8_t light_color_remap[5];
uint8_t light_wheel = 0;
uint8_t light_subtype = 0;
@ -576,25 +575,25 @@ void LightUpdateColorMapping(void)
param = 119;
}
uint8_t tmp[] = {0,1,2,3,4};
color_remap[0] = tmp[param / 24];
light_color_remap[0] = tmp[param / 24];
for (uint8_t i = param / 24; i<4; ++i){
tmp[i] = tmp[i+1];
}
param = param % 24;
color_remap[1] = tmp[(param / 6)];
light_color_remap[1] = tmp[(param / 6)];
for (uint8_t i = param / 6; i<3; ++i){
tmp[i] = tmp[i+1];
}
param = param % 6;
color_remap[2] = tmp[(param / 2)];
light_color_remap[2] = tmp[(param / 2)];
for (uint8_t i = param / 2; i<2; ++i){
tmp[i] = tmp[i+1];
}
param = param % 2;
color_remap[3] = tmp[param];
color_remap[4] = tmp[1-param];
light_color_remap[3] = tmp[param];
light_color_remap[4] = tmp[1-param];
//snprintf_P(log_data, sizeof(log_data), "%d colors: %d %d %d %d %d",Settings.param[P_RGB_REMAP], color_remap[0],color_remap[1],color_remap[2],color_remap[3],color_remap[4]);
//snprintf_P(log_data, sizeof(log_data), "%d colors: %d %d %d %d %d",Settings.param[P_RGB_REMAP], light_color_remap[0],light_color_remap[1],light_color_remap[2],light_color_remap[3],light_color_remap[4]);
//AddLog(LOG_LEVEL_DEBUG);
}
@ -929,11 +928,11 @@ void LightAnimate(void)
}
}
else {
#ifdef PWM_LIGHTSCHEME0_IGNORE_SLEEP
#ifdef PWM_LIGHTSCHEME0_IGNORE_SLEEP
sleep = (LS_POWER == Settings.light_scheme) ? Settings.sleep : 0; // If no animation then use sleep as is
#else
sleep = 0;
#endif // PWM_LIGHTSCHEME0_IGNORE_SLEEP
#endif // PWM_LIGHTSCHEME0_IGNORE_SLEEP
switch (Settings.light_scheme) {
case LS_POWER:
LightSetDimmer(Settings.light_dimmer);
@ -1001,7 +1000,7 @@ void LightAnimate(void)
uint8_t orig_col[5];
memcpy(orig_col, cur_col, sizeof(orig_col));
for (uint8_t i = 0; i < 5; i++) {
cur_col[i] = orig_col[color_remap[i]];
cur_col[i] = orig_col[light_color_remap[i]];
}
for (uint8_t i = 0; i < light_subtype; i++) {