From ea63c5e4801c15dc93050cf94dde34355a8281e2 Mon Sep 17 00:00:00 2001 From: Alexey Pavlov Date: Sun, 7 Nov 2021 17:56:28 +0300 Subject: [PATCH 1/8] fix opentherm --- tasmota/xsns_69_opentherm.ino | 20 ++++++++++++++++-- tasmota/xsns_69_opentherm_protocol.ino | 29 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/tasmota/xsns_69_opentherm.ino b/tasmota/xsns_69_opentherm.ino index cfcc0384d..c94e61b59 100644 --- a/tasmota/xsns_69_opentherm.ino +++ b/tasmota/xsns_69_opentherm.ino @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#define USE_OPENTHERM #ifdef USE_OPENTHERM @@ -467,8 +468,11 @@ uint8_t sns_opentherm_read_flags(char *data, uint32_t len) // flag value, however, this command does not update the settings. #define D_CMND_SET_HOT_WATER_ENABLED "dhw" +// BLOR - Reset boiler +#define D_CMND_BLLOR "blor" + const char kOpenThermCommands[] PROGMEM = D_PRFX_OTHERM "|" D_CMND_OTHERM_BOILER_SETPOINT "|" D_CMND_OTHERM_DHW_SETPOINT - "|" D_CMND_OTHERM_SAVE_SETTINGS "|" D_CMND_OTHERM_FLAGS "|" D_CMND_SET_CENTRAL_HEATING_ENABLED "|" D_CMND_SET_HOT_WATER_ENABLED; + "|" D_CMND_OTHERM_SAVE_SETTINGS "|" D_CMND_OTHERM_FLAGS "|" D_CMND_SET_CENTRAL_HEATING_ENABLED "|" D_CMND_SET_HOT_WATER_ENABLED "|" D_CMND_BLLOR; void (*const OpenThermCommands[])(void) PROGMEM = { &sns_opentherm_boiler_setpoint_cmd, @@ -476,7 +480,8 @@ void (*const OpenThermCommands[])(void) PROGMEM = { &sns_opentherm_save_settings_cmd, &sns_opentherm_flags_cmd, &sns_opentherm_set_central_heating_cmd, - &sns_opentherm_set_hot_water_cmd}; + &sns_opentherm_set_hot_water_cmd, + &sns_opentherm_blor_cmd,}; void sns_opentherm_cmd(void) { } void sns_opentherm_boiler_setpoint_cmd(void) @@ -550,6 +555,17 @@ void sns_opentherm_set_hot_water_cmd(void) ResponseCmndNumber(sns_ot_boiler_status.m_enableHotWater ? 1 : 0); } +void sns_opentherm_blor_cmd(void) +{ + bool query = strlen(XdrvMailbox.data) == 0; + bool retval = false; + if (!query) + { + if (atoi(XdrvMailbox.data)) retval = sns_opentherm_call_blor(); + } + ResponseCmndNumber(retval); +} + /*********************************************************************************************\ * Interface \*********************************************************************************************/ diff --git a/tasmota/xsns_69_opentherm_protocol.ino b/tasmota/xsns_69_opentherm_protocol.ino index bc821640a..a86648849 100644 --- a/tasmota/xsns_69_opentherm_protocol.ino +++ b/tasmota/xsns_69_opentherm_protocol.ino @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#define USE_OPENTHERM #ifdef USE_OPENTHERM @@ -243,6 +244,14 @@ OpenThermCommand sns_opentherm_commands[] = { .m_ot_make_request = sns_opentherm_get_generic_u16, .m_ot_parse_response = sns_opentherm_parse_generic_u16, .m_ot_appent_telemetry = sns_opentherm_tele_generic_u16}, + {// Boiler Lock-out Reset command + .m_command_name = "BLOR", + .m_command_code = (uint8_t)OpenThermMessageID::Command, + .m_flags = {.notSupported = 1}, + .m_results = {{.m_u8 = 0}, {.m_u8 = 0}}, + .m_ot_make_request = sns_opentherm_send_blor, + .m_ot_parse_response = sns_opentherm_parse_generic_u16, + .m_ot_appent_telemetry = sns_opentherm_tele_u8_u8}, }; /////////////////////////////////// Process Slave Status Flags & Control ////////////////////////////////////////////////// @@ -431,6 +440,26 @@ void sns_opentherm_tele_oem_diag(struct OpenThermCommandT *self) ResponseAppend_P(PSTR("%d"), (int)self->m_results[0].m_u16); } +/////////////////////////////////// Boiler Boiler Lock-out Reset ////////////////////////////////////////////////// +unsigned long sns_opentherm_send_blor(struct OpenThermCommandT *self, struct OT_BOILER_STATUS_T *status) +{ + AddLog(LOG_LEVEL_ERROR, PSTR("[OTH]: Boiler Boiler Lock-out Reset")); + + self->m_flags.notSupported = true; // Disable future calls of this command + + unsigned int data = 1; //1 : “BLOR”= Boiler Lock-out Reset command + return OpenTherm::buildRequest(OpenThermMessageType::WRITE_DATA, OpenThermMessageID::Command, data); +} +bool sns_opentherm_call_blor() +{ + /* + OpenThermCommandT *cmd = &sns_opentherm_commands[sns_opentherm_current_command-1]; + if (strcmp(cmd->m_command_name, "BLOR")) return false; + cmd->m_flags.notSupported = false; + return true; + */ +} + /////////////////////////////////// Generic Single Float ///////////////////////////////////////////////// unsigned long sns_opentherm_get_generic_float(struct OpenThermCommandT *self, struct OT_BOILER_STATUS_T *) { From f6211a416bc0d1b1a30f5f2d0c593a4ee9ccbbc2 Mon Sep 17 00:00:00 2001 From: Alexey Pavlov Date: Sun, 7 Nov 2021 17:59:03 +0300 Subject: [PATCH 2/8] fix opentherm --- tasmota/xlgt_01_ws2812.ino | 99 +++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/tasmota/xlgt_01_ws2812.ino b/tasmota/xlgt_01_ws2812.ino index a7e7c9927..465aba427 100644 --- a/tasmota/xlgt_01_ws2812.ino +++ b/tasmota/xlgt_01_ws2812.ino @@ -17,6 +17,11 @@ along with this program. If not, see . */ +#ifndef FIRMWARE_MINIMAL +#define USE_LIGHT +#define USE_WS2812 +#endif + #ifdef USE_LIGHT #ifdef USE_WS2812 /*********************************************************************************************\ @@ -37,7 +42,7 @@ #define XLGT_01 1 -const uint8_t WS2812_SCHEMES = 8; // Number of WS2812 schemes +const uint8_t WS2812_SCHEMES = 10; // Number of WS2812 schemes const char kWs2812Commands[] PROGMEM = "|" // No prefix D_CMND_LED "|" D_CMND_PIXELS "|" D_CMND_ROTATION "|" D_CMND_WIDTH ; @@ -289,6 +294,93 @@ void Ws2812Clock(void) Ws2812StripShow(); } +#define pow2(x) ((x)*(x)) +#define pow3(x) ((x)*pow2(x)) +#define pow4(x) (pow2(x)*pow2(x)) + +void Ws2812RunningStrip(int scheme) +{ +#if (USE_WS2812_CTYPE > NEO_3LED) + RgbwColor c; + c.W = 0; +#else + RgbColor c(Settings->light_dimmer); +#endif + + static uint32_t timer_counter = 0; + static uint32_t last_timer_counter = timer_counter; + if (Settings->light_rotation%2) timer_counter--; + else timer_counter++; + + uint32_t width = Settings->ws_width[WS_MINUTE]?Settings->ws_width[WS_MINUTE]:1; + uint32_t repeat = 1;//kWsRepeat[Settings->light_width]; // number of scheme.count per ledcount + uint32_t range = (uint32_t)ceil((float)Settings->light_pixels / (float)repeat); + uint32_t speed = Settings->light_speed; //((Settings->light_speed * 2) -1) * (STATES / 10); // + static uint32_t offset = 0; + + if (scheme==WS2812_SCHEMES-1) { + if (timer_counter/speed!=last_timer_counter/speed) { + offset = random(range); + last_timer_counter = timer_counter; + } + } else { + offset = speed > 0 ? timer_counter / speed : 0; + } + + //WsColor oldColor, currentColor; + //Ws2812GradientColor(schemenr, &oldColor, range, gradRange, offset); + //currentColor = oldColor; + int power = Settings->ws_width[WS_SECOND]; + int max_input = pow(width, power); + float dimmer = 100 / (float)Settings->light_dimmer; + + uint32_t target = offset % Settings->light_pixels; + + for (uint32_t i = 0; i < Settings->light_pixels; i++) { + int delta = targetlight_color[0] / pow(delta+1, power); + float fmyGrn = Settings->light_color[1] / pow(delta+1, power); + float fmyBlu = Settings->light_color[2] / pow(delta+1, power); + /* + float fmyRed = (float)wsmap(max_input-pow(delta+1, power), 0, max_input, 0, Settings->light_color[0]); + float fmyGrn = (float)wsmap(max_input-pow(delta+1, power), 0, max_input, 0, Settings->light_color[1]); + float fmyBlu = (float)wsmap(max_input-pow(delta+1, power), 0, max_input, 0, Settings->light_color[2]); + */ + + c.R = (uint8_t)fmyRed/dimmer; + c.G = (uint8_t)fmyGrn/dimmer; + c.B = (uint8_t)fmyBlu/dimmer; + } + else { + c.R = 0 ; + c.G = 0 ; + c.B = 0 ; + } + + if (Settings->light_width==2) { + c.R = Settings->light_color[0]/dimmer - c.R; + c.G = Settings->light_color[1]/dimmer - c.G; + c.B = Settings->light_color[2]/dimmer - c.B; + } else if (Settings->ws_width[WS_MINUTE]==3) { + c.R = max(100 - c.R,0); + c.G = max(100 - c.G,0); + c.B = max(100 - c.B,0); + } + + strip->SetPixelColor(i, c); +/* + // Blend old and current color based on time for smooth movement. + c.R = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.red, currentColor.red); + c.G = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.green, currentColor.green); + c.B = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.blue, currentColor.blue); + strip->SetPixelColor(i, c); + oldColor = currentColor; + */ + } + Ws2812StripShow(); +} + void Ws2812GradientColor(uint32_t schemenr, struct WsColor* mColor, uint32_t range, uint32_t gradRange, uint32_t i) { /* @@ -495,6 +587,11 @@ void Ws2812ShowScheme(void) Ws2812.show_next = 0; } break; + case WS2812_SCHEMES-2: // Running strip + case WS2812_SCHEMES-1: // Running strip + Ws2812RunningStrip(scheme); + Ws2812.show_next = 1; + break; default: if (1 == Settings->light_fade) { Ws2812Gradient(scheme -1); From 71f1c1775fc44f20d535c572ead9efe94f50eeda Mon Sep 17 00:00:00 2001 From: Alexey Pavlov Date: Sun, 7 Nov 2021 17:56:28 +0300 Subject: [PATCH 3/8] fix opentherm --- tasmota/xsns_69_opentherm.ino | 20 ++++++++++++++++-- tasmota/xsns_69_opentherm_protocol.ino | 29 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/tasmota/xsns_69_opentherm.ino b/tasmota/xsns_69_opentherm.ino index cfcc0384d..c94e61b59 100644 --- a/tasmota/xsns_69_opentherm.ino +++ b/tasmota/xsns_69_opentherm.ino @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#define USE_OPENTHERM #ifdef USE_OPENTHERM @@ -467,8 +468,11 @@ uint8_t sns_opentherm_read_flags(char *data, uint32_t len) // flag value, however, this command does not update the settings. #define D_CMND_SET_HOT_WATER_ENABLED "dhw" +// BLOR - Reset boiler +#define D_CMND_BLLOR "blor" + const char kOpenThermCommands[] PROGMEM = D_PRFX_OTHERM "|" D_CMND_OTHERM_BOILER_SETPOINT "|" D_CMND_OTHERM_DHW_SETPOINT - "|" D_CMND_OTHERM_SAVE_SETTINGS "|" D_CMND_OTHERM_FLAGS "|" D_CMND_SET_CENTRAL_HEATING_ENABLED "|" D_CMND_SET_HOT_WATER_ENABLED; + "|" D_CMND_OTHERM_SAVE_SETTINGS "|" D_CMND_OTHERM_FLAGS "|" D_CMND_SET_CENTRAL_HEATING_ENABLED "|" D_CMND_SET_HOT_WATER_ENABLED "|" D_CMND_BLLOR; void (*const OpenThermCommands[])(void) PROGMEM = { &sns_opentherm_boiler_setpoint_cmd, @@ -476,7 +480,8 @@ void (*const OpenThermCommands[])(void) PROGMEM = { &sns_opentherm_save_settings_cmd, &sns_opentherm_flags_cmd, &sns_opentherm_set_central_heating_cmd, - &sns_opentherm_set_hot_water_cmd}; + &sns_opentherm_set_hot_water_cmd, + &sns_opentherm_blor_cmd,}; void sns_opentherm_cmd(void) { } void sns_opentherm_boiler_setpoint_cmd(void) @@ -550,6 +555,17 @@ void sns_opentherm_set_hot_water_cmd(void) ResponseCmndNumber(sns_ot_boiler_status.m_enableHotWater ? 1 : 0); } +void sns_opentherm_blor_cmd(void) +{ + bool query = strlen(XdrvMailbox.data) == 0; + bool retval = false; + if (!query) + { + if (atoi(XdrvMailbox.data)) retval = sns_opentherm_call_blor(); + } + ResponseCmndNumber(retval); +} + /*********************************************************************************************\ * Interface \*********************************************************************************************/ diff --git a/tasmota/xsns_69_opentherm_protocol.ino b/tasmota/xsns_69_opentherm_protocol.ino index bc821640a..a86648849 100644 --- a/tasmota/xsns_69_opentherm_protocol.ino +++ b/tasmota/xsns_69_opentherm_protocol.ino @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#define USE_OPENTHERM #ifdef USE_OPENTHERM @@ -243,6 +244,14 @@ OpenThermCommand sns_opentherm_commands[] = { .m_ot_make_request = sns_opentherm_get_generic_u16, .m_ot_parse_response = sns_opentherm_parse_generic_u16, .m_ot_appent_telemetry = sns_opentherm_tele_generic_u16}, + {// Boiler Lock-out Reset command + .m_command_name = "BLOR", + .m_command_code = (uint8_t)OpenThermMessageID::Command, + .m_flags = {.notSupported = 1}, + .m_results = {{.m_u8 = 0}, {.m_u8 = 0}}, + .m_ot_make_request = sns_opentherm_send_blor, + .m_ot_parse_response = sns_opentherm_parse_generic_u16, + .m_ot_appent_telemetry = sns_opentherm_tele_u8_u8}, }; /////////////////////////////////// Process Slave Status Flags & Control ////////////////////////////////////////////////// @@ -431,6 +440,26 @@ void sns_opentherm_tele_oem_diag(struct OpenThermCommandT *self) ResponseAppend_P(PSTR("%d"), (int)self->m_results[0].m_u16); } +/////////////////////////////////// Boiler Boiler Lock-out Reset ////////////////////////////////////////////////// +unsigned long sns_opentherm_send_blor(struct OpenThermCommandT *self, struct OT_BOILER_STATUS_T *status) +{ + AddLog(LOG_LEVEL_ERROR, PSTR("[OTH]: Boiler Boiler Lock-out Reset")); + + self->m_flags.notSupported = true; // Disable future calls of this command + + unsigned int data = 1; //1 : “BLOR”= Boiler Lock-out Reset command + return OpenTherm::buildRequest(OpenThermMessageType::WRITE_DATA, OpenThermMessageID::Command, data); +} +bool sns_opentherm_call_blor() +{ + /* + OpenThermCommandT *cmd = &sns_opentherm_commands[sns_opentherm_current_command-1]; + if (strcmp(cmd->m_command_name, "BLOR")) return false; + cmd->m_flags.notSupported = false; + return true; + */ +} + /////////////////////////////////// Generic Single Float ///////////////////////////////////////////////// unsigned long sns_opentherm_get_generic_float(struct OpenThermCommandT *self, struct OT_BOILER_STATUS_T *) { From af14b4943525264c27ea0e4eada391b83352c4bb Mon Sep 17 00:00:00 2001 From: Alexey Pavlov Date: Sun, 28 Nov 2021 18:44:10 +0300 Subject: [PATCH 4/8] merge conflict --- tasmota/xlgt_01_ws2812.ino | 99 +++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/tasmota/xlgt_01_ws2812.ino b/tasmota/xlgt_01_ws2812.ino index 3a9e396f3..f2c8b0610 100644 --- a/tasmota/xlgt_01_ws2812.ino +++ b/tasmota/xlgt_01_ws2812.ino @@ -17,6 +17,11 @@ along with this program. If not, see . */ +#ifndef FIRMWARE_MINIMAL +#define USE_LIGHT +#define USE_WS2812 +#endif + #ifdef USE_LIGHT #ifdef USE_WS2812 /*********************************************************************************************\ @@ -37,7 +42,7 @@ #define XLGT_01 1 -const uint8_t WS2812_SCHEMES = 9; // Number of WS2812 schemes +const uint8_t WS2812_SCHEMES = 10; // Number of WS2812 schemes const char kWs2812Commands[] PROGMEM = "|" // No prefix D_CMND_LED "|" D_CMND_PIXELS "|" D_CMND_ROTATION "|" D_CMND_WIDTH "|" D_CMND_STEPPIXELS ; @@ -291,6 +296,93 @@ void Ws2812Clock(void) Ws2812StripShow(); } +#define pow2(x) ((x)*(x)) +#define pow3(x) ((x)*pow2(x)) +#define pow4(x) (pow2(x)*pow2(x)) + +void Ws2812RunningStrip(int scheme) +{ +#if (USE_WS2812_CTYPE > NEO_3LED) + RgbwColor c; + c.W = 0; +#else + RgbColor c(Settings->light_dimmer); +#endif + + static uint32_t timer_counter = 0; + static uint32_t last_timer_counter = timer_counter; + if (Settings->light_rotation%2) timer_counter--; + else timer_counter++; + + uint32_t width = Settings->ws_width[WS_MINUTE]?Settings->ws_width[WS_MINUTE]:1; + uint32_t repeat = 1;//kWsRepeat[Settings->light_width]; // number of scheme.count per ledcount + uint32_t range = (uint32_t)ceil((float)Settings->light_pixels / (float)repeat); + uint32_t speed = Settings->light_speed; //((Settings->light_speed * 2) -1) * (STATES / 10); // + static uint32_t offset = 0; + + if (scheme==WS2812_SCHEMES-1) { + if (timer_counter/speed!=last_timer_counter/speed) { + offset = random(range); + last_timer_counter = timer_counter; + } + } else { + offset = speed > 0 ? timer_counter / speed : 0; + } + + //WsColor oldColor, currentColor; + //Ws2812GradientColor(schemenr, &oldColor, range, gradRange, offset); + //currentColor = oldColor; + int power = Settings->ws_width[WS_SECOND]; + int max_input = pow(width, power); + float dimmer = 100 / (float)Settings->light_dimmer; + + uint32_t target = offset % Settings->light_pixels; + + for (uint32_t i = 0; i < Settings->light_pixels; i++) { + int delta = targetlight_color[0] / pow(delta+1, power); + float fmyGrn = Settings->light_color[1] / pow(delta+1, power); + float fmyBlu = Settings->light_color[2] / pow(delta+1, power); + /* + float fmyRed = (float)wsmap(max_input-pow(delta+1, power), 0, max_input, 0, Settings->light_color[0]); + float fmyGrn = (float)wsmap(max_input-pow(delta+1, power), 0, max_input, 0, Settings->light_color[1]); + float fmyBlu = (float)wsmap(max_input-pow(delta+1, power), 0, max_input, 0, Settings->light_color[2]); + */ + + c.R = (uint8_t)fmyRed/dimmer; + c.G = (uint8_t)fmyGrn/dimmer; + c.B = (uint8_t)fmyBlu/dimmer; + } + else { + c.R = 0 ; + c.G = 0 ; + c.B = 0 ; + } + + if (Settings->light_width==2) { + c.R = Settings->light_color[0]/dimmer - c.R; + c.G = Settings->light_color[1]/dimmer - c.G; + c.B = Settings->light_color[2]/dimmer - c.B; + } else if (Settings->ws_width[WS_MINUTE]==3) { + c.R = max(100 - c.R,0); + c.G = max(100 - c.G,0); + c.B = max(100 - c.B,0); + } + + strip->SetPixelColor(i, c); +/* + // Blend old and current color based on time for smooth movement. + c.R = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.red, currentColor.red); + c.G = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.green, currentColor.green); + c.B = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.blue, currentColor.blue); + strip->SetPixelColor(i, c); + oldColor = currentColor; + */ + } + Ws2812StripShow(); +} + void Ws2812GradientColor(uint32_t schemenr, struct WsColor* mColor, uint32_t range, uint32_t gradRange, uint32_t i) { /* @@ -588,6 +680,11 @@ void Ws2812ShowScheme(void) Ws2812.show_next = 0; } break; + case WS2812_SCHEMES-2: // Running strip + case WS2812_SCHEMES-1: // Running strip + Ws2812RunningStrip(scheme); + Ws2812.show_next = 1; + break; default: if(Settings->light_step_pixels > 0){ Ws2812Steps(scheme -1); From 45aeaede9ac9d37bb5b3d5696bd41d5b35052e50 Mon Sep 17 00:00:00 2001 From: Alexey Pavlov Date: Sun, 12 Dec 2021 08:59:52 +0300 Subject: [PATCH 5/8] Add blor command + bug fixes --- tasmota/xsns_69_opentherm.ino | 2 -- tasmota/xsns_69_opentherm_protocol.ino | 18 +++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tasmota/xsns_69_opentherm.ino b/tasmota/xsns_69_opentherm.ino index c94e61b59..38c1ae2c9 100644 --- a/tasmota/xsns_69_opentherm.ino +++ b/tasmota/xsns_69_opentherm.ino @@ -16,8 +16,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#define USE_OPENTHERM - #ifdef USE_OPENTHERM #define XSNS_69 69 diff --git a/tasmota/xsns_69_opentherm_protocol.ino b/tasmota/xsns_69_opentherm_protocol.ino index a86648849..68430d94a 100644 --- a/tasmota/xsns_69_opentherm_protocol.ino +++ b/tasmota/xsns_69_opentherm_protocol.ino @@ -16,8 +16,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#define USE_OPENTHERM - #ifdef USE_OPENTHERM #include "OpenTherm.h" @@ -33,6 +31,7 @@ typedef union { uint8_t notSupported : 1; // If set, boiler does not support this command uint8_t supported : 1; // Set if at least one response were successfull uint8_t retryCount : 2; // Retry counter before notSupported flag being set + uint8_t manual : 1; // Only manual call }; } OpenThermParamFlags; @@ -247,7 +246,7 @@ OpenThermCommand sns_opentherm_commands[] = { {// Boiler Lock-out Reset command .m_command_name = "BLOR", .m_command_code = (uint8_t)OpenThermMessageID::Command, - .m_flags = {.notSupported = 1}, + .m_flags = {.manual = 1}, .m_results = {{.m_u8 = 0}, {.m_u8 = 0}}, .m_ot_make_request = sns_opentherm_send_blor, .m_ot_parse_response = sns_opentherm_parse_generic_u16, @@ -443,21 +442,21 @@ void sns_opentherm_tele_oem_diag(struct OpenThermCommandT *self) /////////////////////////////////// Boiler Boiler Lock-out Reset ////////////////////////////////////////////////// unsigned long sns_opentherm_send_blor(struct OpenThermCommandT *self, struct OT_BOILER_STATUS_T *status) { - AddLog(LOG_LEVEL_ERROR, PSTR("[OTH]: Boiler Boiler Lock-out Reset")); + AddLog(LOG_LEVEL_ERROR, PSTR("[OTH]: Call Boiler Lock-out Reset")); self->m_flags.notSupported = true; // Disable future calls of this command unsigned int data = 1; //1 : “BLOR”= Boiler Lock-out Reset command - return OpenTherm::buildRequest(OpenThermMessageType::WRITE_DATA, OpenThermMessageID::Command, data); + data <<= 8; + return OpenTherm::buildRequest(OpenThermMessageType::OPTH_WRITE_DATA, OpenThermMessageID::Command, data); } + bool sns_opentherm_call_blor() { - /* - OpenThermCommandT *cmd = &sns_opentherm_commands[sns_opentherm_current_command-1]; + OpenThermCommandT *cmd = &sns_opentherm_commands[(sizeof(sns_opentherm_commands) / sizeof(OpenThermCommand))-1]; if (strcmp(cmd->m_command_name, "BLOR")) return false; cmd->m_flags.notSupported = false; return true; - */ } /////////////////////////////////// Generic Single Float ///////////////////////////////////////////////// @@ -597,7 +596,8 @@ void sns_opentherm_protocol_reset() for (int i = 0; i < SNS_OT_COMMANDS_COUNT; ++i) { struct OpenThermCommandT *cmd = &sns_opentherm_commands[i]; - cmd->m_flags.m_flags = 0; + cmd->m_flags.notSupported = cmd->m_flags.manual; + cmd->m_flags.retryCount = 0; memset(cmd->m_results, 0, sizeof(OpenThermCommandT::m_results)); } } From 60660dc177384237948c921e47e6b2bf3a80e079 Mon Sep 17 00:00:00 2001 From: Alexey Pavlov Date: Fri, 17 Dec 2021 15:26:13 +0300 Subject: [PATCH 6/8] revert /xlgt_01_ws2812.ino --- tasmota/xlgt_01_ws2812.ino | 99 +------------------------------------- 1 file changed, 1 insertion(+), 98 deletions(-) diff --git a/tasmota/xlgt_01_ws2812.ino b/tasmota/xlgt_01_ws2812.ino index f2c8b0610..3a9e396f3 100644 --- a/tasmota/xlgt_01_ws2812.ino +++ b/tasmota/xlgt_01_ws2812.ino @@ -17,11 +17,6 @@ along with this program. If not, see . */ -#ifndef FIRMWARE_MINIMAL -#define USE_LIGHT -#define USE_WS2812 -#endif - #ifdef USE_LIGHT #ifdef USE_WS2812 /*********************************************************************************************\ @@ -42,7 +37,7 @@ #define XLGT_01 1 -const uint8_t WS2812_SCHEMES = 10; // Number of WS2812 schemes +const uint8_t WS2812_SCHEMES = 9; // Number of WS2812 schemes const char kWs2812Commands[] PROGMEM = "|" // No prefix D_CMND_LED "|" D_CMND_PIXELS "|" D_CMND_ROTATION "|" D_CMND_WIDTH "|" D_CMND_STEPPIXELS ; @@ -296,93 +291,6 @@ void Ws2812Clock(void) Ws2812StripShow(); } -#define pow2(x) ((x)*(x)) -#define pow3(x) ((x)*pow2(x)) -#define pow4(x) (pow2(x)*pow2(x)) - -void Ws2812RunningStrip(int scheme) -{ -#if (USE_WS2812_CTYPE > NEO_3LED) - RgbwColor c; - c.W = 0; -#else - RgbColor c(Settings->light_dimmer); -#endif - - static uint32_t timer_counter = 0; - static uint32_t last_timer_counter = timer_counter; - if (Settings->light_rotation%2) timer_counter--; - else timer_counter++; - - uint32_t width = Settings->ws_width[WS_MINUTE]?Settings->ws_width[WS_MINUTE]:1; - uint32_t repeat = 1;//kWsRepeat[Settings->light_width]; // number of scheme.count per ledcount - uint32_t range = (uint32_t)ceil((float)Settings->light_pixels / (float)repeat); - uint32_t speed = Settings->light_speed; //((Settings->light_speed * 2) -1) * (STATES / 10); // - static uint32_t offset = 0; - - if (scheme==WS2812_SCHEMES-1) { - if (timer_counter/speed!=last_timer_counter/speed) { - offset = random(range); - last_timer_counter = timer_counter; - } - } else { - offset = speed > 0 ? timer_counter / speed : 0; - } - - //WsColor oldColor, currentColor; - //Ws2812GradientColor(schemenr, &oldColor, range, gradRange, offset); - //currentColor = oldColor; - int power = Settings->ws_width[WS_SECOND]; - int max_input = pow(width, power); - float dimmer = 100 / (float)Settings->light_dimmer; - - uint32_t target = offset % Settings->light_pixels; - - for (uint32_t i = 0; i < Settings->light_pixels; i++) { - int delta = targetlight_color[0] / pow(delta+1, power); - float fmyGrn = Settings->light_color[1] / pow(delta+1, power); - float fmyBlu = Settings->light_color[2] / pow(delta+1, power); - /* - float fmyRed = (float)wsmap(max_input-pow(delta+1, power), 0, max_input, 0, Settings->light_color[0]); - float fmyGrn = (float)wsmap(max_input-pow(delta+1, power), 0, max_input, 0, Settings->light_color[1]); - float fmyBlu = (float)wsmap(max_input-pow(delta+1, power), 0, max_input, 0, Settings->light_color[2]); - */ - - c.R = (uint8_t)fmyRed/dimmer; - c.G = (uint8_t)fmyGrn/dimmer; - c.B = (uint8_t)fmyBlu/dimmer; - } - else { - c.R = 0 ; - c.G = 0 ; - c.B = 0 ; - } - - if (Settings->light_width==2) { - c.R = Settings->light_color[0]/dimmer - c.R; - c.G = Settings->light_color[1]/dimmer - c.G; - c.B = Settings->light_color[2]/dimmer - c.B; - } else if (Settings->ws_width[WS_MINUTE]==3) { - c.R = max(100 - c.R,0); - c.G = max(100 - c.G,0); - c.B = max(100 - c.B,0); - } - - strip->SetPixelColor(i, c); -/* - // Blend old and current color based on time for smooth movement. - c.R = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.red, currentColor.red); - c.G = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.green, currentColor.green); - c.B = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.blue, currentColor.blue); - strip->SetPixelColor(i, c); - oldColor = currentColor; - */ - } - Ws2812StripShow(); -} - void Ws2812GradientColor(uint32_t schemenr, struct WsColor* mColor, uint32_t range, uint32_t gradRange, uint32_t i) { /* @@ -680,11 +588,6 @@ void Ws2812ShowScheme(void) Ws2812.show_next = 0; } break; - case WS2812_SCHEMES-2: // Running strip - case WS2812_SCHEMES-1: // Running strip - Ws2812RunningStrip(scheme); - Ws2812.show_next = 1; - break; default: if(Settings->light_step_pixels > 0){ Ws2812Steps(scheme -1); From aca519ddecf66e1255d7be8ac6ae6a2ef3b8822d Mon Sep 17 00:00:00 2001 From: Alexey Pavlov Date: Fri, 17 Dec 2021 15:27:34 +0300 Subject: [PATCH 7/8] format fixes --- tasmota/xsns_69_opentherm.ino | 1 + tasmota/xsns_69_opentherm_protocol.ino | 1 + 2 files changed, 2 insertions(+) diff --git a/tasmota/xsns_69_opentherm.ino b/tasmota/xsns_69_opentherm.ino index 38c1ae2c9..23df42a90 100644 --- a/tasmota/xsns_69_opentherm.ino +++ b/tasmota/xsns_69_opentherm.ino @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #ifdef USE_OPENTHERM #define XSNS_69 69 diff --git a/tasmota/xsns_69_opentherm_protocol.ino b/tasmota/xsns_69_opentherm_protocol.ino index 68430d94a..4047884c6 100644 --- a/tasmota/xsns_69_opentherm_protocol.ino +++ b/tasmota/xsns_69_opentherm_protocol.ino @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #ifdef USE_OPENTHERM #include "OpenTherm.h" From 582aa10e0a05cf8424a5b57b5e94a3f03a472188 Mon Sep 17 00:00:00 2001 From: Alexey Pavlov Date: Mon, 20 Dec 2021 19:33:22 +0300 Subject: [PATCH 8/8] pull request fixes --- tasmota/xsns_69_opentherm_protocol.ino | 29 ++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tasmota/xsns_69_opentherm_protocol.ino b/tasmota/xsns_69_opentherm_protocol.ino index 4047884c6..b281f4781 100644 --- a/tasmota/xsns_69_opentherm_protocol.ino +++ b/tasmota/xsns_69_opentherm_protocol.ino @@ -32,7 +32,7 @@ typedef union { uint8_t notSupported : 1; // If set, boiler does not support this command uint8_t supported : 1; // Set if at least one response were successfull uint8_t retryCount : 2; // Retry counter before notSupported flag being set - uint8_t manual : 1; // Only manual call + uint8_t skip : 1; // Only manual call }; } OpenThermParamFlags; @@ -247,12 +247,13 @@ OpenThermCommand sns_opentherm_commands[] = { {// Boiler Lock-out Reset command .m_command_name = "BLOR", .m_command_code = (uint8_t)OpenThermMessageID::Command, - .m_flags = {.manual = 1}, + .m_flags = {.skip = 1}, .m_results = {{.m_u8 = 0}, {.m_u8 = 0}}, .m_ot_make_request = sns_opentherm_send_blor, .m_ot_parse_response = sns_opentherm_parse_generic_u16, .m_ot_appent_telemetry = sns_opentherm_tele_u8_u8}, }; +#define SNS_OT_COMMANDS_COUNT (sizeof(sns_opentherm_commands) / sizeof(OpenThermCommand)) /////////////////////////////////// Process Slave Status Flags & Control ////////////////////////////////////////////////// unsigned long sns_opentherm_set_slave_flags(struct OpenThermCommandT *self, struct OT_BOILER_STATUS_T *status) @@ -445,7 +446,7 @@ unsigned long sns_opentherm_send_blor(struct OpenThermCommandT *self, struct OT_ { AddLog(LOG_LEVEL_ERROR, PSTR("[OTH]: Call Boiler Lock-out Reset")); - self->m_flags.notSupported = true; // Disable future calls of this command + self->m_flags.skip = true; // Disable future calls of this command unsigned int data = 1; //1 : “BLOR”= Boiler Lock-out Reset command data <<= 8; @@ -454,10 +455,16 @@ unsigned long sns_opentherm_send_blor(struct OpenThermCommandT *self, struct OT_ bool sns_opentherm_call_blor() { - OpenThermCommandT *cmd = &sns_opentherm_commands[(sizeof(sns_opentherm_commands) / sizeof(OpenThermCommand))-1]; - if (strcmp(cmd->m_command_name, "BLOR")) return false; - cmd->m_flags.notSupported = false; - return true; + for (int i = 0; i < SNS_OT_COMMANDS_COUNT; ++i) + { + struct OpenThermCommandT *cmd = &sns_opentherm_commands[i]; + if (!strcmp(cmd->m_command_name, "BLOR") && cmd->m_flags.skip) { + cmd->m_flags.skip = false; + return true; + } + } + + return false; } /////////////////////////////////// Generic Single Float ///////////////////////////////////////////////// @@ -517,7 +524,6 @@ void sns_opentherm_parse_boiler_temperature(struct OpenThermCommandT *self, stru //////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define SNS_OT_COMMANDS_COUNT (sizeof(sns_opentherm_commands) / sizeof(OpenThermCommand)) int sns_opentherm_current_command = SNS_OT_COMMANDS_COUNT; unsigned long sns_opentherm_get_next_request(struct OT_BOILER_STATUS_T *boilerStatus) @@ -581,7 +587,7 @@ void sns_opentherm_dump_telemetry() for (int i = 0; i < SNS_OT_COMMANDS_COUNT; ++i) { struct OpenThermCommandT *cmd = &sns_opentherm_commands[i]; - if (!cmd->m_flags.supported) + if (!cmd->m_flags.supported || cmd->m_flags.skip) { continue; } @@ -597,8 +603,9 @@ void sns_opentherm_protocol_reset() for (int i = 0; i < SNS_OT_COMMANDS_COUNT; ++i) { struct OpenThermCommandT *cmd = &sns_opentherm_commands[i]; - cmd->m_flags.notSupported = cmd->m_flags.manual; - cmd->m_flags.retryCount = 0; + int skip = cmd->m_flags.skip; + cmd->m_flags.m_flags = 0; + cmd->m_flags.skip = skip; memset(cmd->m_results, 0, sizeof(OpenThermCommandT::m_results)); } }