mirror of https://github.com/arendst/Tasmota.git
Merge pull request #5342 from netpok/light-rgb-ct-unlink
Allow independent working of RGB and white lights
This commit is contained in:
commit
13b24bbf5f
|
@ -789,10 +789,6 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
||||||
param_low = 1;
|
param_low = 1;
|
||||||
param_high = 250;
|
param_high = 250;
|
||||||
break;
|
break;
|
||||||
case P_RGB_REMAP:
|
|
||||||
param_low = 0;
|
|
||||||
param_high = 119;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if ((payload >= param_low) && (payload <= param_high)) {
|
if ((payload >= param_low) && (payload <= param_high)) {
|
||||||
Settings.param[pindex] = payload;
|
Settings.param[pindex] = payload;
|
||||||
|
|
|
@ -111,6 +111,8 @@ uint8_t light_last_color[5];
|
||||||
uint8_t light_signal_color[5];
|
uint8_t light_signal_color[5];
|
||||||
uint8_t light_color_remap[5];
|
uint8_t light_color_remap[5];
|
||||||
|
|
||||||
|
bool light_ct_rgb_linked;
|
||||||
|
|
||||||
uint8_t light_wheel = 0;
|
uint8_t light_wheel = 0;
|
||||||
uint8_t light_subtype = 0;
|
uint8_t light_subtype = 0;
|
||||||
uint8_t light_device = 0;
|
uint8_t light_device = 0;
|
||||||
|
@ -570,9 +572,9 @@ void LightInit(void)
|
||||||
|
|
||||||
void LightUpdateColorMapping(void)
|
void LightUpdateColorMapping(void)
|
||||||
{
|
{
|
||||||
uint8_t param = Settings.param[P_RGB_REMAP];
|
uint8_t param = Settings.param[P_RGB_REMAP] & 127;
|
||||||
if(param > 119){
|
if(param > 119){
|
||||||
param = 119;
|
param = 0;
|
||||||
}
|
}
|
||||||
uint8_t tmp[] = {0,1,2,3,4};
|
uint8_t tmp[] = {0,1,2,3,4};
|
||||||
light_color_remap[0] = tmp[param / 24];
|
light_color_remap[0] = tmp[param / 24];
|
||||||
|
@ -593,6 +595,9 @@ void LightUpdateColorMapping(void)
|
||||||
light_color_remap[3] = tmp[param];
|
light_color_remap[3] = tmp[param];
|
||||||
light_color_remap[4] = tmp[1-param];
|
light_color_remap[4] = tmp[1-param];
|
||||||
|
|
||||||
|
light_ct_rgb_linked = !(Settings.param[P_RGB_REMAP] & 128);
|
||||||
|
|
||||||
|
light_update = 1;
|
||||||
//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]);
|
//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);
|
//AddLog(LOG_LEVEL_DEBUG);
|
||||||
}
|
}
|
||||||
|
@ -616,9 +621,11 @@ void LightSetColorTemp(uint16_t ct)
|
||||||
Settings.light_color[1] = (uint8_t)icold;
|
Settings.light_color[1] = (uint8_t)icold;
|
||||||
} else
|
} else
|
||||||
if (LST_RGBWC == light_subtype) {
|
if (LST_RGBWC == light_subtype) {
|
||||||
|
if(light_ct_rgb_linked){
|
||||||
Settings.light_color[0] = 0;
|
Settings.light_color[0] = 0;
|
||||||
Settings.light_color[1] = 0;
|
Settings.light_color[1] = 0;
|
||||||
Settings.light_color[2] = 0;
|
Settings.light_color[2] = 0;
|
||||||
|
}
|
||||||
Settings.light_color[3] = (uint8_t)icold;
|
Settings.light_color[3] = (uint8_t)icold;
|
||||||
Settings.light_color[4] = (uint8_t)iwarm;
|
Settings.light_color[4] = (uint8_t)iwarm;
|
||||||
} else {
|
} else {
|
||||||
|
@ -983,11 +990,9 @@ void LightAnimate(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Settings.light_scheme < LS_MAX) || !light_power) {
|
if ((Settings.light_scheme < LS_MAX) || !light_power) {
|
||||||
for (uint8_t i = 0; i < light_subtype; i++) {
|
if (memcmp(light_last_color, light_new_color, light_subtype)) {
|
||||||
if (light_last_color[i] != light_new_color[i]) {
|
|
||||||
light_update = 1;
|
light_update = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (light_update) {
|
if (light_update) {
|
||||||
light_update = 0;
|
light_update = 0;
|
||||||
for (uint8_t i = 0; i < light_subtype; i++) {
|
for (uint8_t i = 0; i < light_subtype; i++) {
|
||||||
|
@ -1158,9 +1163,11 @@ void LightHsbToRgb(void)
|
||||||
light_current_color[0] = (uint8_t)(r * 255.0f);
|
light_current_color[0] = (uint8_t)(r * 255.0f);
|
||||||
light_current_color[1] = (uint8_t)(g * 255.0f);
|
light_current_color[1] = (uint8_t)(g * 255.0f);
|
||||||
light_current_color[2] = (uint8_t)(b * 255.0f);
|
light_current_color[2] = (uint8_t)(b * 255.0f);
|
||||||
|
if(light_ct_rgb_linked){
|
||||||
light_current_color[3] = 0;
|
light_current_color[3] = 0;
|
||||||
light_current_color[4] = 0;
|
light_current_color[4] = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
|
|
||||||
|
@ -1252,11 +1259,7 @@ bool LightColorEntry(char *buffer, uint8_t buffer_length)
|
||||||
entry_type = 2; // Decimal
|
entry_type = 2; // Decimal
|
||||||
}
|
}
|
||||||
else if (((2 * light_subtype) == buffer_length) || (buffer_length > 3)) { // Hexadecimal entry
|
else if (((2 * light_subtype) == buffer_length) || (buffer_length > 3)) { // Hexadecimal entry
|
||||||
uint8_t limit = buffer_length / 2;
|
for (uint8_t i = 0; i < min((uint)(buffer_length / 2), sizeof(light_entry_color)); i++) {
|
||||||
if (limit > sizeof(light_entry_color)) { // Fix buffer overflow due to too many parameters
|
|
||||||
limit = sizeof(light_entry_color);
|
|
||||||
}
|
|
||||||
for (uint8_t i = 0; i < limit; i++) {
|
|
||||||
strlcpy(scolor, buffer + (i *2), 3);
|
strlcpy(scolor, buffer + (i *2), 3);
|
||||||
light_entry_color[i] = (uint8_t)strtol(scolor, &p, 16);
|
light_entry_color[i] = (uint8_t)strtol(scolor, &p, 16);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue