From 18bf102e4fa9328883279eb4f440bd6b03279f42 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 13 Aug 2020 16:49:11 +0200 Subject: [PATCH] Prep support for SO114 until SO145 --- tasmota/settings.h | 51 ++++++++++++++++++++++++++++++++----- tasmota/settings.ino | 1 + tasmota/support_command.ino | 18 ++++++++++--- 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/tasmota/settings.h b/tasmota/settings.h index e32b15bf3..ff722b5d6 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -127,15 +127,53 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t white_blend_mode : 1; // bit 23 (v8.4.0.1) - SetOption105 - White Blend Mode - used to be `RGBWWTable` last value `0`, now deprecated in favor of this option uint32_t virtual_ct : 1; // bit 24 (v8.4.0.1) - SetOption106 - Virtual CT - Creates a virtual White ColorTemp for RGBW lights uint32_t virtual_ct_cw : 1; // bit 25 (v8.4.0.1) - SetOption107 - Virtual CT Channel - signals whether the hardware white is cold CW (true) or warm WW (false) - uint32_t spare26 : 1; - uint32_t spare27 : 1; - uint32_t spare28 : 1; - uint32_t spare29 : 1; - uint32_t spare30 : 1; + uint32_t spare26 : 1; // bit 26 + uint32_t spare27 : 1; // bit 27 + uint32_t spare28 : 1; // bit 28 + uint32_t spare29 : 1; // bit 29 + uint32_t spare30 : 1; // bit 30 uint32_t spare31 : 1; // bit 31 }; } SysBitfield4; +typedef union { // Restricted by MISRA-C Rule 18.4 but so useful... + uint32_t data; // Allow bit manipulation using SetOption + struct { // SetOption114 .. SetOption145 + uint32_t spare00 : 1; // bit 0 + uint32_t spare01 : 1; // bit 1 + uint32_t spare02 : 1; // bit 2 + uint32_t spare03 : 1; // bit 3 + uint32_t spare04 : 1; // bit 4 + uint32_t spare05 : 1; // bit 5 + uint32_t spare06 : 1; // bit 6 + uint32_t spare07 : 1; // bit 7 + uint32_t spare08 : 1; // bit 8 + uint32_t spare09 : 1; // bit 9 + uint32_t spare10 : 1; // bit 10 + uint32_t spare11 : 1; // bit 11 + uint32_t spare12 : 1; // bit 12 + uint32_t spare13 : 1; // bit 13 + uint32_t spare14 : 1; // bit 14 + uint32_t spare15 : 1; // bit 15 + uint32_t spare16 : 1; // bit 16 + uint32_t spare17 : 1; // bit 17 + uint32_t spare18 : 1; // bit 18 + uint32_t spare19 : 1; // bit 19 + uint32_t spare20 : 1; // bit 20 + uint32_t spare21 : 1; // bit 21 + uint32_t spare22 : 1; // bit 22 + uint32_t spare23 : 1; // bit 23 + uint32_t spare24 : 1; // bit 24 + uint32_t spare25 : 1; // bit 25 + uint32_t spare26 : 1; // bit 26 + uint32_t spare27 : 1; // bit 27 + uint32_t spare28 : 1; // bit 28 + uint32_t spare29 : 1; // bit 29 + uint32_t spare30 : 1; // bit 30 + uint32_t spare31 : 1; // bit 31 + }; +} SysBitfield5; + typedef union { uint32_t data; // Allow bit manipulation struct { @@ -572,9 +610,10 @@ struct { uint8_t tcp_baudrate; // F41 uint8_t fallback_module; // F42 - uint8_t free_f43[117]; // F43 - Decrement if adding new Setting variables just above and below + uint8_t free_f43[113]; // F43 - Decrement if adding new Setting variables just above and below // Only 32 bit boundary variables below + SysBitfield5 flag5; // EB4 uint16_t pulse_counter_debounce_low; // FB8 uint16_t pulse_counter_debounce_high; // FBA uint32_t keeloq_master_msb; // FBC diff --git a/tasmota/settings.ino b/tasmota/settings.ino index 9beb8f7de..0ea1381dc 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -767,6 +767,7 @@ void SettingsDefaultSet2(void) SysBitfield2 flag2 = { 0 }; SysBitfield3 flag3 = { 0 }; SysBitfield4 flag4 = { 0 }; + SysBitfield5 flag5 = { 0 }; #ifdef ESP8266 // Settings.config_version = 0; // ESP8266 (Has been 0 for long time) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 7b08723ea..17be4b762 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -458,11 +458,11 @@ void CmndStatus(void) if ((0 == payload) || (3 == payload)) { Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS3_LOGGING "\":{\"" D_CMND_SERIALLOG "\":%d,\"" D_CMND_WEBLOG "\":%d,\"" D_CMND_MQTTLOG "\":%d,\"" D_CMND_SYSLOG "\":%d,\"" D_CMND_LOGHOST "\":\"%s\",\"" D_CMND_LOGPORT "\":%d,\"" D_CMND_SSID "\":[\"%s\",\"%s\"],\"" D_CMND_TELEPERIOD "\":%d,\"" - D_JSON_RESOLUTION "\":\"%08X\",\"" D_CMND_SETOPTION "\":[\"%08X\",\"%s\",\"%08X\",\"%08X\"]}}"), + D_JSON_RESOLUTION "\":\"%08X\",\"" D_CMND_SETOPTION "\":[\"%08X\",\"%s\",\"%08X\",\"%08X\",\"%08X\"]}}"), Settings.seriallog_level, Settings.weblog_level, Settings.mqttlog_level, Settings.syslog_level, SettingsText(SET_SYSLOG_HOST), Settings.syslog_port, EscapeJSONString(SettingsText(SET_STASSID1)).c_str(), EscapeJSONString(SettingsText(SET_STASSID2)).c_str(), Settings.tele_period, Settings.flag2.data, Settings.flag.data, ToHex_P((unsigned char*)Settings.param, PARAM8_SIZE, stemp2, sizeof(stemp2)), - Settings.flag3.data, Settings.flag4.data); + Settings.flag3.data, Settings.flag4.data, Settings.flag5.data); MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "3")); } @@ -803,7 +803,7 @@ void CmndSetoption(void) { snprintf_P(XdrvMailbox.command, CMDSZ, PSTR(D_CMND_SETOPTION)); // Rename result shortcut command SO to SetOption - if (XdrvMailbox.index < 114) { + if (XdrvMailbox.index < 146) { uint32_t ptype; uint32_t pindex; if (XdrvMailbox.index <= 31) { // SetOption0 .. 31 = Settings.flag @@ -818,10 +818,14 @@ void CmndSetoption(void) ptype = 3; pindex = XdrvMailbox.index -50; // 0 .. 31 } - else { // SetOption82 .. 113 = Settings.flag4 + else if (XdrvMailbox.index <= 113) { // SetOption82 .. 113 = Settings.flag4 ptype = 4; pindex = XdrvMailbox.index -82; // 0 .. 31 } + else { // SetOption114 .. 145 = Settings.flag5 + ptype = 5; + pindex = XdrvMailbox.index -114; // 0 .. 31 + } if (XdrvMailbox.payload >= 0) { if (1 == ptype) { // SetOption32 .. 49 @@ -911,6 +915,9 @@ void CmndSetoption(void) break; } } + else if (5 == ptype) { // SetOption114 .. 145 + bitWrite(Settings.flag5.data, pindex, XdrvMailbox.payload); + } } else { ptype = 99; // Command Error } @@ -928,6 +935,9 @@ void CmndSetoption(void) else if (4 == ptype) { flag = Settings.flag4.data; } + else if (5 == ptype) { + flag = Settings.flag5.data; + } ResponseCmndIdxChar(GetStateText(bitRead(flag, pindex))); } }