diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61770de129..580eb5e132 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,7 @@ on: tags-ignore: '**' paths-ignore: - 'dist/Release_notes.txt' + - 'docs/**' pull_request: branches: [mega] diff --git a/docs/source/Plugin/P026.rst b/docs/source/Plugin/P026.rst index 01080d1a37..ec0e8b0117 100644 --- a/docs/source/Plugin/P026.rst +++ b/docs/source/Plugin/P026.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p02x.repl +.. include:: ../Plugin/_plugin_substitutions_p02x.repl .. _P026_page: |P026_typename| @@ -21,10 +21,48 @@ Maintainer: |P026_maintainer| Used libraries: |P026_usedlibraries| -Supported hardware ------------------- +.. Supported hardware +.. ------------------ -|P026_usedby| +.. .. |P026_usedby| + +Introduction +------------ + +To monitor some internal values of an ESPEasy equiped device, the SysInfo plugin is available. This device can show up to 4 values showing user-selected system data. + +Configuration +------------- + +.. image:: P026_DeviceConfiguration.png + +* **Name** A unique name should be entered here. + +* **Enabled** The device can be disabled or enabled. When not enabled the device should not use any resources. + +Output configuration +^^^^^^^^^^^^^^^^^^^^ + +* **Number Output Values**: Select from 1 to 4 output values, default is 4 (Quad). If more values are to be used, multiple tasks can be configured using this plugin. + +.. image:: P026_NumberOutputOptions.png + +* **Value 1..4**: Depending on the **Number Output Values** selection, 1 to 4 selections for output values are available. These can be chosen as desired. + +.. image:: P026_ValuesOptions.png + +* *Uptime*: The uptime of the unit in minutes. +* *Free RAM*: The amount of free memory in bytes. +* *Wifi RSSI*: The RSSI (Received signal strength indicator) value. This is a negative value. +* *Input VCC*: The voltage applied to the 3.3V VCC input of the ESP. This value is **only** available on ESP8266 builds with VCC enabled (included in the build name), else 0 will be shown. +* *System load*: The load as displayed on the Main and Info pages, a percentage in range 0 .. 100. +* *IP 1.Octet* .. *IP 4.Octet*: The separate parts of the active IP address of the unit, the octets are counted from left to right. +* *Web activity*: The time passed since the last web activity at the unit. Measured in seconds. +* *Free Stack*: The available stack space in bytes. +* *WiFi TX pwr*: The current setting for transmit power via WiFi. This is determined dynamically, depending on the corresponding settings in the Tools/Advanced page, RSSI and other factors. +* *Free 2nd Heap*: The available memory on the 2nd heap, **only** available in some specific ESP8266 builds, else it shows 0. +* *Internal temperature (ESP32)*: The internal temperature of the ESP. **Only** available on ESP32 units. For ESP32-S2/S3/C2/C3/C6 MCUs there is official support for the internal temperature sensor via the Espressif libraries, that has compensation applied so it shows a realistic value. For ESP32 Classic this is determined empirically, based on the deviation of the 150 kHz internal clock generator, that is rather temperature dependent, compared to the (stable) crystal frequency. This should not be seen as an absolute temperature, but *can* be used as a relative measurement f.e. when comparing heavy load vs. light load situations. +* *None*: No value. .. Commands available .. ^^^^^^^^^^^^^^^^^^ @@ -36,12 +74,28 @@ Supported hardware .. .. include:: P026_events.repl +Data Acquisition +^^^^^^^^^^^^^^^^ + +This group of settings, **Single event with all values** and **Send to Controller** settings are standard available configuration items. Send to Controller is only visible when one or more Controllers are configured. + +* **Interval** By default, Interval will be set to 60 sec. The data will be collected, and event(s) generated, using this interval. + +Get Config values +~~~~~~~~~~~~~~~~~ + +These values are not available in *Minimal OTA* builds. + +.. include:: P026_config_values.repl + Change log ---------- .. versionchanged:: 2.0 ... + |added| 2023-09-25 ESP32 Internal temperature sensor option, Get Config values + |added| Major overhaul for 2.0 release. diff --git a/docs/source/Plugin/P026_DeviceConfiguration.png b/docs/source/Plugin/P026_DeviceConfiguration.png new file mode 100644 index 0000000000..befceacc7d Binary files /dev/null and b/docs/source/Plugin/P026_DeviceConfiguration.png differ diff --git a/docs/source/Plugin/P026_NumberOutputOptions.png b/docs/source/Plugin/P026_NumberOutputOptions.png new file mode 100644 index 0000000000..2087f40e43 Binary files /dev/null and b/docs/source/Plugin/P026_NumberOutputOptions.png differ diff --git a/docs/source/Plugin/P026_ValuesOptions.png b/docs/source/Plugin/P026_ValuesOptions.png new file mode 100644 index 0000000000..09c6b91311 Binary files /dev/null and b/docs/source/Plugin/P026_ValuesOptions.png differ diff --git a/docs/source/Plugin/P026_config_values.repl b/docs/source/Plugin/P026_config_values.repl new file mode 100644 index 0000000000..a8ebdaa5e2 --- /dev/null +++ b/docs/source/Plugin/P026_config_values.repl @@ -0,0 +1,59 @@ +.. csv-table:: + :header: "Config value", "Information" + :widths: 20, 30 + + " + | ``[#uptime]`` + "," + | Returns the uptime of the unit in minutes. + " + " + | ``[#freeheap]`` + "," + | Returns the amount of free memory in bytes. + " + " + | ``[#rssi]`` + "," + | Returns the RSSI (Received signal strength indicator) value. This is a negative value. + " + " + | ``[#vcc]`` + "," + | Returns the voltage applied to the 3.3V VCC input of the ESP. This value is **only** available on ESP8266 builds with VCC enabled (included in the build name), else 0 will be shown. + " + " + | ``[#load]`` + "," + | Returns the load as displayed on the Main and Info pages, a percentage in range 0 .. 100. + " + " + | ``[#ip1]`` .. ``[#ip4]`` + "," + | Returns the separate parts of the active IPv4 address of the unit, the parts 1..4 are counted from left to right. + " + " + | ``[#web]`` + "," + | Returns the time passed since the last web activity at the unit. Measured in seconds. + " + " + | ``[#freestack]`` + "," + | Returns the available stack space in bytes. + " + " + | ``[#txpwr]`` + "," + | Returns the current setting for transmit power via WiFi. This is determined dynamically, depending on the corresponding settings in the Tools/Advanced page, RSSI and other factors. + " + " + | ``[#free2ndheap]`` + "," + | Returns the available memory on the 2nd heap, **only** available in some specific ESP8266 builds, else it shows 0. + " + " + | ``[#internaltemp]`` + "," + | Returns the internal temperature of the ESP. **Only** available on ESP32 units. For ESP32-S2/S3/C2/C3/C6 MCUs there is official support for the internal temperature sensor via the Espressif libraries, that has compensation applied so it shows a realistic value. For ESP32 Classic this is determined empirically, based on the deviation of the 150 kHz internal clock generator, that is rather temperature dependent, compared to the (stable) crystal frequency. This should not be seen as an absolute temperature, but *can* be used as a relative measurement f.e. when comparing heavy load vs. light load situations. + " diff --git a/docs/source/Plugin/P036.rst b/docs/source/Plugin/P036.rst index 2be3e553ca..cb22a3a213 100644 --- a/docs/source/Plugin/P036.rst +++ b/docs/source/Plugin/P036.rst @@ -66,17 +66,21 @@ Device Settings .. image:: P036_ScrollOptions.png * **Scroll**: Switching between pages can be "instant", "scrolling" or a "ticker" band. Please note that scrolling will need more resources of the ESP, which can have an effect on other active tasks of the node. + For the ``Ticker`` there are some restrictions: + * Depending on the build used (NORMAL and CUSTOM) this option is available * only one line is displaying the ticker string * all line contents are parsed and combined to this ticker string, the parsing happens only at each ticker start (using the setting ``Interval``) * the optional split token ``<|>`` is replaced by three spaces -* the gaps between the ticker items must be set by the ``line content`` (tailing spaces) +* the gaps between the ticker items must be set by the ``line content`` (trailing spaces) * the starting alignment (left, center, right) depends on the setting ``Align content (global)`` * the font is taken from the setting ``Modify font`` of the first line, the ``Alignment`` settings of the lines are ignored (always right aligned) -* the ticker speed depends on the length of the ticker string and the setting ``Interval`` setting +* the ticker speed depends on the length of the ticker string and the task ``Interval`` setting * the footer is automatically hidden +.. spacer + * **GPIO <- Display button**: Setting up a ``Display Button``, allows to configure a Display Timeout and wake the display on demand, either by a button, or by using some presence detection. .. image:: P036_PinModeOptions.png @@ -108,7 +112,7 @@ Content .. image:: P036_HeaderOptions.png -* **Header** / **Header (alternate)**: The plugin allows for a header line, which may show some user selectable information. When using a different setting for **Header (alternate)**, the header will be updated halfway of the Interval time. +* **Header** / **Header (alternate)**: The plugin allows for a header line, which may show some user selectable information. When using a different setting for **Header (alternate)**, the header will be updated halfway of the Interval time. The **User defined 1/2** options are not available in all builds. If they are available, their content can be set using the ``oledframedcmd,userDef1,''`` and ``oledframedcmd,userDef2,''`` commands (by default they are empty), see the command reference below for details. * **Scroll long lines**: When checked, lines that won't fit on the display will be scrolled to be completely shown. diff --git a/docs/source/Plugin/P036_HeaderOptions.png b/docs/source/Plugin/P036_HeaderOptions.png index 60704fa73c..a9e6a3f0f4 100644 Binary files a/docs/source/Plugin/P036_HeaderOptions.png and b/docs/source/Plugin/P036_HeaderOptions.png differ diff --git a/src/_P026_Sysinfo.ino b/src/_P026_Sysinfo.ino index 9139efece0..2a7b0eb679 100644 --- a/src/_P026_Sysinfo.ino +++ b/src/_P026_Sysinfo.ino @@ -5,44 +5,46 @@ // #################################### Plugin 026: System Info ########################################## // ####################################################################################################### - -# include "src/DataStructs/ESPEasy_packed_raw_data.h" -# include "src/ESPEasyCore/ESPEasyNetwork.h" -# include "src/Globals/ESPEasyWiFiEvent.h" -# include "src/Helpers/Memory.h" - -# include "ESPEasy-Globals.h" +/** Changelog: + * 2023-09-24 tonhuisman: Add support for getting all values via Get Config option [#] where is the default + * name as set for an output value. None is ignored. Not available in MINIMAL_OTA builds. + * Move all includes to P026_data_struct.h + * 2023-09-23 tonhuisman: Add Internal temperature option for ESP32 + * Format source using Uncrustify + * Move #if check to P026_data_struct.h as Arduino compiler doesn't support that :( + * Move other defines to P026_data_struct.h + * 2023-09-23 tonhuisman: Start changelog + */ # define PLUGIN_026 # define PLUGIN_ID_026 26 # define PLUGIN_NAME_026 "Generic - System Info" -// place sensor type selector right after the output value settings -# define P026_QUERY1_CONFIG_POS 0 -# define P026_SENSOR_TYPE_INDEX (P026_QUERY1_CONFIG_POS + VARS_PER_TASK) -# define P026_NR_OUTPUT_VALUES getValueCountFromSensorType(static_cast(PCONFIG(P026_SENSOR_TYPE_INDEX))) - -# define P026_NR_OUTPUT_OPTIONS 14 +# include "src/PluginStructs/P026_data_struct.h" // Arduino doesn't do #if in .ino sources :( const __FlashStringHelper* Plugin_026_valuename(uint8_t value_nr, bool displayString) { - const __FlashStringHelper* strings[] { - F("Uptime") , F("uptime"), - F("Free RAM") , F("freeheap"), - F("Wifi RSSI") , F("rssi"), - F("Input VCC") , F("vcc"), - F("System load") , F("load"), - F("IP 1.Octet") , F("ip1"), - F("IP 2.Octet") , F("ip2"), - F("IP 3.Octet") , F("ip3"), - F("IP 4.Octet") , F("ip4"), - F("Web activity") , F("web"), - F("Free Stack") , F("freestack"), - F("None") , F(""), - F("WiFi TX pwr") , F("txpwr"), - F("Free 2nd Heap"), F("free2ndheap") + const __FlashStringHelper *strings[] { + F("Uptime"), F("uptime"), + F("Free RAM"), F("freeheap"), + F("Wifi RSSI"), F("rssi"), + F("Input VCC"), F("vcc"), + F("System load"), F("load"), + F("IP 1.Octet"), F("ip1"), + F("IP 2.Octet"), F("ip2"), + F("IP 3.Octet"), F("ip3"), + F("IP 4.Octet"), F("ip4"), + F("Web activity"), F("web"), + F("Free Stack"), F("freestack"), + F("None"), F(""), + F("WiFi TX pwr"), F("txpwr"), + F("Free 2nd Heap"), F("free2ndheap"), + # if FEATURE_INTERNAL_TEMPERATURE + F("Internal temperature (ESP32)"), F("internaltemp"), + # endif // if FEATURE_INTERNAL_TEMPERATURE }; - const size_t index = (2* value_nr) + (displayString ? 0 : 1); + const size_t index = (2 * value_nr) + (displayString ? 0 : 1); constexpr size_t nrStrings = NR_ELEMENTS(strings); + if (index < nrStrings) { return strings[index]; } @@ -77,6 +79,7 @@ boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string) case PLUGIN_GET_DEVICEVALUENAMES: { const int valueCount = P026_NR_OUTPUT_VALUES; + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < valueCount) { const uint8_t pconfigIndex = i + P026_QUERY1_CONFIG_POS; @@ -134,8 +137,9 @@ boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string) // Work around to get the "none" at the end. options[index] = Plugin_026_valuename(11, true); indices[index] = 11; - + const int valueCount = P026_NR_OUTPUT_VALUES; + for (uint8_t i = 0; i < valueCount; ++i) { const uint8_t pconfigIndex = i + P026_QUERY1_CONFIG_POS; sensorTypeHelper_loadOutputSelector(event, pconfigIndex, i, P026_NR_OUTPUT_OPTIONS, options, indices); @@ -153,6 +157,7 @@ boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string) { // Save output selector parameters. const int valueCount = P026_NR_OUTPUT_VALUES; + for (uint8_t i = 0; i < valueCount; ++i) { const uint8_t pconfigIndex = i + P026_QUERY1_CONFIG_POS; const uint8_t choice = PCONFIG(pconfigIndex); @@ -171,10 +176,12 @@ boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string) case PLUGIN_READ: { const int valueCount = P026_NR_OUTPUT_VALUES; + for (int i = 0; i < valueCount; ++i) { UserVar[event->BaseVarIndex + i] = P026_get_value(PCONFIG(i)); } - #ifndef LIMIT_BUILD_SIZE + # ifndef LIMIT_BUILD_SIZE + if (loglevelActiveFor(LOG_LEVEL_INFO)) { String log; @@ -191,10 +198,25 @@ boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string) addLogMove(LOG_LEVEL_INFO, log); } } - #endif + # endif // ifndef LIMIT_BUILD_SIZE success = true; break; } + # ifndef PLUGIN_BUILD_MINIMAL_OTA + case PLUGIN_GET_CONFIG_VALUE: + { + const String cmd = parseString(string, 1); + + for (uint8_t option = 0; option < P026_NR_OUTPUT_OPTIONS; ++option) { + if ((option != 11) && equals(cmd, Plugin_026_valuename(option, false))) { // Use default valuename + string = floatToString(P026_get_value(option), 2, true); // Trim trailing zeroes + success = true; + break; + } + } + break; + } + # endif // ifndef PLUGIN_BUILD_MINIMAL_OTA # if FEATURE_PACKED_RAW_DATA case PLUGIN_GET_PACKED_RAW_DATA: { @@ -202,19 +224,23 @@ boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string) // return decode(bytes, // [header, uint24, uint24, int8, vcc, pct_8, uint8, uint8, uint8, uint8, uint24, uint16], // ['header', 'uptime', 'freeheap', 'rssi', 'vcc', 'load', 'ip1', 'ip2', 'ip3', 'ip4', 'web', 'freestack']); + // on ESP32 you can add 'internaltemperature' of type int16 (1e2) to the list (disabled for now, so not available) uint8_t index = 0; - string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // uptime - string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // freeheap - string += LoRa_addFloat(P026_get_value(index++), PackedData_int8); // rssi - string += LoRa_addFloat(P026_get_value(index++), PackedData_vcc); // vcc - string += LoRa_addFloat(P026_get_value(index++), PackedData_pct_8); // load - string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip1 - string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip2 - string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip3 - string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip4 - string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // web - string += LoRa_addInt(P026_get_value(index++), PackedData_uint16); // freestack - event->Par1 = index; // valuecount + string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // uptime + string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // freeheap + string += LoRa_addFloat(P026_get_value(index++), PackedData_int8); // rssi + string += LoRa_addFloat(P026_get_value(index++), PackedData_vcc); // vcc + string += LoRa_addFloat(P026_get_value(index++), PackedData_pct_8); // load + string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip1 + string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip2 + string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip3 + string += LoRa_addInt(P026_get_value(index++), PackedData_uint8); // ip4 + string += LoRa_addInt(P026_get_value(index++), PackedData_uint24); // web + string += LoRa_addInt(P026_get_value(index++), PackedData_uint16); // freestack + // # if FEATURE_INTERNAL_TEMPERATURE + // string += LoRa_addInt(P026_get_value(index++) * 100.0f, PackedData_int16_1e2); // internal temperature in 0.01 degrees + // # endif // if FEATURE_INTERNAL_TEMPERATURE + event->Par1 = index; // valuecount success = true; break; } @@ -226,6 +252,7 @@ boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string) float P026_get_value(uint8_t type) { float res{}; + switch (type) { case 0: res = getUptimeMinutes(); break; @@ -243,7 +270,7 @@ float P026_get_value(uint8_t type) case 6: case 7: case 8: - res = NetworkLocalIP()[type - 5]; break; + res = NetworkLocalIP()[type - 5]; break; case 9: res = timePassedSince(lastWeb) / 1000.0f; break; // respond in seconds case 10: res = getCurrentFreeStack(); break; case 12: res = WiFiEventData.wifi_TX_pwr; break; @@ -252,6 +279,11 @@ float P026_get_value(uint8_t type) res = FreeMem2ndHeap(); # endif // ifdef USE_SECOND_HEAP break; + case 14: + # if FEATURE_INTERNAL_TEMPERATURE + res = getInternalTemperature(); + # endif // if FEATURE_INTERNAL_TEMPERATURE + break; } return res; } diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index b5d110ab30..98897d01d9 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -2975,6 +2975,18 @@ To create/register a plugin, you have to : #define FEATURE_PLUGIN_PRIORITY 0 // Disable by default #endif +#ifndef FEATURE_INTERNAL_TEMPERATURE + #if defined(ESP32) // Feature is only available on (most?) ESP32 chips + #define FEATURE_INTERNAL_TEMPERATURE 1 + #else + #define FEATURE_INTERNAL_TEMPERATURE 0 // Not evailable on ESP8266 + #endif +#endif +#if defined(FEATURE_INTERNAL_TEMPERATURE) && defined(ESP8266) + #undef FEATURE_INTERNAL_TEMPERATURE + #define FEATURE_INTERNAL_TEMPERATURE 0 // Not evailable on ESP8266 +#endif + #ifndef FEATURE_I2C_DEVICE_CHECK #ifdef ESP8266_1M #define FEATURE_I2C_DEVICE_CHECK 0 // Disabled by default for 1M units diff --git a/src/src/Helpers/Hardware.cpp b/src/src/Helpers/Hardware.cpp index 2ad3039b2e..7321c9c062 100644 --- a/src/src/Helpers/Hardware.cpp +++ b/src/src/Helpers/Hardware.cpp @@ -604,6 +604,55 @@ int espeasy_analogRead(int pin, bool readAsTouch) { #endif // ifdef ESP32 +#if FEATURE_INTERNAL_TEMPERATURE + +/** + * Code based on: https://github.com/esphome/esphome/blob/518ecb4cc4489c8a76b899bfda7576b05d84c226/esphome/components/internal_temperature/internal_temperature.cpp#L40 + */ + +#ifdef ESP32 +#if defined(ESP32_CLASSIC) +// there is no official API available on the original ESP32 +extern "C" { +uint8_t temprature_sens_read(); +} +#elif defined(ESP32C3) || defined(ESP32S2) || defined(ESP32S3) +#include "driver/temp_sensor.h" +#endif // ESP32_CLASSIC +#endif // ESP32 + +float getInternalTemperature() { + static float temperature = -273.15f; // Improbable value + int8_t retries = 2; + #ifdef ESP32 + #if defined(ESP32_CLASSIC) + uint8_t raw = 128u; + while ((128u == raw) && (0 != retries)) { + delay(0); + raw = temprature_sens_read(); // Each reading takes about 112 microseconds + --retries; + } + #ifndef BUILD_NO_DEBUG + addLog(LOG_LEVEL_DEBUG, concat(F("ESP32: Raw temperature value: "), raw)); + #endif + if (raw != 128) { + temperature = (raw - 32) / 1.8f; + } + #elif defined(ESP32C3) || defined(ESP32S2) || defined(ESP32S3) + temp_sensor_config_t tsens = TSENS_CONFIG_DEFAULT(); + temp_sensor_set_config(tsens); + float tmpTemp = 0.0f; + temp_sensor_start(); + esp_err_t result = temp_sensor_read_celsius(&tmpTemp); + temp_sensor_stop(); + if (result == ESP_OK) { + temperature = tmpTemp; + } + #endif // ESP32_CLASSIC + #endif // USE_ESP32 + return temperature; +} +#endif // if FEATURE_INTERNAL_TEMPERATURE /********************************************************************************************\ Hardware information diff --git a/src/src/Helpers/Hardware.h b/src/src/Helpers/Hardware.h index d443780e22..c0704bae1d 100644 --- a/src/src/Helpers/Hardware.h +++ b/src/src/Helpers/Hardware.h @@ -70,6 +70,10 @@ int espeasy_analogRead(int pin, extern esp_adc_cal_characteristics_t adc_chars[ADC_ATTEN_MAX]; #endif // ifdef ESP32 +#if FEATURE_INTERNAL_TEMPERATURE +float getInternalTemperature(); +#endif // if FEATURE_INTERNAL_TEMPERATURE + /********************************************************************************************\ Hardware information diff --git a/src/src/Helpers/PeriodicalActions.cpp b/src/src/Helpers/PeriodicalActions.cpp index 391bbdbec9..c6ad41ec0a 100644 --- a/src/src/Helpers/PeriodicalActions.cpp +++ b/src/src/Helpers/PeriodicalActions.cpp @@ -185,6 +185,9 @@ void runOncePerSecond() #endif #endif // if FEATURE_MDNS + #if FEATURE_INTERNAL_TEMPERATURE && defined(ESP32_CLASSIC) + getInternalTemperature(); // Just read the value every second to hopefully get a valid next reading on original ESP32 + #endif // if FEATURE_INTERNAL_TEMPERATURE && defined(ESP32_CLASSIC) checkResetFactoryPin(); STOP_TIMER(PLUGIN_CALL_1PS); diff --git a/src/src/Helpers/StringProvider.cpp b/src/src/Helpers/StringProvider.cpp index b63bfbe38f..7b974c457a 100644 --- a/src/src/Helpers/StringProvider.cpp +++ b/src/src/Helpers/StringProvider.cpp @@ -237,6 +237,9 @@ const __FlashStringHelper * getLabel(LabelType::Enum label) { case LabelType::MAX_OTA_SKETCH_SIZE: return F("Max. OTA Sketch Size"); case LabelType::OTA_2STEP: return F("OTA 2-step Needed"); case LabelType::OTA_POSSIBLE: return F("OTA possible"); + #if FEATURE_INTERNAL_TEMPERATURE + case LabelType::INTERNAL_TEMPERATURE: return F("Internal temperature (ESP32)"); + #endif // if FEATURE_INTERNAL_TEMPERATURE #if FEATURE_ETHERNET case LabelType::ETH_IP_ADDRESS: return F("Eth IP Address"); case LabelType::ETH_IP_SUBNET: return F("Eth IP Subnet"); @@ -413,6 +416,9 @@ String getValue(LabelType::Enum label) { case LabelType::IP_ADDRESS_SUBNET: return getValue(LabelType::IP_ADDRESS) + F(" / ") + getValue(LabelType::IP_SUBNET); case LabelType::GATEWAY: return formatIP(NetworkGatewayIP()); case LabelType::CLIENT_IP: return formatIP(web_server.client().remoteIP()); + #if FEATURE_INTERNAL_TEMPERATURE + case LabelType::INTERNAL_TEMPERATURE: return toString(getInternalTemperature()); + #endif // if FEATURE_INTERNAL_TEMPERATURE #if FEATURE_MDNS case LabelType::M_DNS: return NetworkGetHostname() + F(".local"); diff --git a/src/src/Helpers/StringProvider.h b/src/src/Helpers/StringProvider.h index 8e9e2d7333..9ac08a48b8 100644 --- a/src/src/Helpers/StringProvider.h +++ b/src/src/Helpers/StringProvider.h @@ -183,6 +183,9 @@ struct LabelType { MAX_OTA_SKETCH_SIZE, OTA_2STEP, OTA_POSSIBLE, + #if FEATURE_INTERNAL_TEMPERATURE + INTERNAL_TEMPERATURE, + #endif // if FEATURE_INTERNAL_TEMPERATURE #if FEATURE_ETHERNET ETH_IP_ADDRESS, ETH_IP_SUBNET, diff --git a/src/src/Helpers/SystemVariables.cpp b/src/src/Helpers/SystemVariables.cpp index 79fcaf59c8..c5590e0d12 100644 --- a/src/src/Helpers/SystemVariables.cpp +++ b/src/src/Helpers/SystemVariables.cpp @@ -89,6 +89,9 @@ LabelType::Enum SystemVariables2LabelType(SystemVariables::Enum enumval) { case SystemVariables::DNS_2: label = LabelType::DNS_2; break; case SystemVariables::GATEWAY: label = LabelType::GATEWAY; break; case SystemVariables::CLIENTIP: label = LabelType::CLIENT_IP; break; + #if FEATURE_INTERNAL_TEMPERATURE + case SystemVariables::INTERNAL_TEMPERATURE: label = LabelType::INTERNAL_TEMPERATURE; break; + #endif // if FEATURE_INTERNAL_TEMPERATURE #if FEATURE_ETHERNET @@ -359,6 +362,9 @@ const __FlashStringHelper * SystemVariables::toFlashString(SystemVariables::Enum case Enum::ISMQTTIMP: return F("ismqttimp"); case Enum::ISNTP: return F("isntp"); case Enum::ISWIFI: return F("iswifi"); + #if FEATURE_INTERNAL_TEMPERATURE + case Enum::INTERNAL_TEMPERATURE: return F("inttemp"); + #endif // if FEATURE_INTERNAL_TEMPERATURE #if FEATURE_ETHERNET case Enum::ETHWIFIMODE: return F("ethwifimode"); case Enum::ETHCONNECTED: return F("ethconnected"); diff --git a/src/src/Helpers/SystemVariables.h b/src/src/Helpers/SystemVariables.h index d1965a78ab..e4cb077f57 100644 --- a/src/src/Helpers/SystemVariables.h +++ b/src/src/Helpers/SystemVariables.h @@ -4,7 +4,6 @@ #include "../../ESPEasy_common.h" class SystemVariables { - public: enum Enum : uint8_t { @@ -13,13 +12,16 @@ class SystemVariables { BSSID, CR, IP, - IP4, // 4th IP octet + IP4, // 4th IP octet SUBNET, GATEWAY, DNS, DNS_1, DNS_2, CLIENTIP, + #if FEATURE_INTERNAL_TEMPERATURE + INTERNAL_TEMPERATURE, + #endif // if FEATURE_INTERNAL_TEMPERATURE ISMQTT, ISMQTTIMP, ISNTP, @@ -85,7 +87,7 @@ class SystemVariables { SYS_MONTH_0, S_CR, S_LF, - UNIT_sysvar, // We already use UNIT as define. + UNIT_sysvar, // We already use UNIT as define. #if FEATURE_ZEROFILLED_UNITNUMBER UNIT_0_sysvar, #endif // FEATURE_ZEROFILLED_UNITNUMBER @@ -96,12 +98,12 @@ class SystemVariables { UPTIME_MS, VCC, WI_CH, - FLASH_FREQ, // Frequency of the flash chip - FLASH_SIZE, // Real size of the flash chip + FLASH_FREQ, // Frequency of the flash chip + FLASH_SIZE, // Real size of the flash chip FLASH_CHIP_VENDOR, FLASH_CHIP_MODEL, - FS_SIZE, // Size of the file system - FS_FREE, // Free space (in bytes) on the file system + FS_SIZE, // Size of the file system + FS_FREE, // Free space (in bytes) on the file system ESP_CHIP_ID, ESP_CHIP_FREQ, @@ -117,18 +119,17 @@ class SystemVariables { // Find the next thing to replace. // Return UNKNOWN when nothing needs to be replaced. - static SystemVariables::Enum nextReplacementEnum(const String& str, SystemVariables::Enum last_tested); - - static String toString(SystemVariables::Enum enumval); - static const __FlashStringHelper * toFlashString(SystemVariables::Enum enumval); + static SystemVariables::Enum nextReplacementEnum(const String & str, + SystemVariables::Enum last_tested); - static String getSystemVariable(SystemVariables::Enum enumval); + static String toString(SystemVariables::Enum enumval); + static const __FlashStringHelper* toFlashString(SystemVariables::Enum enumval); - static void parseSystemVariables(String& s, boolean useURLencode); + static String getSystemVariable(SystemVariables::Enum enumval); + static void parseSystemVariables(String& s, + boolean useURLencode); }; - - #endif // HELPERS_SYSTEMVARIABLES_H diff --git a/src/src/PluginStructs/P026_data_struct.h b/src/src/PluginStructs/P026_data_struct.h new file mode 100644 index 0000000000..17b091b7e2 --- /dev/null +++ b/src/src/PluginStructs/P026_data_struct.h @@ -0,0 +1,26 @@ +#ifndef PLUGINSTRUCTS_P026_DATA_STRUCT_H +#define PLUGINSTRUCTS_P026_DATA_STRUCT_H + +#include "../../_Plugin_Helper.h" +#ifdef USES_P026 + +# include "src/DataStructs/ESPEasy_packed_raw_data.h" +# include "src/ESPEasyCore/ESPEasyNetwork.h" +# include "src/Globals/ESPEasyWiFiEvent.h" +# include "src/Helpers/Memory.h" + +# include "ESPEasy-Globals.h" + +// place sensor type selector right after the output value settings +# define P026_QUERY1_CONFIG_POS 0 +# define P026_SENSOR_TYPE_INDEX (P026_QUERY1_CONFIG_POS + VARS_PER_TASK) +# define P026_NR_OUTPUT_VALUES getValueCountFromSensorType(static_cast(PCONFIG(P026_SENSOR_TYPE_INDEX))) + +# if FEATURE_INTERNAL_TEMPERATURE +# define P026_NR_OUTPUT_OPTIONS 15 +# else // if FEATURE_INTERNAL_TEMPERATURE +# define P026_NR_OUTPUT_OPTIONS 14 +# endif // if FEATURE_INTERNAL_TEMPERATURE + +#endif // ifdef USES_P026 +#endif // ifndef PLUGINSTRUCTS_P026_DATA_STRUCT_H diff --git a/src/src/WebServer/SysVarPage.cpp b/src/src/WebServer/SysVarPage.cpp index 1a356b417b..370eb24c74 100644 --- a/src/src/WebServer/SysVarPage.cpp +++ b/src/src/WebServer/SysVarPage.cpp @@ -91,6 +91,9 @@ void handle_sysvars() { #if FEATURE_ADC_VCC addSysVar_enum_html(SystemVariables::VCC); #endif // if FEATURE_ADC_VCC + #if FEATURE_INTERNAL_TEMPERATURE + addSysVar_enum_html(SystemVariables::INTERNAL_TEMPERATURE); + #endif // if FEATURE_INTERNAL_TEMPERATURE addTableSeparator(F("Services Status"), 3, 3); diff --git a/tools/pio/generate-compiletime-defines.py b/tools/pio/generate-compiletime-defines.py index 9a5a710d29..367430683f 100644 --- a/tools/pio/generate-compiletime-defines.py +++ b/tools/pio/generate-compiletime-defines.py @@ -72,7 +72,9 @@ def get_git_description(): from pygit2 import Repository try: repo = Repository('.') - return "{0}_{1}".format(repo.head.shorthand, repo.revparse_single('HEAD').short_id) + return "{0}_{1}".format(repo.head.name + .replace("refs/heads/","",1) + .replace("refs/tags/","",1), repo.revparse_single('HEAD').short_id) except: return 'No_.git_dir' except ImportError: