From 12b52fd141093e57ae0ac0e0ac6fac8afa837338 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Tue, 31 Mar 2026 23:27:09 +0200 Subject: [PATCH 1/6] [Settings] Convert some settings to bitfields, making available more future settings --- .gitignore | 9 ++-- src/src/Commands/Rules.cpp | 11 +++-- src/src/DataStructs/SettingsStruct.h | 67 +++++++++++++++++++++++----- 3 files changed, 67 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 138e1916b5..9961261475 100644 --- a/.gitignore +++ b/.gitignore @@ -89,7 +89,8 @@ dependencies.lock src/src/CustomBuild/CompiletimeDefines_generated.h - -sdkconfig.normal_ESP32solo1_4M316k - -src/Custom_.h + +sdkconfig.normal_ESP32solo1_4M316k + +src/Custom_.h +src/idf_component.yml diff --git a/src/src/Commands/Rules.cpp b/src/src/Commands/Rules.cpp index 5339986ae1..c4e4d698b1 100644 --- a/src/src/Commands/Rules.cpp +++ b/src/src/Commands/Rules.cpp @@ -33,10 +33,13 @@ const __FlashStringHelper * Command_Rules_Execute(struct EventStruct *event, con String Command_Rules_UseRules(struct EventStruct *event, const char *Line) { - return Command_GetORSetBool(event, F("Rules:"), - Line, - (bool *)&Settings.UseRules, - 1); + bool useRules = Settings.UseRules; // Workaround for converting Settings.UseRules to a bit-field + const String res = Command_GetORSetBool(event, F("Rules:"), + Line, + (bool *)&useRules, + 1); + Settings.UseRules = useRules; + return res; } const __FlashStringHelper * Command_Rules_Async_Events(struct EventStruct *event, const char *Line) diff --git a/src/src/DataStructs/SettingsStruct.h b/src/src/DataStructs/SettingsStruct.h index d16376482c..f80647302f 100644 --- a/src/src/DataStructs/SettingsStruct.h +++ b/src/src/DataStructs/SettingsStruct.h @@ -447,13 +447,11 @@ class SettingsStruct_tmpl } uint32_t getVariousBits2() const { - uint32_t res; - memcpy(&res, &VariousBits_2, sizeof(VariousBits_2)); - return res; + return VariousBits_2._all_bits; } void setVariousBits2(uint32_t value) { - memcpy(&VariousBits_2, &value, sizeof(VariousBits_2)); + VariousBits_2._all_bits = value; } bool getNetworkEnabled(ESPEasy::net::networkIndex_t index) const; @@ -514,14 +512,59 @@ class SettingsStruct_tmpl uint8_t SDLogLevel = 0; uint32_t BaudRate = 115200; uint32_t MessageDelay_unused = 0; // MQTT settings now moved to the controller settings. - uint8_t deepSleep_wakeTime = 0; // 0 = Sleep Disabled, else time awake from sleep in seconds - boolean CustomCSS = false; - boolean DST = false; - uint8_t WDI2CAddress = 0; - boolean UseRules = false; - boolean UseSerial = false; - boolean UseSSDP = false; - uint8_t ExternalTimeSource = 0; + union { + struct { + uint32_t deepSleep_wakeTime : 8; // Bit 0..7, 0 = Sleep Disabled, else time awake from sleep in seconds + uint32_t CustomCSS : 1; // Bit 8 used + uint32_t unusedU0_09 : 1; // Bit 9 + uint32_t unusedU0_10 : 1; // Bit 10 + uint32_t unusedU0_11 : 1; // Bit 11 + uint32_t unusedU0_12 : 1; // Bit 12 + uint32_t unusedU0_13 : 1; // Bit 13 + uint32_t unusedU0_14 : 1; // Bit 14 + uint32_t unusedU0_15 : 1; // Bit 15 + uint32_t DST : 1; // Bit 16 used + uint32_t unusedU0_17 : 1; // Bit 17 + uint32_t unusedU0_18 : 1; // Bit 18 + uint32_t unusedU0_19 : 1; // Bit 19 + uint32_t unusedU0_20 : 1; // Bit 20 + uint32_t unusedU0_21 : 1; // Bit 21 + uint32_t unusedU0_22 : 1; // Bit 22 + uint32_t unusedU0_23 : 1; // Bit 23 + uint32_t WDI2CAddress : 8; // Bit 24..31 used + }; + uint32_t _unnamedUnion0{}; + }; + union { + struct { + uint32_t UseRules : 1; // Bit 0 used + uint32_t unusedU1_01 : 1; // Bit 1 + uint32_t unusedU1_02 : 1; // Bit 2 + uint32_t unusedU1_03 : 1; // Bit 3 + uint32_t unusedU1_04 : 1; // Bit 4 + uint32_t unusedU1_05 : 1; // Bit 5 + uint32_t unusedU1_06 : 1; // Bit 6 + uint32_t unusedU1_07 : 1; // Bit 7 + uint32_t UseSerial : 1; // Bit 8 used + uint32_t unusedU1_09 : 1; // Bit 9 + uint32_t unusedU1_10 : 1; // Bit 10 + uint32_t unusedU1_11 : 1; // Bit 11 + uint32_t unusedU1_12 : 1; // Bit 12 + uint32_t unusedU1_13 : 1; // Bit 13 + uint32_t unusedU1_14 : 1; // Bit 14 + uint32_t unusedU1_15 : 1; // Bit 15 + uint32_t UseSSDP : 1; // Bit 16 used + uint32_t unusedU1_17 : 1; // Bit 17 + uint32_t unusedU1_18 : 1; // Bit 18 + uint32_t unusedU1_19 : 1; // Bit 19 + uint32_t unusedU1_20 : 1; // Bit 20 + uint32_t unusedU1_21 : 1; // Bit 21 + uint32_t unusedU1_22 : 1; // Bit 22 + uint32_t unusedU1_23 : 1; // Bit 23 + uint32_t ExternalTimeSource : 8; // Bit 24..31 used + }; + uint32_t _unnamedUnion1{}; + }; uint32_t WireClockStretchLimit = 0; union { struct { From e2ad9bfef05fc7c59ed36a0cca8e018d0833a504 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Sat, 4 Apr 2026 14:00:43 +0200 Subject: [PATCH 2/6] [Settings] Convert more settings to bitfields, compile-time optional to enable when needed --- src/_C002.cpp | 2 +- src/_C013.cpp | 6 +- src/_C014.cpp | 2 +- src/_C015.cpp | 6 +- src/_P001_Switch.ino | 2 +- src/_P003_Pulse.ino | 2 +- src/_P009_MCP.ino | 2 +- src/_P019_PCF8574.ino | 2 +- src/_P031_SHT1X.ino | 2 +- src/_P037_MQTTImport.ino | 2 +- src/_P055_Chiming.ino | 2 +- src/_P059_Encoder.ino | 2 +- src/_P075_Nextion.ino | 2 +- src/_P088_HeatpumpIR.ino | 2 +- src/_P094_CULReader.ino | 4 +- src/_Plugin_Helper.cpp | 2 +- src/src/Commands/Blynk.cpp | 2 +- src/src/Commands/Notifications.cpp | 2 +- src/src/Commands/Tasks.cpp | 8 +- src/src/DataStructs/Caches.cpp | 2 +- src/src/DataStructs/SettingsStruct.h | 231 +++++++++++++++++- src/src/DataStructs_templ/SettingsStruct.cpp | 12 +- src/src/ESPEasyCore/Controller.cpp | 8 +- src/src/Globals/CPlugins.cpp | 10 +- src/src/Globals/Plugins.cpp | 16 +- src/src/Helpers/ESPEasy_FactoryDefault.cpp | 2 +- src/src/Helpers/ESPEasy_Storage.cpp | 20 +- src/src/Helpers/ESPEasy_checks.cpp | 10 +- src/src/Helpers/Hardware.cpp | 4 +- src/src/Helpers/I2C_access.cpp | 2 +- src/src/Helpers/Misc.cpp | 8 +- src/src/Helpers/PeriodicalActions.cpp | 2 +- src/src/Helpers/Scheduler_PluginTaskTimer.cpp | 2 +- src/src/Helpers/Scheduler_TaskDeviceTimer.cpp | 4 +- src/src/Helpers/StringParser.cpp | 10 +- src/src/Helpers/_CPlugin_Helper_mqtt.cpp | 83 +++---- src/src/Helpers/_CPlugin_Helper_webform.cpp | 6 +- src/src/Helpers/_CPlugin_init.cpp | 4 +- src/src/Helpers/_Plugin_Helper_GPIO.cpp | 6 +- src/src/Helpers/_Plugin_init.cpp | 2 +- src/src/PluginStructs/P001_data_struct.cpp | 2 +- src/src/PluginStructs/P146_data_struct.cpp | 2 +- src/src/WebServer/ControllerPage.cpp | 8 +- src/src/WebServer/DevicesPage.cpp | 20 +- src/src/WebServer/JSON.cpp | 4 +- src/src/WebServer/Metrics.cpp | 2 +- src/src/WebServer/NotificationPage.cpp | 10 +- src/src/WebServer/WebTemplateParser.cpp | 2 +- 48 files changed, 377 insertions(+), 171 deletions(-) diff --git a/src/_C002.cpp b/src/_C002.cpp index e2fa84d88b..0717c13e9d 100644 --- a/src/_C002.cpp +++ b/src/_C002.cpp @@ -96,7 +96,7 @@ bool CPlugin_002(CPlugin::Function function, struct EventStruct *event, String& constexpr pluginID_t PLUGIN_ID_HEATPUMP_IR(88); # endif // if defined(USES_P088) - if (Settings.TaskDeviceEnabled[x] && + if (Settings.TaskDeviceEnabled(x) && (Settings.TaskDeviceSendData[ControllerID][x] || (Settings.getPluginID_for_task(x) == PLUGIN_ID_DOMOTICZ_HELPER) // Domoticz helper doesn't have controller checkboxes... # if defined(USES_P088) diff --git a/src/_C013.cpp b/src/_C013.cpp index 569766765c..530b26103c 100644 --- a/src/_C013.cpp +++ b/src/_C013.cpp @@ -272,7 +272,7 @@ void C013_Receive(struct EventStruct *event) { if (currentPluginID == infoReply->deviceNumber) { // Check to see if task already is set to receive from this host if ((Settings.TaskDeviceDataFeed[infoReply->destTaskIndex] == infoReply->sourceUnit) && - Settings.TaskDeviceEnabled[infoReply->destTaskIndex]) { + Settings.TaskDeviceEnabled(infoReply->destTaskIndex)) { mustUpdateCurrentTask = true; } } @@ -285,7 +285,7 @@ void C013_Receive(struct EventStruct *event) { Settings.TaskDeviceDataFeed[infoReply->destTaskIndex] = infoReply->sourceUnit; // remote feed store unit nr sending the data if (mustUpdateCurrentTask) { - Settings.TaskDeviceEnabled[infoReply->destTaskIndex] = true; + Settings.TaskDeviceEnabled(infoReply->destTaskIndex, true); } constexpr pluginID_t DUMMY_PLUGIN_ID{ 33 }; @@ -332,7 +332,7 @@ void C013_Receive(struct EventStruct *event) { SaveTaskSettings(taskIndex); SaveSettings(); - if (Settings.TaskDeviceEnabled[taskIndex]) { + if (Settings.TaskDeviceEnabled(taskIndex)) { struct EventStruct TempEvent(taskIndex); TempEvent.Source = EventValueSource::Enum::VALUE_SOURCE_UDP; diff --git a/src/_C014.cpp b/src/_C014.cpp index 852af381fd..5126874f89 100644 --- a/src/_C014.cpp +++ b/src/_C014.cpp @@ -399,7 +399,7 @@ bool CPlugin_014(CPlugin::Function function, struct EventStruct *event, String& deviceName = getTaskDeviceName(x); - if (validDeviceIndex(DeviceIndex) && Settings.TaskDeviceEnabled[x]) { // Device is enabled so send information + if (validDeviceIndex(DeviceIndex) && Settings.TaskDeviceEnabled(x)) { // Device is enabled so send information // device enabled valuesList = EMPTY_STRING; diff --git a/src/_C015.cpp b/src/_C015.cpp index c9afedd2f9..bd6e12b6a6 100644 --- a/src/_C015.cpp +++ b/src/_C015.cpp @@ -145,7 +145,7 @@ bool CPlugin_015(CPlugin::Function function, struct EventStruct *event, String& if (validProtocolIndex(ProtocolIndex)) { const cpluginID_t number = getCPluginID_from_ProtocolIndex(ProtocolIndex); - if ((i != event->ControllerIndex) && (number == 15) && Settings.ControllerEnabled[i]) { + if ((i != event->ControllerIndex) && (number == 15) && Settings.ControllerEnabled(i)) { success = false; // FIXME: this will only show a warning message and not uncheck "enabled" in webform. @@ -182,7 +182,7 @@ bool CPlugin_015(CPlugin::Function function, struct EventStruct *event, String& break; } - if (!Settings.ControllerEnabled[event->ControllerIndex]) { + if (!Settings.ControllerEnabled(event->ControllerIndex)) { break; } @@ -270,7 +270,7 @@ bool do_process_c015_delay_queue(cpluginID_t cpluginID, const Queue_element_base const C015_queue_element& element = static_cast(element_base); // *INDENT-ON* -if (!Settings.ControllerEnabled[element._controller_idx]) { +if (!Settings.ControllerEnabled(element._controller_idx)) { // controller has been disabled. Answer true to flush queue. return true; } diff --git a/src/_P001_Switch.ino b/src/_P001_Switch.ino index 0780d4850b..2fc49e12e5 100644 --- a/src/_P001_Switch.ino +++ b/src/_P001_Switch.ino @@ -178,7 +178,7 @@ boolean Plugin_001(uint8_t function, struct EventStruct *event, String& string) } success = true; } else { - success = getDiscoveryVType(event, Settings.TaskDevicePin1Inversed[event->TaskIndex] + success = getDiscoveryVType(event, Settings.TaskDevicePin1Inversed(event->TaskIndex) ? Plugin_QueryVType_BinarySensorInv : Plugin_QueryVType_BinarySensor, 255, event->Par5); # if FEATURE_MQTT_DEVICECLASS diff --git a/src/_P003_Pulse.ino b/src/_P003_Pulse.ino index ea0af238e5..58d351a3a1 100644 --- a/src/_P003_Pulse.ino +++ b/src/_P003_Pulse.ino @@ -229,7 +229,7 @@ boolean Plugin_003(uint8_t function, struct EventStruct *event, String& string) config.gpio = CONFIG_PIN1; config.taskIndex = event->TaskIndex; config.interruptPinMode = static_cast(PCONFIG(P003_IDX_MODETYPE)); - config.pullupPinMode = Settings.TaskDevicePin1PullUp[event->TaskIndex] ? INPUT_PULLUP : INPUT; + config.pullupPinMode = Settings.TaskDevicePin1PullUp(event->TaskIndex) ? INPUT_PULLUP : INPUT; // FIXME TD-er: Must set the state using globalMapPortStatus diff --git a/src/_P009_MCP.ino b/src/_P009_MCP.ino index 1d38ef4f89..95c9006b19 100644 --- a/src/_P009_MCP.ino +++ b/src/_P009_MCP.ino @@ -146,7 +146,7 @@ boolean Plugin_009(uint8_t function, struct EventStruct *event, String& string) # if FEATURE_MQTT_DISCOVER case PLUGIN_GET_DISCOVERY_VTYPES: - success = getDiscoveryVType(event, Settings.TaskDevicePin1Inversed[event->TaskIndex] + success = getDiscoveryVType(event, Settings.TaskDevicePin1Inversed(event->TaskIndex) ? Plugin_QueryVType_BinarySensorInv : Plugin_QueryVType_BinarySensor, 255, event->Par5); # if FEATURE_MQTT_DEVICECLASS diff --git a/src/_P019_PCF8574.ino b/src/_P019_PCF8574.ino index f046a426ca..31c63d68e7 100644 --- a/src/_P019_PCF8574.ino +++ b/src/_P019_PCF8574.ino @@ -149,7 +149,7 @@ boolean Plugin_019(uint8_t function, struct EventStruct *event, String& string) # if FEATURE_MQTT_DISCOVER case PLUGIN_GET_DISCOVERY_VTYPES: - success = getDiscoveryVType(event, Settings.TaskDevicePin1Inversed[event->TaskIndex] + success = getDiscoveryVType(event, Settings.TaskDevicePin1Inversed(event->TaskIndex) ? Plugin_QueryVType_BinarySensorInv : Plugin_QueryVType_BinarySensor, 255, event->Par5); # if FEATURE_MQTT_DEVICECLASS diff --git a/src/_P031_SHT1X.ino b/src/_P031_SHT1X.ino index 81c54986e1..e4ec0ce8a6 100644 --- a/src/_P031_SHT1X.ino +++ b/src/_P031_SHT1X.ino @@ -85,7 +85,7 @@ boolean Plugin_031(uint8_t function, struct EventStruct *event, String& string) # endif // ifndef BUILD_NO_DEBUG P031_data->init( CONFIG_PIN1, CONFIG_PIN2, - Settings.TaskDevicePin1PullUp[event->TaskIndex], + Settings.TaskDevicePin1PullUp(event->TaskIndex), PCONFIG(0)); # ifndef BUILD_NO_DEBUG diff --git a/src/_P037_MQTTImport.ino b/src/_P037_MQTTImport.ino index 44f158a5a4..ded8b2f592 100644 --- a/src/_P037_MQTTImport.ino +++ b/src/_P037_MQTTImport.ino @@ -748,7 +748,7 @@ bool MQTT_unsubscribe_037(struct EventStruct *event) if (task != event->TaskIndex) { constexpr pluginID_t P037_PLUGIN_ID{ PLUGIN_ID_037 }; - if (Settings.TaskDeviceEnabled[task] && + if (Settings.TaskDeviceEnabled(task) && (Settings.getPluginID_for_task(task) == P037_PLUGIN_ID)) { P037_data_struct *P037_data_other = static_cast(getPluginTaskData(task)); diff --git a/src/_P055_Chiming.ino b/src/_P055_Chiming.ino index 629b698d7a..2e98fb7b82 100644 --- a/src/_P055_Chiming.ino +++ b/src/_P055_Chiming.ino @@ -186,7 +186,7 @@ boolean Plugin_055(uint8_t function, struct EventStruct *event, String& string) } if (Plugin_055_Data != nullptr) { - Plugin_055_Data->lowActive = Settings.TaskDevicePin1Inversed[event->TaskIndex]; + Plugin_055_Data->lowActive = Settings.TaskDevicePin1Inversed(event->TaskIndex); Plugin_055_Data->millisChimeTime = PCONFIG(0); Plugin_055_Data->millisPauseTime = PCONFIG(1); Plugin_055_Data->chimeClock = PCONFIG(2); diff --git a/src/_P059_Encoder.ino b/src/_P059_Encoder.ino index 363030e383..15a7d663ca 100644 --- a/src/_P059_Encoder.ino +++ b/src/_P059_Encoder.ino @@ -143,7 +143,7 @@ boolean Plugin_059(uint8_t function, struct EventStruct *event, String& string) if (validGpio(pin)) { - // pinMode(pin, (Settings.TaskDevicePin1PullUp[event->TaskIndex]) ? INPUT_PULLUP : INPUT); + // pinMode(pin, Settings.TaskDevicePin1PullUp(event->TaskIndex) ? INPUT_PULLUP : INPUT); constexpr pluginID_t P059_PLUGIN_ID{ PLUGIN_ID_059 }; const uint32_t key = createKey(P059_PLUGIN_ID, pin); diff --git a/src/_P075_Nextion.ino b/src/_P075_Nextion.ino index d3ed479979..3fe871f7d0 100644 --- a/src/_P075_Nextion.ino +++ b/src/_P075_Nextion.ino @@ -115,7 +115,7 @@ boolean Plugin_075(uint8_t function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { // ** DEVELOPER DEBUG MESSAGE AREA ** - // int datax = static_cast(Settings.TaskDeviceEnabled[event->TaskIndex]); // Debug value. + // int datax = static_cast(Settings.TaskDeviceEnabled(event->TaskIndex)); // Debug value. // String Data = "Debug. Plugin Enable State: "; // Data += String(datax); // addFormNote(Data); diff --git a/src/_P088_HeatpumpIR.ino b/src/_P088_HeatpumpIR.ino index cb669b3d00..8ae617f23a 100644 --- a/src/_P088_HeatpumpIR.ino +++ b/src/_P088_HeatpumpIR.ino @@ -92,7 +92,7 @@ boolean Plugin_088(uint8_t function, struct EventStruct *event, String& string) if (Settings.Protocol[i] == 2) { controllerNr = i; } } - if (Settings.ControllerEnabled[controllerNr]) + if (Settings.ControllerEnabled(controllerNr)) { addRowLabel(F("IDX")); String id = F("TDID"); // ="taskdeviceid" diff --git a/src/_P094_CULReader.ino b/src/_P094_CULReader.ino index e1dadd6d2d..ca81c7471a 100644 --- a/src/_P094_CULReader.ino +++ b/src/_P094_CULReader.ino @@ -269,7 +269,7 @@ boolean Plugin_094(uint8_t function, struct EventStruct *event, String& string) } case PLUGIN_FIFTY_PER_SECOND: { - if (Settings.TaskDeviceEnabled[event->TaskIndex]) { + if (Settings.TaskDeviceEnabled(event->TaskIndex)) { P094_data_struct *P094_data = static_cast(getPluginTaskData(event->TaskIndex)); @@ -468,7 +468,7 @@ boolean Plugin_094(uint8_t function, struct EventStruct *event, String& string) { // event->String1 => topic; // event->String2 => payload; - if (Settings.TaskDeviceEnabled[event->TaskIndex]) { + if (Settings.TaskDeviceEnabled(event->TaskIndex)) { const bool fromCUL = false; if (!Plugin_094_match_all(event->TaskIndex, event->String2, event->String1, fromCUL)) { diff --git a/src/_Plugin_Helper.cpp b/src/_Plugin_Helper.cpp index 5c720cc649..32b1150def 100644 --- a/src/_Plugin_Helper.cpp +++ b/src/_Plugin_Helper.cpp @@ -55,7 +55,7 @@ bool initPluginTaskData(taskIndex_t taskIndex, PluginTaskData_base *data) { clearPluginTaskData(taskIndex); if (data != nullptr) { - if (Settings.TaskDeviceEnabled[taskIndex]) { + if (Settings.TaskDeviceEnabled(taskIndex)) { Plugin_task_data[taskIndex] = data; Plugin_task_data[taskIndex]->_taskdata_pluginID = Settings.getPluginID_for_task(taskIndex); diff --git a/src/src/Commands/Blynk.cpp b/src/src/Commands/Blynk.cpp index acd47c5e23..403e77d966 100644 --- a/src/src/Commands/Blynk.cpp +++ b/src/src/Commands/Blynk.cpp @@ -21,7 +21,7 @@ controllerIndex_t firstEnabledBlynk_ControllerIndex() { if (validProtocolIndex(ProtocolIndex)) { const cpluginID_t number = getCPluginID_from_ProtocolIndex(ProtocolIndex); - if ((number == 12) && Settings.ControllerEnabled[i]) { + if ((number == 12) && Settings.ControllerEnabled(i)) { return i; } } diff --git a/src/src/Commands/Notifications.cpp b/src/src/Commands/Notifications.cpp index 56acef3f1f..4f1e17f757 100644 --- a/src/src/Commands/Notifications.cpp +++ b/src/src/Commands/Notifications.cpp @@ -21,7 +21,7 @@ const __FlashStringHelper * Command_Notifications_Notify(struct EventStruct *eve if (event->Par1 > 0) { int index = event->Par1 - 1; - if (Settings.NotificationEnabled[index] && Settings.Notification[index] != INVALID_N_PLUGIN_ID.value) { + if (Settings.NotificationEnabled(index) && Settings.Notification[index] != INVALID_N_PLUGIN_ID.value) { nprotocolIndex_t NotificationProtocolIndex = getNProtocolIndex(npluginID_t::toPluginID(Settings.Notification[index])); if (validNProtocolIndex(NotificationProtocolIndex )) { diff --git a/src/src/Commands/Tasks.cpp b/src/src/Commands/Tasks.cpp index 192602e895..11b721e068 100644 --- a/src/src/Commands/Tasks.cpp +++ b/src/src/Commands/Tasks.cpp @@ -116,7 +116,7 @@ const __FlashStringHelper * taskValueSet(struct EventStruct *event, const char * success = false; return F("NOT_A_DUMMY_TASK"); } - if (!Settings.TaskDeviceEnabled[taskIndex]) { + if (!Settings.TaskDeviceEnabled(taskIndex)) { success = false; return F("TASK_NOT_ENABLED"); } @@ -375,7 +375,7 @@ const __FlashStringHelper * Command_Task_ValueToggle(struct EventStruct *event, if (!validateAndParseTaskValueArguments(event, Line, taskIndex, varNr)) { return F("INVALID_PARAMETERS"); } - if (!Settings.TaskDeviceEnabled[taskIndex]) { + if (!Settings.TaskDeviceEnabled(taskIndex)) { return F("TASK_NOT_ENABLED"); } @@ -411,7 +411,7 @@ const __FlashStringHelper * Command_ScheduleTask_Run(struct EventStruct *event, if (!validateAndParseTaskIndexArguments(event, Line, taskIndex) || event->Par2 < 0) { return F("INVALID_PARAMETERS"); } - if (!Settings.TaskDeviceEnabled[taskIndex]) { + if (!Settings.TaskDeviceEnabled(taskIndex)) { return F("TASK_NOT_ENABLED"); } @@ -433,7 +433,7 @@ const __FlashStringHelper * Command_Task_Run(struct EventStruct *event, const ch if (!validateAndParseTaskIndexArguments(event, Line, taskIndex) || event->Par2 < 0) { return F("INVALID_PARAMETERS"); } - if (!Settings.TaskDeviceEnabled[taskIndex]) { + if (!Settings.TaskDeviceEnabled(taskIndex)) { return F("TASK_NOT_ENABLED"); } uint32_t unixTime = 0; diff --git a/src/src/DataStructs/Caches.cpp b/src/src/DataStructs/Caches.cpp index 29f76b27eb..9db3fe6f59 100644 --- a/src/src/DataStructs/Caches.cpp +++ b/src/src/DataStructs/Caches.cpp @@ -75,7 +75,7 @@ void Caches::updateActiveTaskUseSerial0() { { const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(task); - if (Settings.TaskDeviceEnabled[task] && validDeviceIndex(DeviceIndex)) { + if (Settings.TaskDeviceEnabled(task) && validDeviceIndex(DeviceIndex)) { if ((Device[DeviceIndex].Type == DEVICE_TYPE_SERIAL) || (Device[DeviceIndex].Type == DEVICE_TYPE_SERIAL_PLUS1)) { const ESPEasySerialPort port = ESPeasySerialType::getSerialType( diff --git a/src/src/DataStructs/SettingsStruct.h b/src/src/DataStructs/SettingsStruct.h index f80647302f..d8763ad9f7 100644 --- a/src/src/DataStructs/SettingsStruct.h +++ b/src/src/DataStructs/SettingsStruct.h @@ -59,6 +59,32 @@ enum class PinBootState { }; +/** + * Determine what additional bit-fields to use, only enable when needed because of additional build-size + * First use up the bits in VariousBits_3 (like VariousBits_1 and VariousBits_2) because of the build size increases! + */ +#ifndef FEATURE_UNNAMED_BITFIELDS_1 + #define FEATURE_UNNAMED_BITFIELDS_1 0 // 2x 7 bits globally, adds ESP32: 36 ESP8266: 64 bytes +#endif +#ifndef FEATURE_UNNAMED_BITFIELDS_2 + #define FEATURE_UNNAMED_BITFIELDS_2 0 // 3x 7 bits globally, adds ESP32: 256 ESP8266: 176 bytes +#endif +#ifndef FEATURE_TASKDEVICE_BITFIELDS_4 + #define FEATURE_TASKDEVICE_BITFIELDS_4 0 // 7 bits per TaskDevice, adds ESP32: 32 ESP8266: 64 bytes + 16 bytes per bit-function +#endif +#ifndef FEATURE_TASKDEVICE_BITFIELDS_5 + #define FEATURE_TASKDEVICE_BITFIELDS_5 0 // 7 bits per TaskDevice, adds ESP32: 16 ESP8266: 64 bytes + 16 bytes per bit-function +#endif +#ifndef FEATURE_TASKDEVICE_BITFIELDS_6 + #define FEATURE_TASKDEVICE_BITFIELDS_6 0 // 7 bits per TaskDevice, adds ESP32: -80 ESP8266: 172 bytes + 16 bytes per bit-function +#endif +#ifndef FEATURE_CONTROLLER_BITFIELDS_1 + #define FEATURE_CONTROLLER_BITFIELDS_1 0 // 7 bits per Controller, adds ESP32: 168 ESP8266: 192 bytes + 16 bytes per bit-function +#endif +#ifndef FEATURE_NOTIFICATION_BITFIELDS_1 + #define FEATURE_NOTIFICATION_BITFIELDS_1 0 // 7 bits per Notifier, adds ESP32: 108 ESP8266: 64 bytes + 16 bytes per bit-function +#endif + @@ -196,6 +222,66 @@ class SettingsStruct_tmpl inline void PassiveWiFiScan(bool value) { VariousBits_2.PassiveWiFiScan = !value; } #endif + #if FEATURE_TASKDEVICE_BITFIELDS_4 + inline const bool TaskDevicePin1PullUp(uint32_t taskIndex) { return TaskDeviceBitfield_4[taskIndex].TaskDevicePin1PullUp; } + inline void TaskDevicePin1PullUp(uint32_t taskIndex, bool state) { TaskDeviceBitfield_4[taskIndex].TaskDevicePin1PullUp = state; } + + // Template for accessor, using bool + inline const bool TaskDeviceBitfield4_01(uint32_t taskIndex) { return TaskDeviceBitfield_4[taskIndex].unusedU4_01; } + inline void TaskDeviceBitfield4_01(uint32_t taskIndex, bool state) { TaskDeviceBitfield_4[taskIndex].unusedU4_01 = state; } + #else // if FEATURE_TASKDEVICE_BITFIELDS_4 + inline const bool TaskDevicePin1PullUp(uint32_t taskIndex) { return _TaskDevicePin1PullUp[taskIndex]; } + inline void TaskDevicePin1PullUp(uint32_t taskIndex, bool state) { _TaskDevicePin1PullUp[taskIndex] = state; } + #endif // if FEATURE_TASKDEVICE_BITFIELDS_4 + + #if FEATURE_TASKDEVICE_BITFIELDS_5 + inline const bool TaskDevicePin1Inversed(uint32_t taskIndex) { return TaskDeviceBitfield_5[taskIndex].TaskDevicePin1Inversed; } + inline void TaskDevicePin1Inversed(uint32_t taskIndex, bool state) { TaskDeviceBitfield_5[taskIndex].TaskDevicePin1Inversed = state; } + + // Template for accessor, using uint8_t, can be multiple bits, if desired + inline const uint8_t TaskDeviceBitfield5_01(uint32_t taskIndex) { return TaskDeviceBitfield_5[taskIndex].unusedU5_01; } + inline void TaskDeviceBitfield5_01(uint32_t taskIndex, uint8_t value) { TaskDeviceBitfield_5[taskIndex].unusedU5_01 = value; } + #else // if FEATURE_TASKDEVICE_BITFIELDS_5 + inline const bool TaskDevicePin1Inversed(uint32_t taskIndex) { return _TaskDevicePin1Inversed[taskIndex]; } + inline void TaskDevicePin1Inversed(uint32_t taskIndex, bool state) { _TaskDevicePin1Inversed[taskIndex] = state; } + #endif // if FEATURE_TASKDEVICE_BITFIELDS_5 + + #if FEATURE_TASKDEVICE_BITFIELDS_6 + inline const bool TaskDeviceEnabled(taskIndex_t taskIndex) { return TaskDeviceBitfield_6[taskIndex].TaskDeviceEnabled; } + inline void TaskDeviceEnabled(taskIndex_t taskIndex, bool state) { TaskDeviceBitfield_6[taskIndex].TaskDeviceEnabled = state; } + + // Template for accessor, using uint8_t, can be multiple bits, if desired + inline const uint8_t TaskDeviceBitfield6_01(uint32_t taskIndex) { return TaskDeviceBitfield_6[taskIndex].unusedU6_01; } + inline void TaskDeviceBitfield6_01(uint32_t taskIndex, uint8_t value) { TaskDeviceBitfield_6[taskIndex].unusedU6_01 = value; } + #else // if FEATURE_TASKDEVICE_BITFIELDS_6 + inline const bool TaskDeviceEnabled(taskIndex_t taskIndex) { return _TaskDeviceEnabled[taskIndex]; } + inline void TaskDeviceEnabled(taskIndex_t taskIndex, bool state) { _TaskDeviceEnabled[taskIndex] = state; } + #endif // if FEATURE_TASKDEVICE_BITFIELDS_6 + + #if FEATURE_CONTROLLER_BITFIELDS_1 + inline const bool ControllerEnabled(controllerIndex_t controllerIndex) { return ControllerBitfield_1[controllerIndex].ControllerEnabled; } + inline void ControllerEnabled(controllerIndex_t controllerIndex, bool state) { ControllerBitfield_1[controllerIndex].ControllerEnabled = state; } + + // Template for accessor, using bool + inline const bool ControllerBitfield1_01(controllerIndex_t controllerIndex) { return ControllerBitfield_1[controllerIndex].unusedC1_01; } + inline void ControllerBitfield1_01(controllerIndex_t controllerIndex, uint8_t value) { ControllerBitfield_1[controllerIndex].unusedC1_01 = value; } + #else // if FEATURE_CONTROLLER_BITFIELDS_1 + inline const bool ControllerEnabled(controllerIndex_t controllerIndex) { return _ControllerEnabled[controllerIndex]; } + inline void ControllerEnabled(controllerIndex_t controllerIndex, bool state) { _ControllerEnabled[controllerIndex] = state; } + #endif // if FEATURE_CONTROLLER_BITFIELDS_1 + + #if FEATURE_NOTIFICATION_BITFIELDS_1 + inline const bool NotificationEnabled(uint8_t notificationIndex) { return NotificationBitfield_1[notificationIndex].NotificationEnabled; } + inline void NotificationEnabled(uint8_t notificationIndex, bool state) { NotificationBitfield_1[notificationIndex].NotificationEnabled = state; } + + // Template for accessor, using bool + inline const bool NotificationBitfield1_01(uint8_t notificationIndex) { return NotificationBitfield_1[notificationIndex].unusedN1_01; } + inline void NotificationBitfield1_01(uint8_t notificationIndex, uint8_t value) { NotificationBitfield_1[notificationIndex].unusedN1_01 = value; } + #else // if FEATURE_NOTIFICATION_BITFIELDS_1 + inline const bool NotificationEnabled(uint8_t notificationIndex) { return _NotificationEnabled[notificationIndex]; } + inline void NotificationEnabled(uint8_t notificationIndex, bool state) { _NotificationEnabled[notificationIndex] = state; } + #endif // if FEATURE_NOTIFICATION_BITFIELDS_1 + // Connect to Hidden SSID using channel and BSSID // This is much slower, but appears to be needed for some access points // like MikroTik. @@ -512,6 +598,7 @@ class SettingsStruct_tmpl uint8_t SDLogLevel = 0; uint32_t BaudRate = 115200; uint32_t MessageDelay_unused = 0; // MQTT settings now moved to the controller settings. + #if FEATURE_UNNAMED_BITFIELDS_1 union { struct { uint32_t deepSleep_wakeTime : 8; // Bit 0..7, 0 = Sleep Disabled, else time awake from sleep in seconds @@ -535,6 +622,13 @@ class SettingsStruct_tmpl }; uint32_t _unnamedUnion0{}; }; + #else // if FEATURE_UNNAMED_BITFIELDS_1 + uint8_t deepSleep_wakeTime = 0; // 0 = Sleep Disabled, else time awake from sleep in seconds + boolean CustomCSS = false; + boolean DST = false; + uint8_t WDI2CAddress = 0; + #endif // if FEATURE_UNNAMED_BITFIELDS_1 + #if FEATURE_UNNAMED_BITFIELDS_2 union { struct { uint32_t UseRules : 1; // Bit 0 used @@ -565,6 +659,12 @@ class SettingsStruct_tmpl }; uint32_t _unnamedUnion1{}; }; + #else // if FEATURE_UNNAMED_BITFIELDS_2 + boolean UseRules = false; + boolean UseSerial = false; + boolean UseSSDP = false; + uint8_t ExternalTimeSource = 0; + #endif // if FEATURE_UNNAMED_BITFIELDS_2 uint32_t WireClockStretchLimit = 0; union { struct { @@ -645,9 +745,41 @@ class SettingsStruct_tmpl }; int8_t TaskDevicePin[4][N_TASKS]{}; }; - boolean TaskDevicePin1PullUp[N_TASKS] = {0}; + #if FEATURE_TASKDEVICE_BITFIELDS_4 + union { + boolean TaskDeviceBitfield_4_internal[N_TASKS]{}; + struct { + uint8_t TaskDevicePin1PullUp : 1; // Bit 0 used + uint8_t unusedU4_01 : 1; // Bit 1 + uint8_t unusedU4_02 : 1; // Bit 2 + uint8_t unusedU4_03 : 1; // Bit 3 + uint8_t unusedU4_04 : 1; // Bit 4 + uint8_t unusedU4_05 : 1; // Bit 5 + uint8_t unusedU4_06 : 1; // Bit 6 + uint8_t unusedU4_07 : 1; // Bit 7 + } TaskDeviceBitfield_4[N_TASKS]; + }; + #else // if FEATURE_TASKDEVICE_BITFIELDS_4 + boolean _TaskDevicePin1PullUp[N_TASKS] = {0}; + #endif // if FEATURE_TASKDEVICE_BITFIELDS_4 int16_t TaskDevicePluginConfig[N_TASKS][PLUGIN_CONFIGVAR_MAX]{}; - boolean TaskDevicePin1Inversed[N_TASKS] = {0}; + #if FEATURE_TASKDEVICE_BITFIELDS_5 + union { + boolean TaskDeviceBitfield5_internal[N_TASKS]{}; + struct { + uint8_t TaskDevicePin1Inversed : 1; // Bit 0 used + uint8_t unusedU5_01 : 1; // Bit 1 + uint8_t unusedU5_02 : 1; // Bit 2 + uint8_t unusedU5_03 : 1; // Bit 3 + uint8_t unusedU5_04 : 1; // Bit 4 + uint8_t unusedU5_05 : 1; // Bit 5 + uint8_t unusedU5_06 : 1; // Bit 6 + uint8_t unusedU5_07 : 1; // Bit 7 + } TaskDeviceBitfield_5[N_TASKS]; + }; + #else //if FEATURE_TASKDEVICE_BITFIELDS_5 + boolean _TaskDevicePin1Inversed[N_TASKS] = {0}; + #endif //if FEATURE_TASKDEVICE_BITFIELDS_5 float TaskDevicePluginConfigFloat[N_TASKS][PLUGIN_CONFIGFLOATVAR_MAX]{}; // FIXME TD-er: When used on ESP8266, this conversion union may not work @@ -660,15 +792,96 @@ class SettingsStruct_tmpl uint8_t VariousTaskBits[N_TASKS] = {0}; uint8_t TaskDeviceDataFeed[N_TASKS] = {0}; // When set to 0, only read local connected sensorsfeeds uint32_t TaskDeviceTimer[N_TASKS] = {0}; - boolean TaskDeviceEnabled[N_TASKS] = {0}; - boolean ControllerEnabled[CONTROLLER_MAX] = {0}; - boolean NotificationEnabled[NOTIFICATION_MAX] = {0}; + #if FEATURE_TASKDEVICE_BITFIELDS_6 +union { + boolean TaskDeviceBitfield_6_internal[N_TASKS]{}; + struct { + uint8_t TaskDeviceEnabled : 1; // Bit 0 used + uint8_t unusedU6_01 : 1; // Bit 1 + uint8_t unusedU6_02 : 1; // Bit 2 + uint8_t unusedU6_03 : 1; // Bit 3 + uint8_t unusedU6_04 : 1; // Bit 4 + uint8_t unusedU6_05 : 1; // Bit 5 + uint8_t unusedU6_06 : 1; // Bit 6 + uint8_t unusedU6_07 : 1; // Bit 7 + } TaskDeviceBitfield_6[N_TASKS]; + }; + #else // if FEATURE_TASKDEVICE_BITFIELDS_6 + boolean _TaskDeviceEnabled[N_TASKS] = {0}; + #endif // if FEATURE_TASKDEVICE_BITFIELDS_6 + #if FEATURE_CONTROLLER_BITFIELDS_1 + union { + boolean ControllerBitfield_1_internal[CONTROLLER_MAX]{}; + struct { + uint8_t ControllerEnabled : 1; // Bit 0 used + uint8_t unusedC1_01 : 1; // Bit 1 + uint8_t unusedC1_02 : 1; // Bit 2 + uint8_t unusedC1_03 : 1; // Bit 3 + uint8_t unusedC1_04 : 1; // Bit 4 + uint8_t unusedC1_05 : 1; // Bit 5 + uint8_t unusedC1_06 : 1; // Bit 6 + uint8_t unusedC1_07 : 1; // Bit 7 + } ControllerBitfield_1[CONTROLLER_MAX]; + }; + #else // if FEATURE_CONTROLLER_BITFIELDS_1 + boolean _ControllerEnabled[CONTROLLER_MAX] = {0}; + #endif // if FEATURE_CONTROLLER_BITFIELDS_1 + #if FEATURE_NOTIFICATION_BITFIELDS_1 + union { + boolean NotificationBitfield_1_internal[NOTIFICATION_MAX]{}; + struct { + uint8_t NotificationEnabled : 1; // Bit 0 used + uint8_t unusedN1_01 : 1; // Bit 1 + uint8_t unusedN1_02 : 1; // Bit 2 + uint8_t unusedN1_03 : 1; // Bit 3 + uint8_t unusedN1_04 : 1; // Bit 4 + uint8_t unusedN1_05 : 1; // Bit 5 + uint8_t unusedN1_06 : 1; // Bit 6 + uint8_t unusedN1_07 : 1; // Bit 7 + } NotificationBitfield_1[NOTIFICATION_MAX]; + }; + #else // if FEATURE_NOTIFICATION_BITFIELDS_1 + boolean _NotificationEnabled[NOTIFICATION_MAX] = {0}; + #endif // if FEATURE_NOTIFICATION_BITFIELDS_1 uint32_t TaskDeviceID[CONTROLLER_MAX][N_TASKS]{}; // IDX number (mainly used by Domoticz) boolean TaskDeviceSendData[CONTROLLER_MAX][N_TASKS]{}; - boolean Pin_status_led_Inversed = false; - boolean deepSleepOnFail = false; - boolean UseValueLogger = false; - boolean ArduinoOTAEnable = false; + union { + struct { + uint32_t Pin_status_led_Inversed : 1; // Bit 0 used + uint32_t unusedU2_01 : 1; // Bit 1 + uint32_t unusedU2_02 : 1; // Bit 2 + uint32_t unusedU2_03 : 1; // Bit 3 + uint32_t unusedU2_04 : 1; // Bit 4 + uint32_t unusedU2_05 : 1; // Bit 5 + uint32_t unusedU2_06 : 1; // Bit 6 + uint32_t unusedU2_07 : 1; // Bit 7 + uint32_t deepSleepOnFail : 1; // Bit 8 used + uint32_t unusedU2_09 : 1; // Bit 9 + uint32_t unusedU2_10 : 1; // Bit 10 + uint32_t unusedU2_11 : 1; // Bit 11 + uint32_t unusedU2_12 : 1; // Bit 12 + uint32_t unusedU2_13 : 1; // Bit 13 + uint32_t unusedU2_14 : 1; // Bit 14 + uint32_t unusedU2_15 : 1; // Bit 15 + uint32_t UseValueLogger : 1; // Bit 16 used + uint32_t unusedU2_17 : 1; // Bit 17 + uint32_t unusedU2_18 : 1; // Bit 18 + uint32_t unusedU2_19 : 1; // Bit 19 + uint32_t unusedU2_20 : 1; // Bit 20 + uint32_t unusedU2_21 : 1; // Bit 21 + uint32_t unusedU2_22 : 1; // Bit 22 + uint32_t unusedU2_23 : 1; // Bit 23 + uint32_t ArduinoOTAEnable : 1; // Bit 24 used + uint32_t unusedU2_25 : 1; // Bit 25 + uint32_t unusedU2_26 : 1; // Bit 26 + uint32_t unusedU2_27 : 1; // Bit 27 + uint32_t unusedU2_28 : 1; // Bit 28 + uint32_t unusedU2_29 : 1; // Bit 29 + uint32_t unusedU2_30 : 1; // Bit 30 + uint32_t unusedU2_31 : 1; // Bit 31 + }; + uint32_t _unnamedUnion2{}; + }; uint16_t DST_Start = 0; uint16_t DST_End = 0; boolean UseRTOSMultitasking = false; diff --git a/src/src/DataStructs_templ/SettingsStruct.cpp b/src/src/DataStructs_templ/SettingsStruct.cpp index c389576415..6d13340e2d 100644 --- a/src/src/DataStructs_templ/SettingsStruct.cpp +++ b/src/src/DataStructs_templ/SettingsStruct.cpp @@ -651,7 +651,7 @@ template void SettingsStruct_tmpl::clearNotifications() { for (uint8_t i = 0; i < NOTIFICATION_MAX; ++i) { Notification[i] = 0u;// .setInvalid(); - NotificationEnabled[i] = false; + NotificationEnabled(i, false); } } @@ -659,7 +659,7 @@ template void SettingsStruct_tmpl::clearControllers() { for (controllerIndex_t i = 0; i < CONTROLLER_MAX; ++i) { Protocol[i] = 0; - ControllerEnabled[i] = false; + ControllerEnabled(i, false); } } @@ -791,17 +791,17 @@ void SettingsStruct_tmpl::clearTask(taskIndex_t task) { TaskDeviceSendData[i][task] = false; } TaskDeviceNumber[task] = 0u; //.setInvalid(); - OLD_TaskDeviceID[task] = 0u; // UNUSED: this can be removed + // OLD_TaskDeviceID[task] = 0u; // UNUSED: this must be removed TaskDevicePin1[task] = -1; TaskDevicePin2[task] = -1; TaskDevicePin3[task] = -1; TaskDevicePort[task] = 0u; - TaskDevicePin1PullUp[task] = false; + TaskDevicePin1PullUp(task, false); for (uint8_t cv = 0; cv < PLUGIN_CONFIGVAR_MAX; ++cv) { TaskDevicePluginConfig[task][cv] = 0; } - TaskDevicePin1Inversed[task] = false; + TaskDevicePin1Inversed(task, false); for (uint8_t cv = 0; cv < PLUGIN_CONFIGFLOATVAR_MAX; ++cv) { TaskDevicePluginConfigFloat[task][cv] = 0.0f; @@ -815,7 +815,7 @@ void SettingsStruct_tmpl::clearTask(taskIndex_t task) { TaskDeviceDataFeed[task] = 0u; TaskDeviceTimer[task] = 0u; // TaskDeviceEnabled[task].value = 0u; // Should also clear any temporary flags. - TaskDeviceEnabled[task] = false; + TaskDeviceEnabled(task, false); I2C_Multiplexer_Channel[task] = -1; } diff --git a/src/src/ESPEasyCore/Controller.cpp b/src/src/ESPEasyCore/Controller.cpp index 5e07aeab5a..1711a460ac 100644 --- a/src/src/ESPEasyCore/Controller.cpp +++ b/src/src/ESPEasyCore/Controller.cpp @@ -65,7 +65,7 @@ void sendData(struct EventStruct *event, bool sendEvents) for (controllerIndex_t x = 0; x < CONTROLLER_MAX; x++) { - if (Settings.ControllerEnabled[x] && + if (Settings.ControllerEnabled(x) && Settings.TaskDeviceSendData[x][event->TaskIndex] && Settings.Protocol[x]) { @@ -147,7 +147,7 @@ void incoming_mqtt_callback(char *c_topic, uint8_t *b_payload, unsigned int leng // Here we loop over all tasks and call each 037 plugin with function PLUGIN_MQTT_IMPORT for (taskIndex_t taskIndex = 0; taskIndex < TASKS_MAX; taskIndex++) { - if (Settings.TaskDeviceEnabled[taskIndex] && (Settings.getPluginID_for_task(taskIndex) == PLUGIN_ID_MQTT_IMPORT)) + if (Settings.TaskDeviceEnabled(taskIndex) && (Settings.getPluginID_for_task(taskIndex) == PLUGIN_ID_MQTT_IMPORT)) { Scheduler.schedule_mqtt_plugin_import_event_timer( DeviceIndex, taskIndex, PLUGIN_MQTT_IMPORT, @@ -1053,7 +1053,7 @@ controllerIndex_t firstEnabledMQTT_ControllerIndex() { protocolIndex_t ProtocolIndex = getProtocolIndex_from_ControllerIndex(i); if (validProtocolIndex(ProtocolIndex)) { - if (getProtocolStruct(ProtocolIndex).usesMQTT && Settings.ControllerEnabled[i]) { + if (getProtocolStruct(ProtocolIndex).usesMQTT && Settings.ControllerEnabled(i)) { return i; } } @@ -1280,7 +1280,7 @@ void SensorSendTask(struct EventStruct *event, unsigned long timestampUnixTime, checkRAM(F("SensorSendTask")); #endif // ifndef BUILD_NO_RAM_TRACKER - if (Settings.TaskDeviceEnabled[event->TaskIndex]) + if (Settings.TaskDeviceEnabled(event->TaskIndex)) { START_TIMER; const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(event->TaskIndex); diff --git a/src/src/Globals/CPlugins.cpp b/src/src/Globals/CPlugins.cpp index a9888a82cd..88044fcfc4 100644 --- a/src/src/Globals/CPlugins.cpp +++ b/src/src/Globals/CPlugins.cpp @@ -70,7 +70,7 @@ bool CPluginCall(CPlugin::Function Function, struct EventStruct *event, String& for (controllerIndex_t x = 0; x < CONTROLLER_MAX; x++) { const bool checkedEnabled = - Settings.ControllerEnabled[x] || + Settings.ControllerEnabled(x) || Function == CPlugin::Function::CPLUGIN_EXIT; if ((Settings.Protocol[x] != 0) && checkedEnabled) { @@ -102,7 +102,7 @@ bool CPluginCall(CPlugin::Function Function, struct EventStruct *event, String& case CPlugin::Function::CPLUGIN_PROTOCOL_RECV: case CPlugin::Function::CPLUGIN_TASK_CHANGE_NOTIFICATION: if (!validControllerIndex(event->ControllerIndex) - || !Settings.ControllerEnabled[event->ControllerIndex]) + || !Settings.ControllerEnabled(event->ControllerIndex)) { return false; } @@ -154,7 +154,7 @@ bool CPluginCall(CPlugin::Function Function, struct EventStruct *event, String& case CPlugin::Function::CPLUGIN_ACKNOWLEDGE: // calls to send acknowledge back to controller for (controllerIndex_t x = 0; x < CONTROLLER_MAX; x++) { - if (Settings.ControllerEnabled[x] && supportedCPluginID(Settings.Protocol[x])) { + if (Settings.ControllerEnabled(x) && supportedCPluginID(Settings.Protocol[x])) { do_CPluginCall( getProtocolIndex_from_ControllerIndex(x), Function, @@ -174,7 +174,7 @@ bool CPluginCall(CPlugin::Function Function, struct EventStruct *event, String& // Check if there is any controller enabled. bool anyControllerEnabled() { for (controllerIndex_t x = 0; x < CONTROLLER_MAX; x++) { - if (Settings.ControllerEnabled[x] && supportedCPluginID(Settings.Protocol[x])) { + if (Settings.ControllerEnabled(x) && supportedCPluginID(Settings.Protocol[x])) { return true; } } @@ -185,7 +185,7 @@ bool anyControllerEnabled() { controllerIndex_t findFirstEnabledControllerWithId(cpluginID_t cpluginid) { if (supportedCPluginID(cpluginid)) { for (controllerIndex_t i = 0; i < CONTROLLER_MAX; i++) { - if ((Settings.Protocol[i] == cpluginid) && Settings.ControllerEnabled[i]) { + if ((Settings.Protocol[i] == cpluginid) && Settings.ControllerEnabled(i)) { return i; } } diff --git a/src/src/Globals/Plugins.cpp b/src/src/Globals/Plugins.cpp index dc6e7e542d..b1fa4c1c1e 100644 --- a/src/src/Globals/Plugins.cpp +++ b/src/src/Globals/Plugins.cpp @@ -337,7 +337,7 @@ bool PluginCallForTask(taskIndex_t taskIndex, uint8_t Function, EventStruct *Tem #endif // ifdef USE_SECOND_HEAP bool retval = false; - const bool considerTaskEnabled = Settings.TaskDeviceEnabled[taskIndex]; + const bool considerTaskEnabled = Settings.TaskDeviceEnabled(taskIndex); // || (Settings.TaskDeviceEnabled[taskIndex].enabled && Function == PLUGIN_INIT); @@ -594,7 +594,7 @@ bool PluginCall(uint8_t Function, struct EventStruct *event, String& str) // []. prefix const pluginID_t pluginID = Settings.getPluginID_for_task(thisTask); - if (Settings.TaskDeviceEnabled[thisTask] // and internally needs to know wether it was called with the taskname prefixed + if (Settings.TaskDeviceEnabled(thisTask) // and internally needs to know wether it was called with the taskname prefixed && validPluginID_fullcheck(pluginID) && (Settings.TaskDeviceDataFeed[thisTask] == 0)) { const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(thisTask); @@ -673,7 +673,7 @@ bool PluginCall(uint8_t Function, struct EventStruct *event, String& str) { for (taskIndex_t taskIndex = 0; taskIndex < TASKS_MAX; taskIndex++) { - if (Settings.TaskDeviceEnabled[taskIndex]) { + if (Settings.TaskDeviceEnabled(taskIndex)) { if (PluginCallForTask(taskIndex, Function, &TempEvent, str)) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("PluginCallUDP"), taskIndex); @@ -719,8 +719,8 @@ bool PluginCall(uint8_t Function, struct EventStruct *event, String& str) // What interval? (see: PR #4793) // Settings.TaskDeviceEnabled[taskIndex].setRetryInit(); // Scheduler.setPluginTaskTimer(10000, taskIndex, PLUGIN_INIT); - Settings.TaskDeviceEnabled[taskIndex] = false; - result = false; + Settings.TaskDeviceEnabled(taskIndex, false); + result = false; } #ifndef BUILD_NO_DEBUG @@ -746,7 +746,7 @@ bool PluginCall(uint8_t Function, struct EventStruct *event, String& str) while (log.length() < 67) { log += ' '; } - log += Settings.TaskDeviceEnabled[taskIndex] ? F("[ena]") : F("[dis]"); + log += Settings.TaskDeviceEnabled(taskIndex) ? F("[ena]") : F("[dis]"); while (log.length() < 73) { log += ' '; } log += getPluginNameFromDeviceIndex(getDeviceIndex_from_TaskIndex(taskIndex)); @@ -808,7 +808,7 @@ bool PluginCall(uint8_t Function, struct EventStruct *event, String& str) } if ((Function == PLUGIN_READ) || (Function == PLUGIN_INIT) || (Function == PLUGIN_PROCESS_CONTROLLER_DATA)) { - if (!Settings.TaskDeviceEnabled[event->TaskIndex]) { + if (!Settings.TaskDeviceEnabled(event->TaskIndex)) { return false; } @@ -942,7 +942,7 @@ bool PluginCall(uint8_t Function, struct EventStruct *event, String& str) if (!retval && (Settings.TaskDeviceDataFeed[event->TaskIndex] == 0)) { // Disable temporarily as PLUGIN_INIT failed // FIXME TD-er: Should reschedule call to PLUGIN_INIT???? - Settings.TaskDeviceEnabled[event->TaskIndex] = false; + Settings.TaskDeviceEnabled(event->TaskIndex, false); } else { #if FEATURE_PLUGIN_STATS diff --git a/src/src/Helpers/ESPEasy_FactoryDefault.cpp b/src/src/Helpers/ESPEasy_FactoryDefault.cpp index aac872006c..37ceb7cbdb 100644 --- a/src/src/Helpers/ESPEasy_FactoryDefault.cpp +++ b/src/src/Helpers/ESPEasy_FactoryDefault.cpp @@ -294,7 +294,7 @@ void ResetFactory(bool formatFS) // advanced Settings // Settings.UseRules = DEFAULT_USE_RULES; - Settings.ControllerEnabled[0] = DEFAULT_CONTROLLER_ENABLED; + Settings.ControllerEnabled(0, DEFAULT_CONTROLLER_ENABLED); Settings.MQTTRetainFlag_unused = DEFAULT_MQTT_RETAIN; Settings.MessageDelay_unused = DEFAULT_MQTT_DELAY; Settings.MQTTUseUnitNameAsClientId_unused = DEFAULT_MQTT_USE_UNITNAME_AS_CLIENTID; diff --git a/src/src/Helpers/ESPEasy_Storage.cpp b/src/src/Helpers/ESPEasy_Storage.cpp index 609474adc7..ab3d16ee45 100644 --- a/src/src/Helpers/ESPEasy_Storage.cpp +++ b/src/src/Helpers/ESPEasy_Storage.cpp @@ -459,7 +459,7 @@ bool BuildFixes() for (taskIndex_t taskIndex = 0; taskIndex < TASKS_MAX; ++taskIndex) { if (Settings.getPluginID_for_task(taskIndex) == PLUGIN_ID_P003_PULSE) { - Settings.TaskDevicePin1PullUp[taskIndex] = true; + Settings.TaskDevicePin1PullUp(taskIndex, true); } } #endif // ifdef USES_P003 @@ -1071,13 +1071,13 @@ String LoadSettings() \*********************************************************************************************/ uint8_t disablePlugin(uint8_t bootFailedCount) { for (taskIndex_t i = 0; i < TASKS_MAX && bootFailedCount > 0; ++i) { - if (Settings.TaskDeviceEnabled[i]) { + if (Settings.TaskDeviceEnabled(i)) { --bootFailedCount; if (bootFailedCount == 0) { // Disable temporarily as unit crashed // FIXME TD-er: Should this be stored? - Settings.TaskDeviceEnabled[i] = false; + Settings.TaskDeviceEnabled(i, false); } } } @@ -1091,7 +1091,7 @@ uint8_t disableAllPlugins(uint8_t bootFailedCount) { for (taskIndex_t i = 0; i < TASKS_MAX; ++i) { // Disable temporarily as unit crashed // FIXME TD-er: Should this be stored? - Settings.TaskDeviceEnabled[i] = false; + Settings.TaskDeviceEnabled(i, false); } } return bootFailedCount; @@ -1102,11 +1102,11 @@ uint8_t disableAllPlugins(uint8_t bootFailedCount) { \*********************************************************************************************/ uint8_t disableController(uint8_t bootFailedCount) { for (controllerIndex_t i = 0; i < CONTROLLER_MAX && bootFailedCount > 0; ++i) { - if (Settings.ControllerEnabled[i]) { + if (Settings.ControllerEnabled(i)) { --bootFailedCount; if (bootFailedCount == 0) { - Settings.ControllerEnabled[i] = false; + Settings.ControllerEnabled(i, false); } } } @@ -1118,7 +1118,7 @@ uint8_t disableAllControllers(uint8_t bootFailedCount) { --bootFailedCount; for (controllerIndex_t i = 0; i < CONTROLLER_MAX; ++i) { - Settings.ControllerEnabled[i] = false; + Settings.ControllerEnabled(i, false); } } return bootFailedCount; @@ -1130,11 +1130,11 @@ uint8_t disableAllControllers(uint8_t bootFailedCount) { #if FEATURE_NOTIFIER uint8_t disableNotification(uint8_t bootFailedCount) { for (uint8_t i = 0; i < NOTIFICATION_MAX && bootFailedCount > 0; ++i) { - if (Settings.NotificationEnabled[i]) { + if (Settings.NotificationEnabled(i)) { --bootFailedCount; if (bootFailedCount == 0) { - Settings.NotificationEnabled[i] = false; + Settings.NotificationEnabled(i, false); } } } @@ -1146,7 +1146,7 @@ uint8_t disableAllNotifications(uint8_t bootFailedCount) { --bootFailedCount; for (uint8_t i = 0; i < NOTIFICATION_MAX; ++i) { - Settings.NotificationEnabled[i] = false; + Settings.NotificationEnabled(i, false); } } return bootFailedCount; diff --git a/src/src/Helpers/ESPEasy_checks.cpp b/src/src/Helpers/ESPEasy_checks.cpp index 07a7e6fe5d..6d4b4cb9f0 100644 --- a/src/src/Helpers/ESPEasy_checks.cpp +++ b/src/src/Helpers/ESPEasy_checks.cpp @@ -179,7 +179,11 @@ void run_compiletime_checks() { // All settings related to N_TASKS static_assert((232 + TASKS_MAX) == offsetof(SettingsStruct, OLD_TaskDeviceID), ""); // 32-bit alignment, so offset of 2 bytes. - static_assert((200 + (67 * TASKS_MAX)) == offsetof(SettingsStruct, ControllerEnabled), ""); + #if FEATURE_CONTROLLER_BITFIELDS_1 + static_assert((200 + (67 * TASKS_MAX)) == offsetof(SettingsStruct, ControllerBitfield_1), ""); + #else // if FEATURE_CONTROLLER_BITFIELDS_1 + static_assert((200 + (67 * TASKS_MAX)) == offsetof(SettingsStruct, _ControllerEnabled), ""); + #endif // if FEATURE_CONTROLLER_BITFIELDS_1 // Used to compute true offset. //const size_t offset = offsetof(SettingsStruct, ControllerEnabled); @@ -245,14 +249,14 @@ String checkTaskSettings(taskIndex_t taskIndex) { return F("Invalid name. Should not be numeric."); } if (deviceName.isEmpty()) { - if (Settings.TaskDeviceEnabled[taskIndex]) { + if (Settings.TaskDeviceEnabled(taskIndex)) { // Decide what to do here, for now give a warning when task is enabled. return F("Warning: Task Device Name is empty. It is adviced to give tasks an unique name"); } } // Do not use the cached function findTaskIndexByName since that one does rely on the fact names should be unique. for (taskIndex_t i = 0; i < TASKS_MAX; ++i) { - if (i != taskIndex && Settings.TaskDeviceEnabled[i]) { + if (i != taskIndex && Settings.TaskDeviceEnabled(i)) { LoadTaskSettings(i); if (ExtraTaskSettings.TaskDeviceName[0] != 0) { if (strcasecmp(ExtraTaskSettings.TaskDeviceName, deviceName.c_str()) == 0) { diff --git a/src/src/Helpers/Hardware.cpp b/src/src/Helpers/Hardware.cpp index cf409cbf62..ba9491e984 100644 --- a/src/src/Helpers/Hardware.cpp +++ b/src/src/Helpers/Hardware.cpp @@ -874,7 +874,7 @@ void addSwitchPlugin(taskIndex_t taskIndex, int gpio, const String& name, bool a true, // enabled name, // name pins); - Settings.TaskDevicePin1PullUp[taskIndex] = true; + Settings.TaskDevicePin1PullUp(taskIndex, true); if (activeLow) { Settings.TaskDevicePluginConfig[taskIndex][2] = 1; // SWITCH_TYPE_PUSH_ACTIVE_LOW; @@ -1012,7 +1012,7 @@ void setBasicTaskValues(taskIndex_t taskIndex, unsigned long taskdevicetimer, Settings.TaskDeviceTimer[taskIndex] = 0; } } - Settings.TaskDeviceEnabled[taskIndex] = enabled; + Settings.TaskDeviceEnabled(taskIndex, enabled); //Settings.TaskDeviceEnabled[taskIndex].enabled = enabled; safe_strncpy(ExtraTaskSettings.TaskDeviceName, name.c_str(), sizeof(ExtraTaskSettings.TaskDeviceName)); diff --git a/src/src/Helpers/I2C_access.cpp b/src/src/Helpers/I2C_access.cpp index bd12c53b55..3bb81b1195 100644 --- a/src/src/Helpers/I2C_access.cpp +++ b/src/src/Helpers/I2C_access.cpp @@ -487,7 +487,7 @@ bool I2C_deviceCheck(uint8_t i2caddr, if (deviceCheckI2C[taskIndex] >= maxRetries) { // Disable temporarily as device check failed // FIXME TD-er: Should reschedule call to PLUGIN_INIT???? - Settings.TaskDeviceEnabled[taskIndex] = false; // If the number of retries is reached, disable the device + Settings.TaskDeviceEnabled(taskIndex, false); // If the number of retries is reached, disable the device # ifndef BUILD_NO_DEBUG addLog(LOG_LEVEL_ERROR, concat(F("I2C : Device doesn't respond for task: "), static_cast(taskIndex + 1))); # endif // ifndef BUILD_NO_DEBUG diff --git a/src/src/Helpers/Misc.cpp b/src/src/Helpers/Misc.cpp index 1d081705f4..e67ba82838 100644 --- a/src/src/Helpers/Misc.cpp +++ b/src/src/Helpers/Misc.cpp @@ -127,7 +127,7 @@ bool setControllerEnableStatus(controllerIndex_t controllerIndex, bool enabled) CPluginCall(CPlugin::Function::CPLUGIN_EXIT, &TempEvent, dummy); } - Settings.ControllerEnabled[controllerIndex] = enabled; + Settings.ControllerEnabled(controllerIndex, enabled); const protocolIndex_t ProtocolIndex = getProtocolIndex_from_ControllerIndex(controllerIndex); if (validProtocolIndex(ProtocolIndex)) { @@ -154,7 +154,7 @@ bool setTaskEnableStatus(struct EventStruct *event, bool enabled) // Only enable task if it has a Plugin configured if (validPluginID(Settings.getPluginID_for_task(event->TaskIndex)) || !enabled) { - if (enabled != Settings.TaskDeviceEnabled[event->TaskIndex]) + if (enabled != Settings.TaskDeviceEnabled(event->TaskIndex)) { String dummy; @@ -165,7 +165,7 @@ bool setTaskEnableStatus(struct EventStruct *event, bool enabled) // Toggle enable/disable state via command // FIXME TD-er: Should this be a 'runtime' change, or actually change the intended state? // Settings.TaskDeviceEnabled[event->TaskIndex].enabled = enabled; - Settings.TaskDeviceEnabled[event->TaskIndex] = enabled; + Settings.TaskDeviceEnabled(event->TaskIndex, enabled); if (enabled) { // Schedule the plugin to be read. @@ -192,7 +192,7 @@ void taskClear(taskIndex_t taskIndex, bool save) checkRAM(F("taskClear")); #endif // ifndef BUILD_NO_RAM_TRACKER - if (Settings.TaskDeviceEnabled[taskIndex]) { + if (Settings.TaskDeviceEnabled(taskIndex)) { struct EventStruct TempEvent(taskIndex); String dummy; PluginCall(PLUGIN_EXIT, &TempEvent, dummy); diff --git a/src/src/Helpers/PeriodicalActions.cpp b/src/src/Helpers/PeriodicalActions.cpp index 66e9c3a61a..12acc679f2 100644 --- a/src/src/Helpers/PeriodicalActions.cpp +++ b/src/src/Helpers/PeriodicalActions.cpp @@ -335,7 +335,7 @@ void schedule_all_MQTTimport_tasks() { if (validDeviceIndex(DeviceIndex)) { for (taskIndex_t task = 0; task < TASKS_MAX; task++) { if ((Settings.getPluginID_for_task(task) == PLUGIN_MQTT_IMPORT) && - (Settings.TaskDeviceEnabled[task])) { + (Settings.TaskDeviceEnabled(task))) { // Schedule a call to each enabled MQTT import plugin to notify the broker connection state EventStruct event(task); event.Par1 = MQTTclient_connected ? 1 : 0; diff --git a/src/src/Helpers/Scheduler_PluginTaskTimer.cpp b/src/src/Helpers/Scheduler_PluginTaskTimer.cpp index accb4127e9..da9e61b1b1 100644 --- a/src/src/Helpers/Scheduler_PluginTaskTimer.cpp +++ b/src/src/Helpers/Scheduler_PluginTaskTimer.cpp @@ -27,7 +27,7 @@ void ESPEasy_Scheduler::setPluginTaskTimer( // taskIndex and par1 form a unique key that can be used to restart a timer if (!validTaskIndex(taskIndex)) { return; } - if (!Settings.TaskDeviceEnabled[taskIndex]) { return; } + if (!Settings.TaskDeviceEnabled(taskIndex)) { return; } const PluginTaskTimerID timerID(taskIndex, Par1, function); diff --git a/src/src/Helpers/Scheduler_TaskDeviceTimer.cpp b/src/src/Helpers/Scheduler_TaskDeviceTimer.cpp index 6f1aa98645..01025c9a81 100644 --- a/src/src/Helpers/Scheduler_TaskDeviceTimer.cpp +++ b/src/src/Helpers/Scheduler_TaskDeviceTimer.cpp @@ -41,7 +41,7 @@ void ESPEasy_Scheduler::schedule_task_device_timer(unsigned long task_index, uns log += task_index; log += F(" @ "); log += runAt; - if (Settings.TaskDeviceEnabled[task_index]) { + if (Settings.TaskDeviceEnabled(task_index)) { log += F(" (enabled)"); } addLog(LOG_LEVEL_INFO, log); @@ -64,7 +64,7 @@ void ESPEasy_Scheduler::schedule_task_device_timer(unsigned long task_index, uns } */ - if (Settings.TaskDeviceEnabled[task_index]) { + if (Settings.TaskDeviceEnabled(task_index)) { const TaskDeviceTimerID timerID(task_index); setNewTimerAt(timerID, runAt); } diff --git a/src/src/Helpers/StringParser.cpp b/src/src/Helpers/StringParser.cpp index 515d1f23dc..1aabe16f65 100644 --- a/src/src/Helpers/StringParser.cpp +++ b/src/src/Helpers/StringParser.cpp @@ -252,7 +252,7 @@ String parseTemplate_padded(String& tmpString, uint8_t minimal_lineSize, bool us if (validTaskIndex(taskIndex)) { bool isHandled = false; - if (Settings.TaskDeviceEnabled[taskIndex]) { + if (Settings.TaskDeviceEnabled(taskIndex)) { uint8_t valueNr = findDeviceValueIndexByName(valueName, taskIndex); if (valueNr != VARS_PER_TASK) { @@ -288,7 +288,7 @@ String parseTemplate_padded(String& tmpString, uint8_t minimal_lineSize, bool us if (!isHandled && valueName.startsWith(F("settings."))) { // Task settings values String value; if (valueName.endsWith(F(".enabled"))) { // Task state - value = Settings.TaskDeviceEnabled[taskIndex] ? '1' : '0'; + value = Settings.TaskDeviceEnabled(taskIndex) ? '1' : '0'; } else if (valueName.endsWith(F(".interval"))) { // Task interval value = Settings.TaskDeviceTimer[taskIndex]; } else if (valueName.endsWith(F(".valuecount"))) { // Task value count @@ -297,7 +297,7 @@ String parseTemplate_padded(String& tmpString, uint8_t minimal_lineSize, bool us String ctrl = valueName.substring(19, 20); int32_t ctrlNr = 0; if (validIntFromString(ctrl, ctrlNr) && (ctrlNr >= 1) && (ctrlNr <= CONTROLLER_MAX) && - Settings.ControllerEnabled[ctrlNr - 1]) { // Controller nr. valid and enabled + Settings.ControllerEnabled(ctrlNr - 1)) { // Controller nr. valid and enabled if (valueName.endsWith(F(".enabled"))) { // Task-controller enabled value = Settings.TaskDeviceSendData[ctrlNr - 1][taskIndex]; } else if (valueName.endsWith(F(".idx"))) { // Task-controller idx value @@ -320,7 +320,7 @@ String parseTemplate_padded(String& tmpString, uint8_t minimal_lineSize, bool us } } #if FEATURE_STRING_VARIABLES - if (!isHandled && Settings.TaskDeviceEnabled[taskIndex]) { + if (!isHandled && Settings.TaskDeviceEnabled(taskIndex)) { String value; const String valName = parseString(valueName, 1); String derived = getCustomStringVar(strformat(F(TASK_VALUE_DERIVED_PREFIX_TEMPLATE), deviceName.c_str(), valName.c_str())); @@ -856,7 +856,7 @@ taskIndex_t findTaskIndexByName(String deviceName, bool allowDisabled) for (taskIndex_t taskIndex = 0; taskIndex < TASKS_MAX; taskIndex++) { - if (Settings.TaskDeviceEnabled[taskIndex] || allowDisabled) { + if (Settings.TaskDeviceEnabled(taskIndex) || allowDisabled) { String taskDeviceName = getTaskDeviceName(taskIndex); if (!taskDeviceName.isEmpty()) diff --git a/src/src/Helpers/_CPlugin_Helper_mqtt.cpp b/src/src/Helpers/_CPlugin_Helper_mqtt.cpp index e1819eb409..428edb1742 100644 --- a/src/src/Helpers/_CPlugin_Helper_mqtt.cpp +++ b/src/src/Helpers/_CPlugin_Helper_mqtt.cpp @@ -64,16 +64,18 @@ bool MQTT_handle_topic_commands(struct EventStruct *event, uint8_t valueNr = findDeviceValueIndexByName(valueName, taskIndex); const taskVarIndex_t taskVarIndex = static_cast(valueNr); - if (validDeviceIndex(deviceIndex) && validTaskVarIndex(taskVarIndex) && Settings.TaskDeviceEnabled[taskIndex]) { + if (validDeviceIndex(deviceIndex) && validTaskVarIndex(taskVarIndex) && Settings.TaskDeviceEnabled(taskIndex)) { # if defined(USES_P001) || defined(USES_P009) || defined(USES_P019) || defined(USES_P033) || defined(USES_P086) const int pluginID = Device[deviceIndex].Number; # endif // if defined(USES_P001) || defined(USES_P009) || defined(USES_P010) || defined(USES_P033) || defined(USES_P086) + # if defined(USES_P001) || defined(USES_P009) || defined(USES_P019) + const bool inverted = Settings.TaskDevicePin1Inversed(taskIndex); + # endif // if defined(USES_P001) || defined(USES_P009) || defined(USES_P019) # ifdef USES_P001 if (!handled && (pluginID == 1) && validGpio(Settings.TaskDevicePin[0][taskIndex])) { // Plugin 1 Switch, uses 1st GPIO only EventStruct TempEvent(taskIndex); const uint8_t switchtype = P001_data_struct::P001_getSwitchType(&TempEvent); // 0 = Switch - const bool inverted = Settings.TaskDevicePin1Inversed[taskIndex]; uint32_t value{}; validUIntFromString(event->String2, value); @@ -89,7 +91,6 @@ bool MQTT_handle_topic_commands(struct EventStruct *event, if (!handled && ((pluginID == 9) || (pluginID == 19))) { // Plugin 9 MCP23017, Plugin 19 PCF8574 EventStruct TempEvent(taskIndex); - const bool inverted = Settings.TaskDevicePin1Inversed[taskIndex]; uint32_t value{}; validUIntFromString(event->String2, value); @@ -370,45 +371,27 @@ bool getDiscoveryVType(struct EventStruct *event, QueryVType_ptr func_ptr, uint8 } // helper functions to supply a single value VType to be used by getDiscoveryVType -int Plugin_QueryVType_BinarySensor(uint8_t value_nr) { - return static_cast(Sensor_VType::SENSOR_TYPE_SWITCH) | Sensor_VType_CAN_SET; -} +int Plugin_QueryVType_BinarySensor(uint8_t value_nr) { return static_cast(Sensor_VType::SENSOR_TYPE_SWITCH) | Sensor_VType_CAN_SET; } int Plugin_QueryVType_BinarySensorInv(uint8_t value_nr) { return static_cast(Sensor_VType::SENSOR_TYPE_SWITCH_INVERTED) | Sensor_VType_CAN_SET; } -int Plugin_QueryVType_Analog(uint8_t value_nr) { - return static_cast(Sensor_VType::SENSOR_TYPE_ANALOG_ONLY); -} +int Plugin_QueryVType_Analog(uint8_t value_nr) { return static_cast(Sensor_VType::SENSOR_TYPE_ANALOG_ONLY); } -int Plugin_QueryVType_CO2(uint8_t value_nr) { - return static_cast(Sensor_VType::SENSOR_TYPE_CO2_ONLY); -} +int Plugin_QueryVType_CO2(uint8_t value_nr) { return static_cast(Sensor_VType::SENSOR_TYPE_CO2_ONLY); } -int Plugin_QueryVType_Distance(uint8_t value_nr) { - return static_cast(Sensor_VType::SENSOR_TYPE_DISTANCE_ONLY); -} +int Plugin_QueryVType_Distance(uint8_t value_nr) { return static_cast(Sensor_VType::SENSOR_TYPE_DISTANCE_ONLY); } -int Plugin_QueryVType_DustPM2_5(uint8_t value_nr) { - return static_cast(Sensor_VType::SENSOR_TYPE_DUSTPM2_5_ONLY); -} +int Plugin_QueryVType_DustPM2_5(uint8_t value_nr) { return static_cast(Sensor_VType::SENSOR_TYPE_DUSTPM2_5_ONLY); } -int Plugin_QueryVType_Lux(uint8_t value_nr) { - return static_cast(Sensor_VType::SENSOR_TYPE_LUX_ONLY); -} +int Plugin_QueryVType_Lux(uint8_t value_nr) { return static_cast(Sensor_VType::SENSOR_TYPE_LUX_ONLY); } -int Plugin_QueryVType_Temperature(uint8_t value_nr) { - return static_cast(Sensor_VType::SENSOR_TYPE_TEMP_ONLY); -} +int Plugin_QueryVType_Temperature(uint8_t value_nr) { return static_cast(Sensor_VType::SENSOR_TYPE_TEMP_ONLY); } -int Plugin_QueryVType_Weight(uint8_t value_nr) { - return static_cast(Sensor_VType::SENSOR_TYPE_WEIGHT_ONLY); -} +int Plugin_QueryVType_Weight(uint8_t value_nr) { return static_cast(Sensor_VType::SENSOR_TYPE_WEIGHT_ONLY); } -String makeHomeAssistantCompliantName(const String& name) { - return ESPEasy::net::makeRFCCompliantName(name, '_', '_', 0); -} +String makeHomeAssistantCompliantName(const String& name) { return ESPEasy::net::makeRFCCompliantName(name, '_', '_', 0); } # if FEATURE_MQTT_DEVICECLASS const char mqtt_binary_deviceclass_names[] PROGMEM = @@ -434,16 +417,17 @@ int MQTT_binary_deviceClassIndex(const String& deviceClassName) { // TwoWay devices are marked with ² in the selector, and discovered as 'light' instead of 'binary_sensor' bool MQTT_binary_deviceClassTwoWay(int devClassIndex) { - switch (devClassIndex) { // Index into mqtt_binary_deviceclass_names - case 1: // power - case 2: // light - case 3: // plug - case 5: // garage_door - case 8: // lock - case 26: // sound - case 28: // vibration - case 29: // switch - case 30: // outlet + switch (devClassIndex) // Index into mqtt_binary_deviceclass_names + { + case 1: // power + case 2: // light + case 3: // plug + case 5: // garage_door + case 8: // lock + case 26: // sound + case 28: // vibration + case 29: // switch + case 30: // outlet return true; default: break; @@ -453,9 +437,10 @@ bool MQTT_binary_deviceClassTwoWay(int devClassIndex) { // Switch devices are marked with ÷ in the selector, and discovered as 'switch' instead of 'light' bool MQTT_binary_deviceClassSwitch(int devClassIndex) { - switch (devClassIndex) { // Index into mqtt_binary_deviceclass_names - case 29: // switch - case 30: // outlet + switch (devClassIndex) // Index into mqtt_binary_deviceclass_names + { + case 29: // switch + case 30: // outlet return true; default: break; @@ -466,9 +451,11 @@ bool MQTT_binary_deviceClassSwitch(int devClassIndex) { # endif // if FEATURE_MQTT_DEVICECLASS # if FEATURE_MQTT_STATE_CLASS + const __FlashStringHelper* MQTT_sensor_StateClass(uint8_t index, bool display) { - switch (index) { + switch (index) + { case 0: return F(""); case 1: return display ? F("Measurement") : F("measurement"); case 2: return display ? F("Measurement-angle") : F("measurement_angle"); @@ -507,7 +494,8 @@ bool MQTT_SendAutoDiscovery(controllerIndex_t ControllerIndex, cpluginID_t CPlug // Dispatch autoDiscovery per supported CPlugin - switch (CPluginID) { + switch (CPluginID) + { case 5: // CPLUGIN_ID_005 : Home assistant/openHAB success = MQTT_HomeAssistant_SendAutoDiscovery(ControllerIndex, *ControllerSettings); break; @@ -544,7 +532,7 @@ bool MQTT_HomeAssistant_SendAutoDiscovery(controllerIndex_t ControllerIn // Device is enabled so send information if (validDeviceIndex(DeviceIndex) && Device[DeviceIndex].SendDataOption && // do (can) we send data? - Settings.TaskDeviceEnabled[x] && // task enabled? + Settings.TaskDeviceEnabled(x) && // task enabled? Settings.TaskDeviceSendData[ControllerIndex][x] // selected for this controller? ) { const String taskName = getTaskDeviceName(x); @@ -636,7 +624,8 @@ bool MQTT_HomeAssistant_SendAutoDiscovery(controllerIndex_t ControllerIn struct EventStruct TempEvent(x); const uint8_t varCount = discoveryItems[s].varIndex + discoveryItems[s].valueCount; - switch (discoveryItems[s].VType) { + switch (discoveryItems[s].VType) + { // VType values to support, mapped to device classes: case Sensor_VType::SENSOR_TYPE_SWITCH: case Sensor_VType::SENSOR_TYPE_SWITCH_INVERTED: diff --git a/src/src/Helpers/_CPlugin_Helper_webform.cpp b/src/src/Helpers/_CPlugin_Helper_webform.cpp index 8e103aeda4..ec1ce7b764 100644 --- a/src/src/Helpers/_CPlugin_Helper_webform.cpp +++ b/src/src/Helpers/_CPlugin_Helper_webform.cpp @@ -138,7 +138,7 @@ void addControllerEnabledForm(controllerIndex_t controllerindex) { bool isAlternativeDisplayName = false; const String displayName = getControllerParameterDisplayName(ProtocolIndex, varType, isAlternativeDisplayName); const String internalName = getControllerParameterInternalName(ProtocolIndex, varType); - addFormCheckBox(displayName, internalName, Settings.ControllerEnabled[controllerindex]); + addFormCheckBox(displayName, internalName, Settings.ControllerEnabled(controllerindex)); } #if FEATURE_MQTT_TLS || FEATURE_HTTP_TLS @@ -416,7 +416,7 @@ void addControllerParameterForm(const ControllerSettingsStruct & ControllerSett addTaskSelectBox(displayName, internalName, ControllerSettings.SampleSetInitiator); break; case ControllerSettingsStruct::CONTROLLER_ENABLED: - addFormCheckBox(displayName, internalName, Settings.ControllerEnabled[controllerindex]); + addFormCheckBox(displayName, internalName, Settings.ControllerEnabled(controllerindex)); break; } } @@ -606,7 +606,7 @@ void saveControllerParameterForm(ControllerSettingsStruct & ControllerSet ControllerSettings.SampleSetInitiator = getFormItemInt(internalName, ControllerSettings.SampleSetInitiator); break; case ControllerSettingsStruct::CONTROLLER_ENABLED: - Settings.ControllerEnabled[controllerindex] = isFormItemChecked(internalName); + Settings.ControllerEnabled(controllerindex, isFormItemChecked(internalName)); break; } } diff --git a/src/src/Helpers/_CPlugin_init.cpp b/src/src/Helpers/_CPlugin_init.cpp index 6fde51e149..d66895d752 100644 --- a/src/src/Helpers/_CPlugin_init.cpp +++ b/src/src/Helpers/_CPlugin_init.cpp @@ -2182,7 +2182,7 @@ void CPluginInit() // Set all not supported cplugins to disabled. for (controllerIndex_t controller = 0; controller < CONTROLLER_MAX; ++controller) { if (!supportedCPluginID(Settings.Protocol[controller])) { - Settings.ControllerEnabled[controller] = false; + Settings.ControllerEnabled(controller, false); } } CPluginCall(CPlugin::Function::CPLUGIN_INIT_ALL, 0); @@ -2201,7 +2201,7 @@ void CPlugin_Exit_Init(controllerIndex_t controllerIndex) // May need to call init later, so make sure exit is called first CPluginCall(CPlugin::Function::CPLUGIN_EXIT, &TempEvent, dummy); - if (Settings.ControllerEnabled[controllerIndex]) { + if (Settings.ControllerEnabled(controllerIndex)) { CPluginCall(CPlugin::Function::CPLUGIN_INIT, &TempEvent, dummy); } } diff --git a/src/src/Helpers/_Plugin_Helper_GPIO.cpp b/src/src/Helpers/_Plugin_Helper_GPIO.cpp index 2093b1903f..fe73653388 100644 --- a/src/src/Helpers/_Plugin_Helper_GPIO.cpp +++ b/src/src/Helpers/_Plugin_Helper_GPIO.cpp @@ -84,7 +84,7 @@ bool GPIO_plugin_helper_data_t::init( savePortStatus(_portStatus_key, newStatus); // @giig1967g-20181022: set initial UserVar of the switch - if ((newStatus.state != -1) && Settings.TaskDevicePin1Inversed[event->TaskIndex]) { + if ((newStatus.state != -1) && Settings.TaskDevicePin1Inversed(event->TaskIndex)) { UserVar.setFloat(event->TaskIndex, 0, !newStatus.state); } else { UserVar.setFloat(event->TaskIndex, 0, newStatus.state); @@ -207,7 +207,7 @@ void GPIO_plugin_helper_data_t::tenPerSecond( currentStatus.output = new_outputState; bool sendState = new_outputState; - if (Settings.TaskDevicePin1Inversed[event->TaskIndex]) + if (Settings.TaskDevicePin1Inversed(event->TaskIndex)) { sendState = !sendState; } @@ -327,7 +327,7 @@ void GPIO_plugin_helper_data_t::tenPerSecond( { bool sendState = pinState; - if (Settings.TaskDevicePin1Inversed[event->TaskIndex]) + if (Settings.TaskDevicePin1Inversed(event->TaskIndex)) { sendState = !sendState; } diff --git a/src/src/Helpers/_Plugin_init.cpp b/src/src/Helpers/_Plugin_init.cpp index 8c4c3cf4b5..8cb2b14f77 100644 --- a/src/src/Helpers/_Plugin_init.cpp +++ b/src/src/Helpers/_Plugin_init.cpp @@ -2287,7 +2287,7 @@ void PluginInit(bool priorityOnly) // Set all not supported plugins to disabled. for (taskIndex_t taskIndex = 0; taskIndex < TASKS_MAX; ++taskIndex) { if (!supportedPluginID(Settings.getPluginID_for_task(taskIndex))) { - Settings.TaskDeviceEnabled[taskIndex] = false; + Settings.TaskDeviceEnabled(taskIndex, false); } } diff --git a/src/src/PluginStructs/P001_data_struct.cpp b/src/src/PluginStructs/P001_data_struct.cpp index 13acef231c..d3c73b577d 100644 --- a/src/src/PluginStructs/P001_data_struct.cpp +++ b/src/src/PluginStructs/P001_data_struct.cpp @@ -38,7 +38,7 @@ P001_data_struct::P001_data_struct(struct EventStruct *event) : // setPinState(PLUGIN_ID_001, _data._pin, PIN_MODE_INPUT, switchstate[event->TaskIndex]); // if it is in the device list we assume it's an input pin - if (Settings.TaskDevicePin1PullUp[event->TaskIndex]) + if (Settings.TaskDevicePin1PullUp(event->TaskIndex)) { setInternalGPIOPullupMode(_data._pin); pinModeValue = PIN_MODE_INPUT_PULLUP; diff --git a/src/src/PluginStructs/P146_data_struct.cpp b/src/src/PluginStructs/P146_data_struct.cpp index 648f781fe9..d06e10f586 100644 --- a/src/src/PluginStructs/P146_data_struct.cpp +++ b/src/src/PluginStructs/P146_data_struct.cpp @@ -389,7 +389,7 @@ bool P146_data_struct::sendViaOriginalTask( tmpEvent.idx = Settings.TaskDeviceID[x][P146_TaskIndex]; if (Settings.TaskDeviceSendData[x][P146_TaskIndex] && - Settings.ControllerEnabled[x] && + Settings.ControllerEnabled(x) && Settings.Protocol[x]) { protocolIndex_t ProtocolIndex = getProtocolIndex_from_ControllerIndex(x); diff --git a/src/src/WebServer/ControllerPage.cpp b/src/src/WebServer/ControllerPage.cpp index 3a58ef9dd5..62956f952c 100644 --- a/src/src/WebServer/ControllerPage.cpp +++ b/src/src/WebServer/ControllerPage.cpp @@ -96,7 +96,7 @@ void handle_controllers() { // AutoDiscovery enabled? if (ControllerSettings->mqtt_autoDiscovery() - && Settings.ControllerEnabled[controllerindex] + && Settings.ControllerEnabled(controllerindex) // && (ControllerSettings->MqttAutoDiscoveryTrigger[0] != 0) && (ControllerSettings->MqttAutoDiscoveryTopic[0] != 0) @@ -180,7 +180,7 @@ void handle_controllers_clearLoadDefaults(uint8_t controllerindex, ControllerSet safe_strncpy(ControllerSettings.LWTMessageDisconnect, TempEvent.String5.c_str(), sizeof(ControllerSettings.LWTMessageDisconnect)); // NOTE: do not enable controller by default, give user a change to enter sensible values first - Settings.ControllerEnabled[controllerindex] = false; + Settings.ControllerEnabled(controllerindex, false); // not resetted to default (for convenience) // SecuritySettings.ControllerUser[controllerindex] @@ -243,7 +243,7 @@ void handle_controllers_ShowAllControllersTable() if (cplugin_set) { - addEnabled(Settings.ControllerEnabled[x]); + addEnabled(Settings.ControllerEnabled(x)); html_TD(); addHtml(getCPluginNameFromCPluginID(Settings.Protocol[x])); @@ -492,7 +492,7 @@ void handle_controllers_ControllerSettingsPage(controllerIndex_t controllerindex # if FEATURE_MQTT - if (proto.usesMQTT && Settings.ControllerEnabled[controllerindex]) { + if (proto.usesMQTT && Settings.ControllerEnabled(controllerindex)) { addFormSubHeader(F("Connection Status")); addRowLabel(F("MQTT Client Connected")); addEnabled(MQTTclient_connected); diff --git a/src/src/WebServer/DevicesPage.cpp b/src/src/WebServer/DevicesPage.cpp index 2c441b4e33..157797b9a1 100644 --- a/src/src/WebServer/DevicesPage.cpp +++ b/src/src/WebServer/DevicesPage.cpp @@ -189,7 +189,7 @@ void handle_devices() { // May need to call PLUGIN_INIT, however we must make sure it is exited first PluginCall(PLUGIN_EXIT, &TempEvent, dummy); - if (Settings.TaskDeviceEnabled[taskIndex]) { + if (Settings.TaskDeviceEnabled(taskIndex)) { if (PluginCall(PLUGIN_INIT, &TempEvent, dummy)) { PluginCall(PLUGIN_READ, &TempEvent, dummy); } @@ -438,11 +438,11 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task } if (device.PullUpOption) { - Settings.TaskDevicePin1PullUp[taskIndex] = isFormItemChecked(F("TDPPU")); + Settings.TaskDevicePin1PullUp(taskIndex, isFormItemChecked(F("TDPPU"))); } if (device.InverseLogicOption) { - Settings.TaskDevicePin1Inversed[taskIndex] = isFormItemChecked(F("TDPI")); + Settings.TaskDevicePin1Inversed(taskIndex, isFormItemChecked(F("TDPI"))); } if (device.isSerial()) @@ -551,7 +551,7 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task TempEvent.ControllerIndex = x; if (Settings.TaskDeviceSendData[TempEvent.ControllerIndex][TempEvent.TaskIndex] && - Settings.ControllerEnabled[TempEvent.ControllerIndex] && Settings.Protocol[TempEvent.ControllerIndex]) + Settings.ControllerEnabled(TempEvent.ControllerIndex) && Settings.Protocol[TempEvent.ControllerIndex]) { String dummy; CPluginCall(CPlugin::Function::CPLUGIN_TASK_CHANGE_NOTIFICATION, &TempEvent, dummy); @@ -633,7 +633,7 @@ void handle_devicess_ShowAllTasksTable(uint8_t page) int8_t spi_gpios[3] { -1, -1, -1 }; #endif struct EventStruct TempEvent(x); - addEnabled(Settings.TaskDeviceEnabled[x] && validDeviceIndex(DeviceIndex)); + addEnabled(Settings.TaskDeviceEnabled(x) && validDeviceIndex(DeviceIndex)); html_TD(); addHtml(getPluginNameFromPluginID(Settings.getPluginID_for_task(x))); @@ -1150,7 +1150,7 @@ void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, uint8_t page) addFormTextBox(F("Name"), F("TDN"), getTaskDeviceName(taskIndex), NAME_FORMULA_LENGTH_MAX); // ="taskdevicename" addFormCheckBox(F("Enabled"), F("TDE"), - Settings.TaskDeviceEnabled[taskIndex], + Settings.TaskDeviceEnabled(taskIndex), // Settings.TaskDeviceEnabled[taskIndex].enabled, Settings.isTaskEnableReadonly(taskIndex)); // ="taskdeviceenabled" @@ -1159,7 +1159,7 @@ void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, uint8_t page) # if FEATURE_PLUGIN_PRIORITY if (device.PowerManager) { // Check extra priority device flags when available - bool disablePrio = !Settings.TaskDeviceEnabled[taskIndex]; + bool disablePrio = !Settings.TaskDeviceEnabled(taskIndex); for (taskIndex_t t = 0; t < TASKS_MAX && !disablePrio; t++) { if (t != taskIndex) { // Ignore current device @@ -1343,7 +1343,7 @@ void devicePage_show_pin_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex if (device.PullUpOption) { - addFormCheckBox(F("Internal PullUp"), F("TDPPU"), Settings.TaskDevicePin1PullUp[taskIndex]); // ="taskdevicepin1pullup" + addFormCheckBox(F("Internal PullUp"), F("TDPPU"), Settings.TaskDevicePin1PullUp(taskIndex)); // ="taskdevicepin1pullup" addFormNote(F("Best to (also) configure pull-up on Hardware tab under \"GPIO boot states\"")); # if defined(ESP8266) @@ -1356,7 +1356,7 @@ void devicePage_show_pin_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex if (device.InverseLogicOption) { - addFormCheckBox(F("Inversed Logic"), F("TDPI"), Settings.TaskDevicePin1Inversed[taskIndex]); // ="taskdevicepin1inversed" + addFormCheckBox(F("Inversed Logic"), F("TDPI"), Settings.TaskDevicePin1Inversed(taskIndex)); // ="taskdevicepin1inversed" addFormNote(F("Will go into effect on next input change.")); } @@ -1694,7 +1694,7 @@ void devicePage_show_controller_config(taskIndex_t taskIndex, deviceIndex_t Devi addHtml(F("Send to Controller ")); addHtml(getControllerSymbol(controllerNr)); addHtmlDiv(F("note"), wrap_braces(getCPluginNameFromCPluginID(Settings.Protocol[controllerNr]) + F(", ") + // Most compact code... - (Settings.ControllerEnabled[controllerNr] ? F("enabled") : F("disabled")) + (Settings.ControllerEnabled(controllerNr) ? F("enabled") : F("disabled")) #if FEATURE_MQTT_DISCOVER + (showMqttGroup ? F(", Auto Discovery") : F("")) #endif // if FEATURE_MQTT_DISCOVER diff --git a/src/src/WebServer/JSON.cpp b/src/src/WebServer/JSON.cpp index 366fe656b3..37ef15f5e2 100644 --- a/src/src/WebServer/JSON.cpp +++ b/src/src/WebServer/JSON.cpp @@ -471,7 +471,7 @@ void handle_json() const uint8_t valueCount = getValueCountForTask(TaskIndex); if (valueCount != 0) { - if (Settings.TaskDeviceEnabled[TaskIndex]) { + if (Settings.TaskDeviceEnabled(TaskIndex)) { if (taskInterval == 0) { ttl_json = 1; } else { @@ -657,7 +657,7 @@ void handle_json() } taskWriter->write({ F("TaskEnabled"), - Settings.TaskDeviceEnabled[TaskIndex] }); + Settings.TaskDeviceEnabled(TaskIndex) }); taskWriter->write({ F("TaskNumber"), TaskIndex + 1 }); if (showSpecificTask) { diff --git a/src/src/WebServer/Metrics.cpp b/src/src/WebServer/Metrics.cpp index e3b8469c3f..b97cdbb9e6 100644 --- a/src/src/WebServer/Metrics.cpp +++ b/src/src/WebServer/Metrics.cpp @@ -106,7 +106,7 @@ void handle_metrics_devices() { const bool pluginID_set = INVALID_PLUGIN_ID != Settings.getPluginID_for_task(x); if (pluginID_set) { - if (Settings.TaskDeviceEnabled[x]) { + if (Settings.TaskDeviceEnabled(x)) { String deviceName = getTaskDeviceName(x); if (deviceName.isEmpty()) { // Empty name, then use taskN diff --git a/src/src/WebServer/NotificationPage.cpp b/src/src/WebServer/NotificationPage.cpp index 6014f2ce54..a6740c31a5 100644 --- a/src/src/WebServer/NotificationPage.cpp +++ b/src/src/WebServer/NotificationPage.cpp @@ -62,7 +62,7 @@ void handle_notifications() { if (notification == INVALID_N_PLUGIN_ID) { Settings.Notification[notificationindex] = INVALID_N_PLUGIN_ID.value; - Settings.NotificationEnabled[notificationindex] = false; + Settings.NotificationEnabled(notificationindex, false); } else { MakeNotificationSettings(NotificationSettings); @@ -94,7 +94,7 @@ void handle_notifications() { NotificationSettings->Timeout_ms = getFormItemInt(F("timeout"), NPLUGIN_001_DEF_TM); NotificationSettings->Pin1 = getFormItemInt(F("pin1"), -1); NotificationSettings->Pin2 = getFormItemInt(F("pin2"), -1); - Settings.NotificationEnabled[notificationindex] = isFormItemChecked(F("notificationenabled")); + Settings.NotificationEnabled(notificationindex, isFormItemChecked(F("notificationenabled"))); strncpy_webserver_arg(NotificationSettings->Domain, F("domain")); strncpy_webserver_arg(NotificationSettings->Server, F("server")); strncpy_webserver_arg(NotificationSettings->Sender, F("sender")); @@ -121,7 +121,7 @@ void handle_notifications() { nprotocolIndex_t NotificationProtocolIndex = getNProtocolIndex_from_NotifierIndex(notificationindex); if (validNProtocolIndex(NotificationProtocolIndex) && - Settings.NotificationEnabled[notificationindex]) + Settings.NotificationEnabled(notificationindex)) { // TempEvent.NotificationProtocolIndex = NotificationProtocolIndex; TempEvent.NotificationIndex = notificationindex; @@ -162,7 +162,7 @@ void handle_notifications() { if (nplugin_set) { - addEnabled(Settings.NotificationEnabled[x]); + addEnabled(Settings.NotificationEnabled(x)); html_TD(); String NotificationName = F("(plugin not found?)"); @@ -222,7 +222,7 @@ void handle_notifications() { if (Settings.Notification[notificationindex] != INVALID_N_PLUGIN_ID.value) { addRowLabel(F("Enabled")); - addCheckBox(F("notificationenabled"), Settings.NotificationEnabled[notificationindex]); + addCheckBox(F("notificationenabled"), Settings.NotificationEnabled(notificationindex)); addFormSeparator(2); MakeNotificationSettings(NotificationSettings); diff --git a/src/src/WebServer/WebTemplateParser.cpp b/src/src/WebServer/WebTemplateParser.cpp index 7f88138ec3..46365c8eb3 100644 --- a/src/src/WebServer/WebTemplateParser.cpp +++ b/src/src/WebServer/WebTemplateParser.cpp @@ -371,7 +371,7 @@ void WebTemplateParser::getErrorNotifications() { if (Settings.Protocol[x] != 0) { const protocolIndex_t ProtocolIndex = getProtocolIndex_from_ControllerIndex(x); - if (Settings.ControllerEnabled[x] && + if (Settings.ControllerEnabled(x) && validProtocolIndex(ProtocolIndex) && getProtocolStruct(ProtocolIndex).usesMQTT) { ++nrMQTTenabled; From e3fb32117d4ecfb609ddc6d6ddd683235f9fd470 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Sat, 4 Apr 2026 20:52:35 +0200 Subject: [PATCH 3/6] [Settings] Improved initialization --- src/src/DataStructs/SettingsStruct.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/src/DataStructs/SettingsStruct.h b/src/src/DataStructs/SettingsStruct.h index d8763ad9f7..009be46b5f 100644 --- a/src/src/DataStructs/SettingsStruct.h +++ b/src/src/DataStructs/SettingsStruct.h @@ -747,7 +747,7 @@ class SettingsStruct_tmpl }; #if FEATURE_TASKDEVICE_BITFIELDS_4 union { - boolean TaskDeviceBitfield_4_internal[N_TASKS]{}; + uint8_t TaskDeviceBitfield_4_internal[N_TASKS]{}; struct { uint8_t TaskDevicePin1PullUp : 1; // Bit 0 used uint8_t unusedU4_01 : 1; // Bit 1 @@ -765,7 +765,7 @@ class SettingsStruct_tmpl int16_t TaskDevicePluginConfig[N_TASKS][PLUGIN_CONFIGVAR_MAX]{}; #if FEATURE_TASKDEVICE_BITFIELDS_5 union { - boolean TaskDeviceBitfield5_internal[N_TASKS]{}; + uint8_t TaskDeviceBitfield5_internal[N_TASKS]{}; struct { uint8_t TaskDevicePin1Inversed : 1; // Bit 0 used uint8_t unusedU5_01 : 1; // Bit 1 @@ -794,7 +794,7 @@ class SettingsStruct_tmpl uint32_t TaskDeviceTimer[N_TASKS] = {0}; #if FEATURE_TASKDEVICE_BITFIELDS_6 union { - boolean TaskDeviceBitfield_6_internal[N_TASKS]{}; + uint8_t TaskDeviceBitfield_6_internal[N_TASKS]{}; struct { uint8_t TaskDeviceEnabled : 1; // Bit 0 used uint8_t unusedU6_01 : 1; // Bit 1 @@ -811,7 +811,7 @@ union { #endif // if FEATURE_TASKDEVICE_BITFIELDS_6 #if FEATURE_CONTROLLER_BITFIELDS_1 union { - boolean ControllerBitfield_1_internal[CONTROLLER_MAX]{}; + uint8_t ControllerBitfield_1_internal[CONTROLLER_MAX]{}; struct { uint8_t ControllerEnabled : 1; // Bit 0 used uint8_t unusedC1_01 : 1; // Bit 1 @@ -828,7 +828,7 @@ union { #endif // if FEATURE_CONTROLLER_BITFIELDS_1 #if FEATURE_NOTIFICATION_BITFIELDS_1 union { - boolean NotificationBitfield_1_internal[NOTIFICATION_MAX]{}; + uint8_t NotificationBitfield_1_internal[NOTIFICATION_MAX]{}; struct { uint8_t NotificationEnabled : 1; // Bit 0 used uint8_t unusedN1_01 : 1; // Bit 1 From 132bc55edcc96d98ed68f6e1def8c43ef59d6f98 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Sat, 4 Apr 2026 23:00:35 +0200 Subject: [PATCH 4/6] [Settings] Convert even more settings to bitfields, compile-time optional to enable when needed --- src/_C002.cpp | 2 +- src/_C013.cpp | 2 +- src/src/DataStructs/SettingsStruct.h | 71 +++++++++++++++++++- src/src/DataStructs_templ/SettingsStruct.cpp | 2 +- src/src/ESPEasyCore/Controller.cpp | 2 +- src/src/Helpers/StringParser.cpp | 2 +- src/src/Helpers/_CPlugin_Helper_mqtt.cpp | 2 +- src/src/PluginStructs/P146_data_struct.cpp | 2 +- src/src/WebServer/DevicesPage.cpp | 10 +-- src/src/WebServer/JSON.cpp | 2 +- 10 files changed, 83 insertions(+), 14 deletions(-) diff --git a/src/_C002.cpp b/src/_C002.cpp index 0717c13e9d..f090acccb0 100644 --- a/src/_C002.cpp +++ b/src/_C002.cpp @@ -97,7 +97,7 @@ bool CPlugin_002(CPlugin::Function function, struct EventStruct *event, String& # endif // if defined(USES_P088) if (Settings.TaskDeviceEnabled(x) && - (Settings.TaskDeviceSendData[ControllerID][x] + (Settings.TaskDeviceSendData(ControllerID, x) || (Settings.getPluginID_for_task(x) == PLUGIN_ID_DOMOTICZ_HELPER) // Domoticz helper doesn't have controller checkboxes... # if defined(USES_P088) || (Settings.getPluginID_for_task(x) == PLUGIN_ID_HEATPUMP_IR) // Heatpump IR doesn't have controller checkboxes... diff --git a/src/_C013.cpp b/src/_C013.cpp index 530b26103c..cde3185d3e 100644 --- a/src/_C013.cpp +++ b/src/_C013.cpp @@ -296,7 +296,7 @@ void C013_Receive(struct EventStruct *event) { } for (controllerIndex_t x = 0; x < CONTROLLER_MAX; x++) { - Settings.TaskDeviceSendData[x][infoReply->destTaskIndex] = false; + Settings.TaskDeviceSendData(x, infoReply->destTaskIndex, false); } safe_strncpy(ExtraTaskSettings.TaskDeviceName, infoReply->taskName, sizeof(infoReply->taskName)); diff --git a/src/src/DataStructs/SettingsStruct.h b/src/src/DataStructs/SettingsStruct.h index 009be46b5f..71a4b21ff3 100644 --- a/src/src/DataStructs/SettingsStruct.h +++ b/src/src/DataStructs/SettingsStruct.h @@ -69,6 +69,12 @@ enum class PinBootState { #ifndef FEATURE_UNNAMED_BITFIELDS_2 #define FEATURE_UNNAMED_BITFIELDS_2 0 // 3x 7 bits globally, adds ESP32: 256 ESP8266: 176 bytes #endif +#ifndef FEATURE_UNNAMED_BITFIELDS_3 + #define FEATURE_UNNAMED_BITFIELDS_3 0 // 7 bits globally, adds ESP32: 36 ESP8266: 64 bytes +#endif +#ifndef FEATURE_UNNAMED_BITFIELDS_4 + #define FEATURE_UNNAMED_BITFIELDS_4 0 // 7 bits globally, adds ESP32: 36 ESP8266: 64 bytes +#endif #ifndef FEATURE_TASKDEVICE_BITFIELDS_4 #define FEATURE_TASKDEVICE_BITFIELDS_4 0 // 7 bits per TaskDevice, adds ESP32: 32 ESP8266: 64 bytes + 16 bytes per bit-function #endif @@ -84,6 +90,9 @@ enum class PinBootState { #ifndef FEATURE_NOTIFICATION_BITFIELDS_1 #define FEATURE_NOTIFICATION_BITFIELDS_1 0 // 7 bits per Notifier, adds ESP32: 108 ESP8266: 64 bytes + 16 bytes per bit-function #endif +#ifndef FEATURE_CONTROLLERTASK_BITFIELDS_1 + #define FEATURE_CONTROLLERTASK_BITFIELDS_1 0 // 7 bits per controller/task combo, adds ESP32: 56 ESP8266: 80 bytes + 16/20 bytes per bit-function +#endif @@ -282,6 +291,18 @@ class SettingsStruct_tmpl inline void NotificationEnabled(uint8_t notificationIndex, bool state) { _NotificationEnabled[notificationIndex] = state; } #endif // if FEATURE_NOTIFICATION_BITFIELDS_1 + #if FEATURE_CONTROLLERTASK_BITFIELDS_1 + inline const bool TaskDeviceSendData(controllerIndex_t controllerIndex, taskIndex_t taskIndex) { return ControllerTaskBitfield_1[controllerIndex][taskIndex].TaskDeviceSendData; } + inline void TaskDeviceSendData(controllerIndex_t controllerIndex, taskIndex_t taskIndex, bool state) { ControllerTaskBitfield_1[controllerIndex][taskIndex].TaskDeviceSendData = state; } + + // Template for accessor, using bool + inline const bool controllerTaskBitfield1_01(controllerIndex_t controllerIndex, taskIndex_t taskIndex) { return ControllerTaskBitfield_1[controllerIndex][taskIndex].unusedCT1_01; } + inline void ControllerTaskBitfield1_01(controllerIndex_t controllerIndex, taskIndex_t taskIndex, uint8_t value) { ControllerTaskBitfield_1[controllerIndex][taskIndex].unusedCT1_01 = value; } + #else // if FEATURE_CONTROLLERTASK_BITFIELDS_1 + inline const bool TaskDeviceSendData(controllerIndex_t controllerIndex, taskIndex_t taskIndex) { return _TaskDeviceSendData[controllerIndex][taskIndex]; } + inline void TaskDeviceSendData(controllerIndex_t controllerIndex, taskIndex_t taskIndex, bool state) { _TaskDeviceSendData[controllerIndex][taskIndex] = state; } + #endif // if FEATURE_CONTROLLERTASK_BITFIELDS_1 + // Connect to Hidden SSID using channel and BSSID // This is much slower, but appears to be needed for some access points // like MikroTik. @@ -844,7 +865,23 @@ union { boolean _NotificationEnabled[NOTIFICATION_MAX] = {0}; #endif // if FEATURE_NOTIFICATION_BITFIELDS_1 uint32_t TaskDeviceID[CONTROLLER_MAX][N_TASKS]{}; // IDX number (mainly used by Domoticz) - boolean TaskDeviceSendData[CONTROLLER_MAX][N_TASKS]{}; + #if FEATURE_CONTROLLERTASK_BITFIELDS_1 + union { + uint8_t ControllerTaskBitfield_1_internal[CONTROLLER_MAX][N_TASKS]{}; + struct { + uint8_t TaskDeviceSendData : 1; // Bit 0 used + uint8_t unusedCT1_01 : 1; // Bit 1 + uint8_t unusedCT1_02 : 1; // Bit 2 + uint8_t unusedCT1_03 : 1; // Bit 3 + uint8_t unusedCT1_04 : 1; // Bit 4 + uint8_t unusedCT1_05 : 1; // Bit 5 + uint8_t unusedCT1_06 : 1; // Bit 6 + uint8_t unusedCT1_07 : 1; // Bit 7 + } ControllerTaskBitfield_1[CONTROLLER_MAX][N_TASKS]; + }; + #else // if FEATURE_CONTROLLERTASK_BITFIELDS_1 + boolean _TaskDeviceSendData[CONTROLLER_MAX][N_TASKS]{}; + #endif // if FEATURE_CONTROLLERTASK_BITFIELDS_1 union { struct { uint32_t Pin_status_led_Inversed : 1; // Bit 0 used @@ -884,11 +921,43 @@ union { }; uint16_t DST_Start = 0; uint16_t DST_End = 0; + #if FEATURE_UNNAMED_BITFIELDS_3 + union { + struct { + uint8_t UseRTOSMultitasking : 1; // Bit 0 used + uint8_t unusedU3_01 : 1; // Bit 1 + uint8_t unusedU3_02 : 1; // Bit 2 + uint8_t unusedU3_03 : 1; // Bit 3 + uint8_t unusedU3_04 : 1; // Bit 4 + uint8_t unusedU3_05 : 1; // Bit 5 + uint8_t unusedU3_06 : 1; // Bit 6 + uint8_t unusedU3_07 : 1; // Bit 7 + }; + uint8_t _unnamedUnion3{}; + }; + #else // if FEATURE_UNNAMED_BITFIELDS_3 boolean UseRTOSMultitasking = false; + #endif // if FEATURE_UNNAMED_BITFIELDS_3 int8_t Pin_Reset = -1; uint8_t SyslogFacility = 0; uint32_t StructSize = 0; // Forced to be 32 bit, to make sure alignment is clear. + #if FEATURE_UNNAMED_BITFIELDS_4 + union { + struct { + uint8_t MQTTUseUnitNameAsClientId_unused : 1; // Bit 0 used + uint8_t unusedU4_01 : 1; // Bit 1 + uint8_t unusedU4_02 : 1; // Bit 2 + uint8_t unusedU4_03 : 1; // Bit 3 + uint8_t unusedU4_04 : 1; // Bit 4 + uint8_t unusedU4_05 : 1; // Bit 5 + uint8_t unusedU4_06 : 1; // Bit 6 + uint8_t unusedU4_07 : 1; // Bit 7 + }; + uint8_t _unnamedUnion4{}; + }; + #else // if FEATURE_UNNAMED_BITFIELDS_4 boolean MQTTUseUnitNameAsClientId_unused = false; + #endif // if FEATURE_UNNAMED_BITFIELDS_4 //its safe to extend this struct, up to several bytes, default values in config are 0 //look in misc.ino how config.dat is used because also other stuff is stored in it at different offsets. diff --git a/src/src/DataStructs_templ/SettingsStruct.cpp b/src/src/DataStructs_templ/SettingsStruct.cpp index 6d13340e2d..c45b0b6c86 100644 --- a/src/src/DataStructs_templ/SettingsStruct.cpp +++ b/src/src/DataStructs_templ/SettingsStruct.cpp @@ -788,7 +788,7 @@ void SettingsStruct_tmpl::clearTask(taskIndex_t task) { for (controllerIndex_t i = 0; i < CONTROLLER_MAX; ++i) { TaskDeviceID[i][task] = 0u; - TaskDeviceSendData[i][task] = false; + TaskDeviceSendData(i, task, false); } TaskDeviceNumber[task] = 0u; //.setInvalid(); // OLD_TaskDeviceID[task] = 0u; // UNUSED: this must be removed diff --git a/src/src/ESPEasyCore/Controller.cpp b/src/src/ESPEasyCore/Controller.cpp index 1711a460ac..5f8f048ea8 100644 --- a/src/src/ESPEasyCore/Controller.cpp +++ b/src/src/ESPEasyCore/Controller.cpp @@ -66,7 +66,7 @@ void sendData(struct EventStruct *event, bool sendEvents) for (controllerIndex_t x = 0; x < CONTROLLER_MAX; x++) { if (Settings.ControllerEnabled(x) && - Settings.TaskDeviceSendData[x][event->TaskIndex] && + Settings.TaskDeviceSendData(x, event->TaskIndex) && Settings.Protocol[x]) { event->ControllerIndex = x; diff --git a/src/src/Helpers/StringParser.cpp b/src/src/Helpers/StringParser.cpp index 1aabe16f65..101445b0b7 100644 --- a/src/src/Helpers/StringParser.cpp +++ b/src/src/Helpers/StringParser.cpp @@ -299,7 +299,7 @@ String parseTemplate_padded(String& tmpString, uint8_t minimal_lineSize, bool us if (validIntFromString(ctrl, ctrlNr) && (ctrlNr >= 1) && (ctrlNr <= CONTROLLER_MAX) && Settings.ControllerEnabled(ctrlNr - 1)) { // Controller nr. valid and enabled if (valueName.endsWith(F(".enabled"))) { // Task-controller enabled - value = Settings.TaskDeviceSendData[ctrlNr - 1][taskIndex]; + value = Settings.TaskDeviceSendData(ctrlNr - 1, taskIndex); } else if (valueName.endsWith(F(".idx"))) { // Task-controller idx value protocolIndex_t ProtocolIndex = getProtocolIndex_from_ControllerIndex(ctrlNr - 1); diff --git a/src/src/Helpers/_CPlugin_Helper_mqtt.cpp b/src/src/Helpers/_CPlugin_Helper_mqtt.cpp index 428edb1742..f1640c1eab 100644 --- a/src/src/Helpers/_CPlugin_Helper_mqtt.cpp +++ b/src/src/Helpers/_CPlugin_Helper_mqtt.cpp @@ -533,7 +533,7 @@ bool MQTT_HomeAssistant_SendAutoDiscovery(controllerIndex_t ControllerIn if (validDeviceIndex(DeviceIndex) && Device[DeviceIndex].SendDataOption && // do (can) we send data? Settings.TaskDeviceEnabled(x) && // task enabled? - Settings.TaskDeviceSendData[ControllerIndex][x] // selected for this controller? + Settings.TaskDeviceSendData(ControllerIndex, x) // selected for this controller? ) { const String taskName = getTaskDeviceName(x); const int valueCount = getValueCountForTask(x); diff --git a/src/src/PluginStructs/P146_data_struct.cpp b/src/src/PluginStructs/P146_data_struct.cpp index d06e10f586..086ca04670 100644 --- a/src/src/PluginStructs/P146_data_struct.cpp +++ b/src/src/PluginStructs/P146_data_struct.cpp @@ -388,7 +388,7 @@ bool P146_data_struct::sendViaOriginalTask( tmpEvent.ControllerIndex = x; tmpEvent.idx = Settings.TaskDeviceID[x][P146_TaskIndex]; - if (Settings.TaskDeviceSendData[x][P146_TaskIndex] && + if (Settings.TaskDeviceSendData(x, P146_TaskIndex) && Settings.ControllerEnabled(x) && Settings.Protocol[x]) { diff --git a/src/src/WebServer/DevicesPage.cpp b/src/src/WebServer/DevicesPage.cpp index 157797b9a1..afc6dfdc01 100644 --- a/src/src/WebServer/DevicesPage.cpp +++ b/src/src/WebServer/DevicesPage.cpp @@ -418,11 +418,11 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task for (controllerIndex_t controllerNr = 0; controllerNr < CONTROLLER_MAX; controllerNr++) { Settings.TaskDeviceID[controllerNr][taskIndex] = getFormItemInt(getPluginCustomArgName(F("TDID"), controllerNr)); - Settings.TaskDeviceSendData[controllerNr][taskIndex] = isFormItemChecked(getPluginCustomArgName(F("TDSD"), controllerNr)); + Settings.TaskDeviceSendData(controllerNr, taskIndex, isFormItemChecked(getPluginCustomArgName(F("TDSD"), controllerNr))); # if FEATURE_MQTT_DISCOVER if (isFormItemChecked(getPluginCustomArgName(F("TDDSC"), controllerNr)) && - Settings.TaskDeviceSendData[controllerNr][taskIndex]) { + Settings.TaskDeviceSendData(controllerNr, taskIndex)) { discoverController = controllerNr; } # endif // if FEATURE_MQTT_DISCOVER @@ -550,7 +550,7 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task { TempEvent.ControllerIndex = x; - if (Settings.TaskDeviceSendData[TempEvent.ControllerIndex][TempEvent.TaskIndex] && + if (Settings.TaskDeviceSendData(TempEvent.ControllerIndex, TempEvent.TaskIndex) && Settings.ControllerEnabled(TempEvent.ControllerIndex) && Settings.Protocol[TempEvent.ControllerIndex]) { String dummy; @@ -692,7 +692,7 @@ void handle_devicess_ShowAllTasksTable(uint8_t page) for (controllerIndex_t controllerNr = 0; controllerNr < CONTROLLER_MAX; controllerNr++) { - if (Settings.TaskDeviceSendData[controllerNr][x]) + if (Settings.TaskDeviceSendData(controllerNr, x)) { if (doBR) { html_BR(); @@ -1705,7 +1705,7 @@ void devicePage_show_controller_config(taskIndex_t taskIndex, deviceIndex_t Devi html_TD(F("width:50px;padding-left:0")); addCheckBox( getPluginCustomArgName(F("TDSD"), controllerNr), // ="taskdevicesenddata" - Settings.TaskDeviceSendData[controllerNr][taskIndex]); + Settings.TaskDeviceSendData(controllerNr, taskIndex)); # if FEATURE_STRING_VARIABLES const bool allowSendDerived = !device.HideDerivedValues && diff --git a/src/src/WebServer/JSON.cpp b/src/src/WebServer/JSON.cpp index 37ef15f5e2..98cd0da514 100644 --- a/src/src/WebServer/JSON.cpp +++ b/src/src/WebServer/JSON.cpp @@ -603,7 +603,7 @@ void handle_json() if (controllerWriter) { controllerWriter->write({ F("Controller"), x + 1 }); controllerWriter->write({ F("IDX"), Settings.TaskDeviceID[x][TaskIndex] }); - controllerWriter->write({ F("Enabled"), !!Settings.TaskDeviceSendData[x][TaskIndex] }); + controllerWriter->write({ F("Enabled"), !!Settings.TaskDeviceSendData(x, TaskIndex) }); } } } From a5d7c893338deb751181bfe559e146966755ee10 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Mon, 6 Apr 2026 22:40:56 +0200 Subject: [PATCH 5/6] [git] Add idf_component.yml to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f4a4487ca8..c2071345e0 100644 --- a/.gitignore +++ b/.gitignore @@ -92,5 +92,6 @@ src/src/CustomBuild/CompiletimeDefines_generated.h sdkconfig.* src/Custom_.h +src/idf_component.yml compile_commands.json From fdb257a800b71599fe87a874439ed53769379199 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Mon, 6 Apr 2026 23:18:14 +0200 Subject: [PATCH 6/6] [Settings] Remove some code that should be removed --- src/src/DataStructs_templ/SettingsStruct.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/src/DataStructs_templ/SettingsStruct.cpp b/src/src/DataStructs_templ/SettingsStruct.cpp index ee497ee03e..ce7ff2614d 100644 --- a/src/src/DataStructs_templ/SettingsStruct.cpp +++ b/src/src/DataStructs_templ/SettingsStruct.cpp @@ -791,7 +791,6 @@ void SettingsStruct_tmpl::clearTask(taskIndex_t task) { TaskDeviceSendData(i, task, false); } TaskDeviceNumber[task] = 0u; //.setInvalid(); - // OLD_TaskDeviceID[task] = 0u; // UNUSED: this must be removed TaskDevicePin1[task] = -1; TaskDevicePin2[task] = -1; TaskDevicePin3[task] = -1;