Merge branch 'development' of https://github.com/arendst/Sonoff-Tasmota into development

This commit is contained in:
localhost61 2019-02-25 22:00:46 +01:00
commit 3757ce98c2
3 changed files with 19 additions and 17 deletions

View File

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

View File

@ -1764,7 +1764,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
0, // GPIO09 (SD_DATA2 Flash QIO or ESP8285) 0, // GPIO09 (SD_DATA2 Flash QIO or ESP8285)
0, // GPIO10 (SD_DATA3 Flash QIO or ESP8285) 0, // GPIO10 (SD_DATA3 Flash QIO or ESP8285)
// GPIO11 (SD_CMD Flash) // GPIO11 (SD_CMD Flash)
GPIO_LED1, // GPIO12 Green LED - Link status GPIO_LED1_INV, // GPIO12 Green LED - Link status
GPIO_LED2, // GPIO13 Red LED - Power status GPIO_LED2, // GPIO13 Red LED - Power status
0, 0, 0, 0 0, 0, 0, 0
}, },

View File

@ -86,8 +86,6 @@ struct LCwColor {
#define MAX_FIXED_COLD_WARM 4 #define MAX_FIXED_COLD_WARM 4
const LCwColor kFixedColdWarm[MAX_FIXED_COLD_WARM] PROGMEM = { 0,0, 255,0, 0,255, 128,128 }; const LCwColor kFixedColdWarm[MAX_FIXED_COLD_WARM] PROGMEM = { 0,0, 255,0, 0,255, 128,128 };
uint8_t color_remap[5];
uint8_t ledTable[] = { uint8_t ledTable[] = {
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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_new_color[5];
uint8_t light_last_color[5]; 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_wheel = 0; uint8_t light_wheel = 0;
uint8_t light_subtype = 0; uint8_t light_subtype = 0;
@ -576,25 +575,25 @@ void LightUpdateColorMapping(void)
param = 119; param = 119;
} }
uint8_t tmp[] = {0,1,2,3,4}; 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){ for (uint8_t i = param / 24; i<4; ++i){
tmp[i] = tmp[i+1]; tmp[i] = tmp[i+1];
} }
param = param % 24; 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){ for (uint8_t i = param / 6; i<3; ++i){
tmp[i] = tmp[i+1]; tmp[i] = tmp[i+1];
} }
param = param % 6; 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){ for (uint8_t i = param / 2; i<2; ++i){
tmp[i] = tmp[i+1]; tmp[i] = tmp[i+1];
} }
param = param % 2; param = param % 2;
color_remap[3] = tmp[param]; light_color_remap[3] = tmp[param];
color_remap[4] = tmp[1-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); //AddLog(LOG_LEVEL_DEBUG);
} }
@ -929,11 +928,11 @@ void LightAnimate(void)
} }
} }
else { 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 sleep = (LS_POWER == Settings.light_scheme) ? Settings.sleep : 0; // If no animation then use sleep as is
#else #else
sleep = 0; sleep = 0;
#endif // PWM_LIGHTSCHEME0_IGNORE_SLEEP #endif // PWM_LIGHTSCHEME0_IGNORE_SLEEP
switch (Settings.light_scheme) { switch (Settings.light_scheme) {
case LS_POWER: case LS_POWER:
LightSetDimmer(Settings.light_dimmer); LightSetDimmer(Settings.light_dimmer);
@ -1001,7 +1000,7 @@ void LightAnimate(void)
uint8_t orig_col[5]; uint8_t orig_col[5];
memcpy(orig_col, cur_col, sizeof(orig_col)); memcpy(orig_col, cur_col, sizeof(orig_col));
for (uint8_t i = 0; i < 5; i++) { 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++) { for (uint8_t i = 0; i < light_subtype; i++) {
@ -1253,7 +1252,11 @@ 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
for (uint8_t i = 0; i < buffer_length / 2; i++) { uint8_t limit = buffer_length / 2;
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);
} }