From 1dc76de73f510ea7db2d13708fdf11d660ca7d65 Mon Sep 17 00:00:00 2001 From: TD-er Date: Thu, 23 Jun 2022 12:42:27 +0200 Subject: [PATCH] [Cleanup] Minor optimizations to reduce build size --- platformio_esp32_envs.ini | 1 + platformio_esp82xx_base.ini | 1 + src/_P118_Itho.ino | 4 +-- src/src/CustomBuild/define_plugin_sets.h | 10 +++--- src/src/WebServer/Markup_Forms.cpp | 46 ++++++++++++++++++++++-- src/src/WebServer/Markup_Forms.h | 27 +++++++++++++- src/src/WebServer/WebServer.cpp | 12 +++++++ src/src/WebServer/WebServer.h | 6 ++++ 8 files changed, 97 insertions(+), 10 deletions(-) diff --git a/platformio_esp32_envs.ini b/platformio_esp32_envs.ini index f2fd813be..ecb0b1324 100644 --- a/platformio_esp32_envs.ini +++ b/platformio_esp32_envs.ini @@ -20,6 +20,7 @@ lib_ignore = ESP8266Ping extends = common, core_esp32_IDF4_4__2_0_3 lib_deps = Adafruit_ST77xx + Adafruit NeoPixel ArduinoOTA ESP32HTTPUpdateServer FrogmoreScd30 diff --git a/platformio_esp82xx_base.ini b/platformio_esp82xx_base.ini index 8316f9efc..f872648d5 100644 --- a/platformio_esp82xx_base.ini +++ b/platformio_esp82xx_base.ini @@ -53,6 +53,7 @@ build_unflags = -DDEBUG_ESP_PORT -fexceptions lib_deps = Adafruit_ST77xx + Adafruit NeoPixel ESP8266HTTPUpdateServer ESP8266WebServer FrogmoreScd30 diff --git a/src/_P118_Itho.ino b/src/_P118_Itho.ino index cb8e5de5b..5576afc40 100644 --- a/src/_P118_Itho.ino +++ b/src/_P118_Itho.ino @@ -106,7 +106,7 @@ volatile bool PLUGIN_118_Int = false; // Forward declarations void PLUGIN_118_ITHOcheck(); void PLUGIN_118_Publishdata(struct EventStruct *event); -void PLUGIN_118_PluginWriteLog(const String& command); +void PLUGIN_118_PluginWriteLog(const __FlashStringHelper * command); ICACHE_RAM_ATTR void PLUGIN_118_ITHOinterrupt() { @@ -584,7 +584,7 @@ void PLUGIN_118_Publishdata(struct EventStruct *event) #endif // ifndef BUILD_NO_DEBUG } -void PLUGIN_118_PluginWriteLog(const String& command) +void PLUGIN_118_PluginWriteLog(const __FlashStringHelper * command) { String log = F("Send Itho command for: "); diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index 788bf77d4..1cadcc4f8 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -1092,10 +1092,7 @@ To create/register a plugin, you have to : #endif #endif - - -// TESTING ##################################### -#ifdef PLUGIN_SET_TESTING +#if defined(PLUGIN_SET_TESTING) || defined(PLUGIN_SET_TESTING_A) || defined(PLUGIN_SET_TESTING_B) || defined(PLUGIN_SET_TESTING_C) || defined(PLUGIN_SET_TESTING_D) || defined(PLUGIN_SET_TESTING_E) #if !defined(PLUGIN_SET_MAX) && !defined(ESP32) #ifndef LIMIT_BUILD_SIZE #define LIMIT_BUILD_SIZE @@ -1103,8 +1100,11 @@ To create/register a plugin, you have to : #ifndef NOTIFIER_SET_NONE #define NOTIFIER_SET_NONE #endif - #endif // PLUGIN_SET_MAX + #endif +#endif +// TESTING ##################################### +#ifdef PLUGIN_SET_TESTING #define USES_P045 // MPU6050 #define USES_P047 // I2C_soil_misture #define USES_P048 // Motoshield_v2 diff --git a/src/src/WebServer/Markup_Forms.cpp b/src/src/WebServer/Markup_Forms.cpp index 7c057d20e..8d8003c6a 100644 --- a/src/src/WebServer/Markup_Forms.cpp +++ b/src/src/WebServer/Markup_Forms.cpp @@ -126,9 +126,23 @@ void addFormNumericBox(LabelType::Enum label, int value, int min, int max ); } -void addFormNumericBox(const __FlashStringHelper * label, const __FlashStringHelper * id, int value, int min, int max) +void addFormNumericBox(const __FlashStringHelper * label, + const __FlashStringHelper * id, + int value, + int min, + int max + #ifdef ENABLE_TOOLTIPS + , + const String& tooltip + #endif // ifdef ENABLE_TOOLTIPS + ) { - addFormNumericBox(String(label), String(id), value, min, max); + addFormNumericBox(String(label), String(id), value, min, max + #ifdef ENABLE_TOOLTIPS + , tooltip + #endif // ifdef ENABLE_TOOLTIPS + ); + } void addFormNumericBox(const String& label, const String& id, int value, int min, int max @@ -178,6 +192,29 @@ void addFormFloatNumberBox(const String& label, ); } +void addFormFloatNumberBox(const __FlashStringHelper * label, + const __FlashStringHelper * id, + float value, + float min, + float max, + uint8_t nrDecimals, + float stepsize + #ifdef ENABLE_TOOLTIPS + , + const String& tooltip + #endif // ifdef ENABLE_TOOLTIPS + ) +{ + addRowLabel_tr_id(label, id); + addFloatNumberBox(id, value, min, max, nrDecimals, stepsize + #ifdef ENABLE_TOOLTIPS + , tooltip + #endif // ifdef ENABLE_TOOLTIPS + ); +} + + + // ******************************************************************************** // Add a task selector form // ******************************************************************************** @@ -401,6 +438,11 @@ void addFormSelector(const __FlashStringHelper * label, const __FlashStringHelpe addFormSelector(String(label), String(id), optionCount, options, indices, nullptr, selectedIndex, reloadonchange); } +void addFormSelector(const __FlashStringHelper * label, const String& id, int optionCount, const __FlashStringHelper * options[], const int indices[], int selectedIndex, bool reloadonchange) +{ + addFormSelector(String(label), id, optionCount, options, indices, nullptr, selectedIndex, reloadonchange); +} + void addFormSelector(const String& label, const String& id, int optionCount, const __FlashStringHelper * options[], const int indices[], int selectedIndex) { addFormSelector(label, id, optionCount, options, indices, nullptr, selectedIndex, false); diff --git a/src/src/WebServer/Markup_Forms.h b/src/src/WebServer/Markup_Forms.h index 03ff00646..2c41015db 100644 --- a/src/src/WebServer/Markup_Forms.h +++ b/src/src/WebServer/Markup_Forms.h @@ -74,6 +74,17 @@ void addFormNumericBox(LabelType::Enum label, #endif // ifdef ENABLE_TOOLTIPS ); +void addFormNumericBox(const __FlashStringHelper * label, + const __FlashStringHelper * id, + int value, + int min = INT_MIN, + int max = INT_MAX + #ifdef ENABLE_TOOLTIPS + , + const String& tooltip = EMPTY_STRING + #endif // ifdef ENABLE_TOOLTIPS + ); + void addFormNumericBox(const String& label, const String& id, int value, @@ -85,6 +96,7 @@ void addFormNumericBox(const String& label, #endif // ifdef ENABLE_TOOLTIPS ); + void addFormFloatNumberBox(LabelType::Enum label, float value, float min, @@ -109,7 +121,19 @@ void addFormFloatNumberBox(const String& label, const String& tooltip = EMPTY_STRING #endif // ifdef ENABLE_TOOLTIPS ); -void addFormNumericBox(const __FlashStringHelper * label, const __FlashStringHelper * id, int value, int min = INT_MIN, int max = INT_MAX); + +void addFormFloatNumberBox(const __FlashStringHelper * label, + const __FlashStringHelper * id, + float value, + float min, + float max, + uint8_t nrDecimals = 6, + float stepsize = 0.0f + #ifdef ENABLE_TOOLTIPS + , + const String& tooltip = EMPTY_STRING + #endif // ifdef ENABLE_TOOLTIPS + ); // ******************************************************************************** @@ -245,6 +269,7 @@ void addFormSelector(const String& label, ); void addFormSelector(const __FlashStringHelper * label, const __FlashStringHelper * id, int optionCount, const __FlashStringHelper * options[], const int indices[], int selectedIndex, bool reloadonchange = false); +void addFormSelector(const __FlashStringHelper * label, const String& id, int optionCount, const __FlashStringHelper * options[], const int indices[], int selectedIndex, bool reloadonchange = false); void addFormSelector(const String& label, const String& id, int optionCount, const __FlashStringHelper * options[], const int indices[], int selectedIndex); void addFormSelector(const __FlashStringHelper * label, const __FlashStringHelper * id, int optionCount, const String options[], const int indices[], int selectedIndex); diff --git a/src/src/WebServer/WebServer.cpp b/src/src/WebServer/WebServer.cpp index 5ebfe96a3..eca0b8574 100644 --- a/src/src/WebServer/WebServer.cpp +++ b/src/src/WebServer/WebServer.cpp @@ -565,12 +565,24 @@ void json_close(bool arr) { lastLevel = level; } +void json_number(const __FlashStringHelper * name, const String& value) +{ + json_prop(name, value); +} + + void json_number(const String& name, const String& value) { + json_prop(name, value); +} + +void json_prop(const __FlashStringHelper * name, const String& value) +{ json_quote_name(name); json_quote_val(value); lastLevel = level; } + void json_prop(const String& name, const String& value) { json_quote_name(name); json_quote_val(value); diff --git a/src/src/WebServer/WebServer.h b/src/src/WebServer/WebServer.h index 3800753be..b5f8f83e3 100644 --- a/src/src/WebServer/WebServer.h +++ b/src/src/WebServer/WebServer.h @@ -87,9 +87,15 @@ void json_close(); void json_close(bool arr); +void json_number(const __FlashStringHelper * name, + const String& value); + void json_number(const String& name, const String& value); +void json_prop(const __FlashStringHelper * name, + const String& value); + void json_prop(const String& name, const String& value);