mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into feature/p104-new-plugin-max7219-dotmatrix
This commit is contained in:
Vendored
+21
-5
@@ -16,8 +16,8 @@ The filename is quite descriptive:
|
||||
|
||||
Build type can be: (differ in included plugins)
|
||||
- normal => Only Stable plugins and controllers
|
||||
- test => Stable + Testing
|
||||
- dev => Stable + Testing + Development
|
||||
- test => Stable + Testing, divided in various build sets to fit max. build size.
|
||||
- max => Only for ESP32 boards with large flash size, includes all plugins.
|
||||
|
||||
There is also a number of special builds:
|
||||
- normal_IR => "Normal" + IR receiver/transmitter plugins and library
|
||||
@@ -29,13 +29,13 @@ There is also a number of special builds:
|
||||
Chip can be:
|
||||
- ESP8266 => Most likely option
|
||||
- ESP8285 => Used in some Sonoff modules
|
||||
- ESP32 => Experimental support at this moment
|
||||
- ESP32 => Showing up in commercial products, but mainly seen on NodeMCU like boards.
|
||||
|
||||
MemorySize can be:
|
||||
- 1M => 1 MB flash modules (e.g. almost all Sonoff modules)
|
||||
- 2M => 2 MB flash modules (e.g. Shelly1/WROOM02)
|
||||
- 4M => 4 MB flash modules (e.g. NodeMCU/ESP32)
|
||||
- 16M => 16 MB flash modules (e.g. Wemos D1 mini pro)
|
||||
- 16M => 16 MB flash modules (e.g. Wemos D1 mini pro or some of the modern ESP32 boards)
|
||||
|
||||
Please note that the performance of 14MB SPIFFS (16M flash modules) is really slow.
|
||||
All file access takes a lot longer and since the settings are also read from flash, the entire node will perform slower.
|
||||
@@ -43,6 +43,11 @@ See [Arduino issue - SPIFFS file access slow on 16/14M flash config](https://git
|
||||
|
||||
If these speed issues will be fixed, it is very likely the SPIFFS must then be re-partitioned, thus loosing all data in the SPIFFS.
|
||||
|
||||
As alternative for SPIFFS, one can chose for LittleFS.
|
||||
This currently is very fast when using it, but extremely slow when storing settings as updating a part of a file is not suitable for LittleFS.
|
||||
However this will be dealt with in the future.
|
||||
N.B. SPIFFS and LittleFS are not compatible. Switching from one to the other will delete all existing settings and configuration stored on the file system.
|
||||
|
||||
Special memory partitioning:
|
||||
- 2M256 => 2 MB flash modules (e.g. Shelly1/WROOM02) with 256k SPIFFS (only core 2.5.0 or newer)
|
||||
- 4M316k => For ESP32 with 4MB flash, sketch size is set to 1.8 MByte (default: 1.4 MByte)
|
||||
@@ -55,10 +60,15 @@ Please note that this only can be used on installs already running a very recent
|
||||
This also means we still need to update the 2-step updater to support .bin.gz files.
|
||||
|
||||
|
||||
ESP32 now has 3 builds:
|
||||
ESP32 now has a number of builds:
|
||||
- custom_ESP32_4M316k Build template using either the plugin set defined in ``Custom.h`` or ``tools/pio/pre_custom_esp32.py``
|
||||
- test_ESP32_4M316k Build using the "testing" set of plugins for ESP32
|
||||
- test_ESP32-wrover-kit_4M316k A build for ESP32 including build flags for the official WRover test kit.
|
||||
- max_ESP32_16M1M A build for ESP32 with larger flash size including all plugins.
|
||||
|
||||
ESP32 also supports Ethernet.
|
||||
Ethernet support is included in similar builds as mentioned before, only ending with "_ETH" in the file name.
|
||||
|
||||
|
||||
|
||||
Since ESP32 does have its flash partitioned in several blocks, we have 2 bin files of each ESP32 build:
|
||||
@@ -84,6 +94,12 @@ To help recover from a bad flash, there are also blank images included.
|
||||
When the wrong image is flashed, or the module behaves unstable, or is in a reboot loop,
|
||||
flash these images first and then the right image for the module.
|
||||
|
||||
Sometimes an update performed via OTA (Over The Air) is not performing as stable as one might expect.
|
||||
It is yet unclear why this happens or what may cause it.
|
||||
The remedy is often to flash the same build another time via serial.
|
||||
There does seem to be some correlation to bad OTA flashes and flash chips made by XMC, but it is not exclusive to this brand of flash chips.
|
||||
|
||||
|
||||
ESP.Easy.Flasher.exe...
|
||||
... is the new flashing tool for ESP Easy. You need to run it in elevated mode (as admin)
|
||||
for it to fetch the COM ports correctly. If you want you may save YOUR settings using the
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
.. |P051_type| replace:: :cyan:`Environment`
|
||||
.. |P051_typename| replace:: :cyan:`Environment - AM2320`
|
||||
.. |P051_porttype| replace:: `.`
|
||||
.. |P051_status| replace:: :green:`NORMAL`
|
||||
.. |P051_status| replace:: :yellow:`TESTING`
|
||||
.. |P051_github| replace:: P051_AM2320.ino
|
||||
.. _P051_github: https://github.com/letscontrolit/ESPEasy/blob/mega/src/_P051_AM2320.ino
|
||||
.. |P051_usedby| replace:: `.`
|
||||
|
||||
@@ -37,6 +37,7 @@ build_flags = -D NDEBUG
|
||||
-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
||||
-DVTABLES_IN_FLASH
|
||||
-DPUYA_SUPPORT=1
|
||||
-fno-strict-aliasing
|
||||
lib_ignore = ESP32_ping, ESP32WebServer, ESP32HTTPUpdateServer, ServoESP32, IRremoteESP8266, HeatpumpIR, TinyWireM
|
||||
|
||||
[esp82xx_2_5_x]
|
||||
@@ -48,6 +49,7 @@ build_flags = -DNDEBUG
|
||||
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
|
||||
-DPUYA_SUPPORT=1
|
||||
-DCORE_POST_2_5_0
|
||||
-fno-strict-aliasing
|
||||
lib_ignore = ${esp82xx_defaults.lib_ignore}
|
||||
|
||||
[esp82xx_2_6_x]
|
||||
@@ -134,7 +136,7 @@ build_flags = ${esp82xx_2_6_x.build_flags}
|
||||
-Wno-deprecated-declarations
|
||||
platform_packages =
|
||||
platformio/framework-arduinoespressif8266 @ https://github.com/esp8266/Arduino.git
|
||||
mcspr/toolchain-xtensa @ 5.100200.201223
|
||||
platformio/toolchain-xtensa @ ~2.100300.210717
|
||||
|
||||
; Updated ESP-IDF to the latest stable 4.0.1
|
||||
; See: https://github.com/platformio/platform-espressif32/releases
|
||||
|
||||
@@ -24,6 +24,7 @@ build_flags = ${core_esp32_stage.build_flags}
|
||||
-DCONFIG_FREERTOS_ASSERT_DISABLE
|
||||
-DCONFIG_LWIP_ESP_GRATUITOUS_ARP
|
||||
-DCONFIG_LWIP_GARP_TMR_INTERVAL=30
|
||||
-fno-strict-aliasing
|
||||
monitor_filters = esp32_exception_decoder
|
||||
|
||||
|
||||
|
||||
@@ -140,6 +140,17 @@ lib_ignore = ${esp8266_custom_common.lib_ignore}
|
||||
extra_scripts = ${esp8266_custom_common.extra_scripts}
|
||||
|
||||
|
||||
; Custom: 2M version --------------------------
|
||||
[env:custom_ESP8266_2M256]
|
||||
extends = espWroom2M256
|
||||
platform = ${regular_platform.platform}
|
||||
platform_packages = ${regular_platform.platform_packages}
|
||||
build_flags = ${regular_platform.build_flags}
|
||||
${espWroom2M256.build_flags}
|
||||
-DPLUGIN_BUILD_CUSTOM
|
||||
lib_ignore = ${esp8266_custom_common.lib_ignore}
|
||||
extra_scripts = ${esp8266_custom_common.extra_scripts}
|
||||
|
||||
|
||||
|
||||
;;; NORMAL (STABLE) ***************************************************
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ bool CPlugin_002(CPlugin::Function function, struct EventStruct *event, String&
|
||||
mustSendEvent = true;
|
||||
int pwmValue = UserVar[baseVar];
|
||||
|
||||
switch ((int)nvalue)
|
||||
switch (static_cast<int>(nvalue))
|
||||
{
|
||||
case 0: // Off
|
||||
pwmValue = 0;
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ bool do_process_c010_delay_queue(int controller_number, const C010_queue_element
|
||||
}
|
||||
|
||||
C010_portUDP.write(
|
||||
(uint8_t *)element.txt[element.valuesSent].c_str(),
|
||||
reinterpret_cast<const uint8_t *>(element.txt[element.valuesSent].c_str()),
|
||||
element.txt[element.valuesSent].length());
|
||||
bool reply = C010_portUDP.endPacket();
|
||||
|
||||
|
||||
+2
-2
@@ -152,7 +152,7 @@ bool CPlugin_011(CPlugin::Function function, struct EventStruct *event, String&
|
||||
strlcpy(customConfig->HttpHeader, httpheader.c_str(), sizeof(customConfig->HttpHeader));
|
||||
strlcpy(customConfig->HttpBody, httpbody.c_str(), sizeof(customConfig->HttpBody));
|
||||
customConfig->zero_last();
|
||||
SaveCustomControllerSettings(event->ControllerIndex, (uint8_t *)customConfig.get(), sizeof(C011_ConfigStruct));
|
||||
SaveCustomControllerSettings(event->ControllerIndex, reinterpret_cast<const uint8_t *>(customConfig.get()), sizeof(C011_ConfigStruct));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ bool load_C011_ConfigStruct(controllerIndex_t ControllerIndex, String& HttpMetho
|
||||
if (!customConfig) {
|
||||
return false;
|
||||
}
|
||||
LoadCustomControllerSettings(ControllerIndex, (uint8_t *)customConfig.get(), sizeof(C011_ConfigStruct));
|
||||
LoadCustomControllerSettings(ControllerIndex, reinterpret_cast<uint8_t *>(customConfig.get()), sizeof(C011_ConfigStruct));
|
||||
customConfig->zero_last();
|
||||
HttpMethod = customConfig->HttpMethod;
|
||||
HttpUri = customConfig->HttpUri;
|
||||
|
||||
+10
-9
@@ -110,13 +110,13 @@ void C013_SendUDPTaskInfo(uint8_t destUnit, uint8_t sourceTaskIndex, uint8_t des
|
||||
if (destUnit != 0)
|
||||
{
|
||||
infoReply.destUnit = destUnit;
|
||||
C013_sendUDP(destUnit, (uint8_t *)&infoReply, sizeof(C013_SensorInfoStruct));
|
||||
C013_sendUDP(destUnit, reinterpret_cast<const uint8_t *>(&infoReply), sizeof(C013_SensorInfoStruct));
|
||||
delay(10);
|
||||
} else {
|
||||
for (NodesMap::iterator it = Nodes.begin(); it != Nodes.end(); ++it) {
|
||||
if (it->first != Settings.Unit) {
|
||||
infoReply.destUnit = it->first;
|
||||
C013_sendUDP(it->first, (uint8_t *)&infoReply, sizeof(C013_SensorInfoStruct));
|
||||
C013_sendUDP(it->first, reinterpret_cast<const uint8_t *>(&infoReply), sizeof(C013_SensorInfoStruct));
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
@@ -146,13 +146,13 @@ void C013_SendUDPTaskData(uint8_t destUnit, uint8_t sourceTaskIndex, uint8_t des
|
||||
if (destUnit != 0)
|
||||
{
|
||||
dataReply.destUnit = destUnit;
|
||||
C013_sendUDP(destUnit, (uint8_t *)&dataReply, sizeof(C013_SensorDataStruct));
|
||||
C013_sendUDP(destUnit, reinterpret_cast<const uint8_t *>(&dataReply), sizeof(C013_SensorDataStruct));
|
||||
delay(10);
|
||||
} else {
|
||||
for (NodesMap::iterator it = Nodes.begin(); it != Nodes.end(); ++it) {
|
||||
if (it->first != Settings.Unit) {
|
||||
dataReply.destUnit = it->first;
|
||||
C013_sendUDP(it->first, (uint8_t *)&dataReply, sizeof(C013_SensorDataStruct));
|
||||
C013_sendUDP(it->first, reinterpret_cast<const uint8_t *>(&dataReply), sizeof(C013_SensorDataStruct));
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ void C013_SendUDPTaskData(uint8_t destUnit, uint8_t sourceTaskIndex, uint8_t des
|
||||
/*********************************************************************************************\
|
||||
Send UDP message (unit 255=broadcast)
|
||||
\*********************************************************************************************/
|
||||
void C013_sendUDP(uint8_t unit, uint8_t *data, uint8_t size)
|
||||
void C013_sendUDP(uint8_t unit, const uint8_t *data, uint8_t size)
|
||||
{
|
||||
if (!NetworkConnected(10)) {
|
||||
return;
|
||||
@@ -217,14 +217,15 @@ void C013_Receive(struct EventStruct *event) {
|
||||
# ifndef BUILD_NO_DEBUG
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG_MORE)) {
|
||||
if ((event->Data[1] > 1) && (event->Data[1] < 6))
|
||||
if ((event->Data != nullptr) &&
|
||||
(event->Data[1] > 1) && (event->Data[1] < 6))
|
||||
{
|
||||
String log = (F("C013 : msg "));
|
||||
|
||||
for (uint8_t x = 1; x < 6; x++)
|
||||
{
|
||||
log += ' ';
|
||||
log += (int)event->Data[x];
|
||||
log += static_cast<int>(event->Data[x]);
|
||||
}
|
||||
addLog(LOG_LEVEL_DEBUG_MORE, log);
|
||||
}
|
||||
@@ -245,7 +246,7 @@ void C013_Receive(struct EventStruct *event) {
|
||||
|
||||
if (event->Par2 < count) { count = event->Par2; }
|
||||
|
||||
memcpy((uint8_t *)&infoReply, (uint8_t *)event->Data, count);
|
||||
memcpy(reinterpret_cast<uint8_t *>(&infoReply), event->Data, count);
|
||||
|
||||
if (infoReply.isValid()) {
|
||||
// to prevent flash wear out (bugs in communication?) we can only write to an empty task
|
||||
@@ -286,7 +287,7 @@ void C013_Receive(struct EventStruct *event) {
|
||||
int count = sizeof(C013_SensorDataStruct);
|
||||
|
||||
if (event->Par2 < count) { count = event->Par2; }
|
||||
memcpy((uint8_t *)&dataReply, (uint8_t *)event->Data, count);
|
||||
memcpy(reinterpret_cast<uint8_t *>(&dataReply), event->Data, count);
|
||||
|
||||
if (dataReply.isValid()) {
|
||||
// only if this task has a remote feed, update values
|
||||
|
||||
+6
-6
@@ -106,8 +106,8 @@ bool CPlugin_015(CPlugin::Function function, struct EventStruct *event, String&
|
||||
# ifdef CPLUGIN_015_SSL
|
||||
case CPlugin::Function::CPLUGIN_WEBFORM_LOAD:
|
||||
{
|
||||
char thumbprint[60];
|
||||
LoadCustomControllerSettings(event->ControllerIndex, (uint8_t *)&thumbprint, sizeof(thumbprint));
|
||||
char thumbprint[60] = {0};
|
||||
LoadCustomControllerSettings(event->ControllerIndex, reinterpret_cast<const uint8_t *>(&thumbprint), sizeof(thumbprint));
|
||||
|
||||
if (strlen(thumbprint) != 59) {
|
||||
strcpy(thumbprint, CPLUGIN_015_DEFAULT_THUMBPRINT);
|
||||
@@ -142,13 +142,13 @@ bool CPlugin_015(CPlugin::Function function, struct EventStruct *event, String&
|
||||
_C015_LastConnectAttempt[event->ControllerIndex] = 0;
|
||||
|
||||
# ifdef CPLUGIN_015_SSL
|
||||
char thumbprint[60];
|
||||
char thumbprint[60] = {0};
|
||||
String error = F("Specify server thumbprint with exactly 59 symbols string like " CPLUGIN_015_DEFAULT_THUMBPRINT);
|
||||
|
||||
if (!safe_strncpy(thumbprint, webArg("c015_thumbprint"), 60) || (strlen(thumbprint) != 59)) {
|
||||
addHtmlError(error);
|
||||
}
|
||||
SaveCustomControllerSettings(event->ControllerIndex, (uint8_t *)&thumbprint, sizeof(thumbprint));
|
||||
SaveCustomControllerSettings(event->ControllerIndex, reinterpret_cast<const uint8_t *>(&thumbprint), sizeof(thumbprint));
|
||||
# endif // ifdef CPLUGIN_015_SSL
|
||||
}
|
||||
break;
|
||||
@@ -286,8 +286,8 @@ boolean Blynk_keep_connection_c015(int controllerIndex, ControllerSettingsStruct
|
||||
_C015_LastConnectAttempt[controllerIndex] = millis();
|
||||
|
||||
# ifdef CPLUGIN_015_SSL
|
||||
char thumbprint[60];
|
||||
LoadCustomControllerSettings(controllerIndex, (uint8_t *)&thumbprint, sizeof(thumbprint));
|
||||
char thumbprint[60] = {0};
|
||||
LoadCustomControllerSettings(controllerIndex, reinterpret_cast<uint8_t *>(&thumbprint), sizeof(thumbprint));
|
||||
|
||||
if (strlen(thumbprint) != 59) {
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ bool CPlugin_016(CPlugin::Function function, struct EventStruct *event, String&
|
||||
event,
|
||||
valueCount,
|
||||
C016_allowLocalSystemTime ? node_time.now() : node_time.getUnixTime());
|
||||
success = ControllerCache.write((uint8_t *)&element, sizeof(element));
|
||||
success = ControllerCache.write(reinterpret_cast<const uint8_t *>(&element), sizeof(element));
|
||||
|
||||
/*
|
||||
if (C016_DelayHandler == nullptr) {
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ bool do_process_c017_delay_queue(int controller_number, const C017_queue_element
|
||||
// addLog(LOG_LEVEL_INFO, String(F("ZBX: ")) + JSON_packet_content);
|
||||
// Send the packet
|
||||
client.write(packet_header, sizeof(packet_header) - 1);
|
||||
client.write((char *)&payload_len, sizeof(payload_len));
|
||||
client.write(reinterpret_cast<const char *>(&payload_len), sizeof(payload_len));
|
||||
client.write(JSON_packet_content.c_str(), payload_len);
|
||||
|
||||
client.stop();
|
||||
|
||||
+3
-3
@@ -574,7 +574,7 @@ bool CPlugin_018(CPlugin::Function function, struct EventStruct *event, String&
|
||||
if (!customConfig) {
|
||||
break;
|
||||
}
|
||||
LoadCustomControllerSettings(event->ControllerIndex, (uint8_t *)customConfig.get(), sizeof(C018_ConfigStruct));
|
||||
LoadCustomControllerSettings(event->ControllerIndex, reinterpret_cast<uint8_t *>(customConfig.get()), sizeof(C018_ConfigStruct));
|
||||
customConfig->validate();
|
||||
baudrate = customConfig->baudrate;
|
||||
rxpin = customConfig->rxpin;
|
||||
@@ -729,7 +729,7 @@ bool CPlugin_018(CPlugin::Function function, struct EventStruct *event, String&
|
||||
customConfig->stackVersion = getFormItemInt(F("ttnstack"), customConfig->stackVersion);
|
||||
customConfig->adr = isFormItemChecked(F("adr"));
|
||||
serialHelper_webformSave(customConfig->serialPort, customConfig->rxpin, customConfig->txpin);
|
||||
SaveCustomControllerSettings(event->ControllerIndex, (uint8_t *)customConfig.get(), sizeof(C018_ConfigStruct));
|
||||
SaveCustomControllerSettings(event->ControllerIndex, reinterpret_cast<const uint8_t *>(customConfig.get()), sizeof(C018_ConfigStruct));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -854,7 +854,7 @@ bool C018_init(struct EventStruct *event) {
|
||||
if (!customConfig) {
|
||||
return false;
|
||||
}
|
||||
LoadCustomControllerSettings(event->ControllerIndex, (uint8_t *)customConfig.get(), sizeof(C018_ConfigStruct));
|
||||
LoadCustomControllerSettings(event->ControllerIndex, reinterpret_cast<uint8_t *>(customConfig.get()), sizeof(C018_ConfigStruct));
|
||||
customConfig->validate();
|
||||
|
||||
if (!C018_data->init(customConfig->serialPort, customConfig->rxpin, customConfig->txpin, customConfig->baudrate,
|
||||
|
||||
@@ -92,7 +92,7 @@ boolean Plugin_006(uint8_t function, struct EventStruct *event, String& string)
|
||||
{
|
||||
UserVar[event->BaseVarIndex] = P006_data->readTemperature();
|
||||
int elev = PCONFIG(1);
|
||||
float pressure = (float)P006_data->readPressure() / 100.0f;
|
||||
float pressure = static_cast<float>(P006_data->readPressure()) / 100.0f;
|
||||
|
||||
if (elev != 0)
|
||||
{
|
||||
|
||||
@@ -104,7 +104,7 @@ boolean Plugin_007(uint8_t function, struct EventStruct *event, String& string)
|
||||
if (Wire.available())
|
||||
{
|
||||
Wire.read(); // Read older value first (stored in chip)
|
||||
UserVar[event->BaseVarIndex] = (float)Wire.read(); // now read actual value and store into Nodo var
|
||||
UserVar[event->BaseVarIndex] = Wire.read(); // now read actual value and store into Nodo var
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log;
|
||||
|
||||
+2
-2
@@ -140,7 +140,7 @@ boolean Plugin_012(uint8_t function, struct EventStruct *event, String& string)
|
||||
if (error.length() > 0) {
|
||||
addHtmlError(error);
|
||||
}
|
||||
SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemplate, sizeof(deviceTemplate));
|
||||
SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<const uint8_t *>(&deviceTemplate), sizeof(deviceTemplate));
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
@@ -198,7 +198,7 @@ boolean Plugin_012(uint8_t function, struct EventStruct *event, String& string)
|
||||
if (nullptr != P012_data) {
|
||||
// FIXME TD-er: This is a huge stack allocated object.
|
||||
char deviceTemplate[P12_Nlines][P12_Nchars];
|
||||
LoadCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemplate, sizeof(deviceTemplate));
|
||||
LoadCustomTaskSettings(event->TaskIndex, reinterpret_cast<uint8_t *>(&deviceTemplate), sizeof(deviceTemplate));
|
||||
|
||||
for (uint8_t x = 0; x < P012_data->Plugin_012_rows; x++)
|
||||
{
|
||||
|
||||
@@ -163,7 +163,7 @@ boolean Plugin_013(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
int8_t Plugin_013_TRIG_Pin = CONFIG_PIN1;
|
||||
int8_t Plugin_013_IRQ_Pin = CONFIG_PIN2;
|
||||
int16_t max_distance_cm = (measuringUnit == UNIT_CM) ? max_distance : (float)max_distance * 2.54f;
|
||||
int16_t max_distance_cm = (measuringUnit == UNIT_CM) ? max_distance : static_cast<float>(max_distance) * 2.54f;
|
||||
|
||||
// create sensor instance and add to std::map
|
||||
P_013_sensordefs.erase(event->TaskIndex);
|
||||
@@ -309,7 +309,7 @@ float Plugin_013_read(taskIndex_t taskIndex)
|
||||
int16_t measuringUnit = Settings.TaskDevicePluginConfig[taskIndex][3];
|
||||
int16_t filterType = Settings.TaskDevicePluginConfig[taskIndex][4];
|
||||
int16_t filterSize = Settings.TaskDevicePluginConfig[taskIndex][5];
|
||||
int16_t max_distance_cm = (measuringUnit == UNIT_CM) ? max_distance : (float)max_distance * 2.54f;
|
||||
int16_t max_distance_cm = (measuringUnit == UNIT_CM) ? max_distance : static_cast<float>(max_distance) * 2.54f;
|
||||
|
||||
unsigned int echoTime = 0;
|
||||
|
||||
|
||||
+1
-1
@@ -861,7 +861,7 @@ boolean displayRawToReadableB32Hex(String& outputStr, decode_results results)
|
||||
continue;
|
||||
}
|
||||
avg /= results.rawlen / 2;
|
||||
float avgTms = (float)totTms / (results.rawlen / 2);
|
||||
float avgTms = static_cast<float>(totTms) / (results.rawlen / 2);
|
||||
|
||||
if ((avgTms <= bstMul) && (avg < bstAvg))
|
||||
{
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ boolean Plugin_018(uint8_t function, struct EventStruct *event, String& string)
|
||||
delayMicroseconds(9680);
|
||||
}
|
||||
interrupts();
|
||||
UserVar[event->BaseVarIndex] = (float)value;
|
||||
UserVar[event->BaseVarIndex] = value;
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("GPY : Dust value: ");
|
||||
log += value;
|
||||
|
||||
+40
-22
@@ -24,17 +24,18 @@
|
||||
# define P020_RX_WAIT PCONFIG(4)
|
||||
# define P020_SERIAL_CONFIG PCONFIG(1)
|
||||
# define P020_SERIAL_PROCESSING PCONFIG(5)
|
||||
# define P020_RESET_TARGET_PIN CONFIG_PIN1
|
||||
# define P020_RESET_TARGET_PIN PCONFIG(6)
|
||||
# define P020_RX_BUFFER PCONFIG(7)
|
||||
|
||||
|
||||
# define P020_QUERY_VALUE 0 // Temp placement holder until we know what selectors are needed.
|
||||
# define P020_NR_OUTPUT_OPTIONS 1
|
||||
|
||||
# define P020_NR_OUTPUT_VALUES 1
|
||||
# define P020_QUERY1_CONFIG_POS 3
|
||||
|
||||
# define P020_DEFAULT_SERVER_PORT 1234
|
||||
# define P020_DEFAULT_BAUDRATE 115200
|
||||
# define P020_DEFAULT_RESET_TARGET_PIN -1
|
||||
# define P020_DEFAULT_RX_BUFFER 256
|
||||
|
||||
|
||||
boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
@@ -67,9 +68,11 @@ boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_SET_DEFAULTS:
|
||||
{
|
||||
P020_BAUDRATE = P020_DEFAULT_BAUDRATE;
|
||||
P020_SERVER_PORT = P020_DEFAULT_SERVER_PORT;
|
||||
success = true;
|
||||
P020_BAUDRATE = P020_DEFAULT_BAUDRATE;
|
||||
P020_SERVER_PORT = P020_DEFAULT_SERVER_PORT;
|
||||
P020_RESET_TARGET_PIN = P020_DEFAULT_RESET_TARGET_PIN;
|
||||
P020_RX_BUFFER = P020_DEFAULT_RX_BUFFER;
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -81,7 +84,7 @@ boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_GET_DEVICEGPIONAMES:
|
||||
case PLUGIN_GET_DEVICEGPIONAMES:
|
||||
{
|
||||
serialHelper_getGpioNames(event);
|
||||
break;
|
||||
@@ -89,7 +92,7 @@ boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
|
||||
case PLUGIN_WEBFORM_LOAD:
|
||||
{
|
||||
{
|
||||
addFormNumericBox(F("TCP Port"), F("p020_port"), P020_SERVER_PORT, 0);
|
||||
addFormNumericBox(F("Baud Rate"), F("p020_baud"), P020_BAUDRATE, 0);
|
||||
uint8_t serialConfChoice = serialHelper_convertOldSerialConfig(P020_SERIAL_CONFIG);
|
||||
@@ -102,9 +105,14 @@ boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
options[2] = F("RFLink");
|
||||
addFormSelector(F("Event processing"), F("p020_events"), 3, options, NULL, choice);
|
||||
}
|
||||
addFormNumericBox(F("RX Receive Timeout (mSec)"), F("p020_rxwait"), P020_RX_WAIT, 0);
|
||||
addFormNumericBox(F("RX Receive Timeout (mSec)"), F("p020_rxwait"), P020_RX_WAIT, 0, 20);
|
||||
addFormPinSelect(F("Reset target after init"), F("p020_resetpin"), P020_RESET_TARGET_PIN);
|
||||
|
||||
addFormNumericBox(F("RX buffer size (bytes)"), F("p020_rx_buffer"), P020_RX_BUFFER, 256, 1024);
|
||||
addFormNote(F("Standard RX buffer 256B; higher values could be unstable; energy meters could require 1024B"));
|
||||
|
||||
success = true;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_WEBFORM_SAVE:
|
||||
@@ -114,6 +122,8 @@ boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
P020_SERIAL_CONFIG = serialHelper_serialconfig_webformSave();
|
||||
P020_SERIAL_PROCESSING = getFormItemInt(F("p020_events"));
|
||||
P020_RX_WAIT = getFormItemInt(F("p020_rxwait"));
|
||||
P020_RESET_TARGET_PIN = getFormItemInt(F("p020_resetpin"));
|
||||
P020_RX_BUFFER = getFormItemInt(F("p020_rx_buffer"));
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
@@ -184,12 +194,20 @@ boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
if (P020_RESET_TARGET_PIN != -1) {
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
String log;
|
||||
log.reserve(38);
|
||||
log = F("Ser2net : P020_RESET_TARGET_PIN : ");
|
||||
log += P020_RESET_TARGET_PIN;
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
pinMode(P020_RESET_TARGET_PIN, OUTPUT);
|
||||
digitalWrite(P020_RESET_TARGET_PIN, LOW);
|
||||
delay(500);
|
||||
digitalWrite(P020_RESET_TARGET_PIN, HIGH);
|
||||
pinMode(P020_RESET_TARGET_PIN, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
task->serial_processing = P020_SERIAL_PROCESSING;
|
||||
success = true;
|
||||
break;
|
||||
@@ -206,7 +224,7 @@ boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
P020_Task *task = static_cast<P020_Task *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if (nullptr == task) {
|
||||
break;
|
||||
break;
|
||||
}
|
||||
task->checkServer();
|
||||
success = true;
|
||||
@@ -217,8 +235,8 @@ boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
{
|
||||
P020_Task *task = static_cast<P020_Task *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if (nullptr == task) {
|
||||
break;
|
||||
if (nullptr == task) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (task->hasClientConnected()) {
|
||||
@@ -233,14 +251,14 @@ boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
{
|
||||
P020_Task *task = static_cast<P020_Task *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if (nullptr == task) {
|
||||
break;
|
||||
if (nullptr == task) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (task->hasClientConnected()) {
|
||||
task->handleSerialIn(event);
|
||||
} else {
|
||||
task->discardSerialIn();
|
||||
if (task->hasClientConnected()) {
|
||||
task->handleSerialIn(event);
|
||||
} else {
|
||||
task->discardSerialIn();
|
||||
|
||||
}
|
||||
success = true;
|
||||
@@ -252,10 +270,10 @@ boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string)
|
||||
String command = parseString(string, 1);
|
||||
P020_Task *task = static_cast<P020_Task *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if (nullptr == task) {
|
||||
break;
|
||||
if (nullptr == task) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (command == F("serialsend")) {
|
||||
const char *tmpBuf = string.substring(11).c_str();
|
||||
task->ser2netSerial->write(tmpBuf);
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ boolean Plugin_023(uint8_t function, struct EventStruct *event, String& string)
|
||||
if (error.length() > 0) {
|
||||
addHtmlError(error);
|
||||
}
|
||||
SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemplate, sizeof(deviceTemplate));
|
||||
SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<const uint8_t *>(&deviceTemplate), sizeof(deviceTemplate));
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ boolean Plugin_024(uint8_t function, struct EventStruct *event, String& string)
|
||||
static_cast<P024_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if (nullptr != P024_data) {
|
||||
UserVar[event->BaseVarIndex] = (float)P024_data->readTemperature(PCONFIG(0));
|
||||
UserVar[event->BaseVarIndex] = P024_data->readTemperature(PCONFIG(0));
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
String log = F("MLX90614 : Temperature: ");
|
||||
log += formatUserVarNoCheck(event->TaskIndex, 0);
|
||||
|
||||
@@ -169,7 +169,7 @@ boolean Plugin_025(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
if (nullptr != P025_data) {
|
||||
const int16_t value = P025_data->read();
|
||||
UserVar[event->BaseVarIndex] = (float)value;
|
||||
UserVar[event->BaseVarIndex] = value;
|
||||
|
||||
String log;
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
@@ -186,7 +186,7 @@ boolean Plugin_025(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
if (adc1 != adc2)
|
||||
{
|
||||
float normalized = (float)(value - adc1) / (float)(adc2 - adc1);
|
||||
const float normalized = static_cast<float>(value - adc1) / static_cast<float>(adc2 - adc1);
|
||||
UserVar[event->BaseVarIndex] = normalized * (out2 - out1) + out1;
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
log += ' ';
|
||||
|
||||
@@ -162,9 +162,9 @@ boolean Plugin_030(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
if (elev)
|
||||
{
|
||||
UserVar[event->BaseVarIndex + 1] = Plugin_030_pressureElevation((float)Plugin_030_readPressure(idx) / 100, elev);
|
||||
UserVar[event->BaseVarIndex + 1] = Plugin_030_pressureElevation(static_cast<float>(Plugin_030_readPressure(idx)) / 100.0f, elev);
|
||||
} else {
|
||||
UserVar[event->BaseVarIndex + 1] = ((float)Plugin_030_readPressure(idx)) / 100;
|
||||
UserVar[event->BaseVarIndex + 1] = static_cast<float>(Plugin_030_readPressure(idx)) / 100.0f;
|
||||
}
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
@@ -315,7 +315,7 @@ float Plugin_030_readPressure(uint8_t idx) {
|
||||
var2 = (((int64_t)_bmp280_calib[idx].dig_P8) * p) >> 19;
|
||||
|
||||
p = ((p + var1 + var2) >> 8) + (((int64_t)_bmp280_calib[idx].dig_P7) << 4);
|
||||
return (float)p / 256;
|
||||
return static_cast<float>(p) / 256.0f;
|
||||
}
|
||||
|
||||
// **************************************************************************/
|
||||
|
||||
@@ -446,7 +446,7 @@ boolean Plugin_036(uint8_t function, struct EventStruct *event, String& string)
|
||||
if (error.length() > 0) {
|
||||
addHtmlError(error);
|
||||
}
|
||||
SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&(P036_data->DisplayLinesV1), sizeof(P036_data->DisplayLinesV1));
|
||||
SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<const uint8_t *>(&(P036_data->DisplayLinesV1)), sizeof(P036_data->DisplayLinesV1));
|
||||
|
||||
// Need to delete the allocated object here
|
||||
delete P036_data;
|
||||
@@ -945,8 +945,8 @@ boolean Plugin_036(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
const int strlen = strnlen_P(P036_data->DisplayLinesV1[LineNo - 1].Content, sizeof(P036_data->DisplayLinesV1[LineNo - 1].Content));
|
||||
if (strlen > 0) {
|
||||
const float fAvgPixPerChar = ((float)PixLength) / strlen;
|
||||
const int iCharToRemove = ceil(((float)(PixLength - 255)) / fAvgPixPerChar);
|
||||
const float fAvgPixPerChar = static_cast<float>(PixLength) / strlen;
|
||||
const int iCharToRemove = ceil((static_cast<float>(PixLength - 255)) / fAvgPixPerChar);
|
||||
|
||||
// shorten string because OLED controller can not handle such long strings
|
||||
P036_data->DisplayLinesV1[LineNo - 1].Content[strlen - iCharToRemove] = 0;
|
||||
@@ -972,7 +972,7 @@ boolean Plugin_036(uint8_t function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
if (UserVar[event->BaseVarIndex] == 1) {
|
||||
uint8_t nextFrame = ceil(((float)LineNo) / P036_data->ScrollingPages.linesPerFrame) - 1; // next frame shows the new content,
|
||||
uint8_t nextFrame = ceil((static_cast<float>(LineNo)) / P036_data->ScrollingPages.linesPerFrame) - 1; // next frame shows the new content,
|
||||
// 0-based
|
||||
P036_data->P036_JumpToPage(event, nextFrame); // Start to display the selected page,
|
||||
// function needs 65ms!
|
||||
|
||||
@@ -174,9 +174,9 @@ boolean Plugin_047(uint8_t function, struct EventStruct *event, String& string)
|
||||
// 2 s delay ...we need this delay, otherwise we get only the last reading...
|
||||
delayBackground(2000);
|
||||
|
||||
float temperature = ((float)Plugin_047_readTemperature(P047_I2C_ADDR)) / 10;
|
||||
float moisture = ((float)Plugin_047_readMoisture(P047_I2C_ADDR));
|
||||
float light = ((float)Plugin_047_readLight(P047_I2C_ADDR));
|
||||
const float temperature = Plugin_047_readTemperature(P047_I2C_ADDR) / 10.0f;
|
||||
const float moisture = Plugin_047_readMoisture(P047_I2C_ADDR);
|
||||
const float light = Plugin_047_readLight(P047_I2C_ADDR);
|
||||
|
||||
if ((temperature > 100) || (temperature < -40) || (moisture > 800) || (moisture < 1) || (light > 65535) || (light < 0)) {
|
||||
addLog(LOG_LEVEL_INFO, F("SoilMoisture: Bad Reading, resetting Sensor..."));
|
||||
|
||||
+3
-3
@@ -595,9 +595,9 @@ boolean Plugin_049(uint8_t function, struct EventStruct *event, String& string)
|
||||
const int filterValue = PCONFIG(1);
|
||||
|
||||
if (Plugin_049_Check_and_ApplyFilter(UserVar[event->BaseVarIndex], ppm, s, filterValue, log)) {
|
||||
UserVar[event->BaseVarIndex] = (float)ppm;
|
||||
UserVar[event->BaseVarIndex + 1] = (float)temp;
|
||||
UserVar[event->BaseVarIndex + 2] = (float)u;
|
||||
UserVar[event->BaseVarIndex] = ppm;
|
||||
UserVar[event->BaseVarIndex + 1] = temp;
|
||||
UserVar[event->BaseVarIndex + 2] = u;
|
||||
success = true;
|
||||
} else {
|
||||
success = false;
|
||||
|
||||
+12
-12
@@ -323,9 +323,9 @@ boolean Plugin_050(uint8_t function, struct EventStruct *event, String& string)
|
||||
// Fall through
|
||||
case 4:
|
||||
if (t != 0) { // r/g/b (normalized to 0.00..255.00 (but avoid divide by 0)
|
||||
UserVar[event->BaseVarIndex + 0] = (float)r / t * sRGBFactor;
|
||||
UserVar[event->BaseVarIndex + 1] = (float)g / t * sRGBFactor;
|
||||
UserVar[event->BaseVarIndex + 2] = (float)b / t * sRGBFactor;
|
||||
UserVar[event->BaseVarIndex + 0] = static_cast<float>(r) / t * sRGBFactor;
|
||||
UserVar[event->BaseVarIndex + 1] = static_cast<float>(g) / t * sRGBFactor;
|
||||
UserVar[event->BaseVarIndex + 2] = static_cast<float>(b) / t * sRGBFactor;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
@@ -333,9 +333,9 @@ boolean Plugin_050(uint8_t function, struct EventStruct *event, String& string)
|
||||
// Fall through
|
||||
case 5:
|
||||
if (t != 0) { // R/G/B normalized & transformed
|
||||
float nr = (float)r / t * sRGBFactor;
|
||||
float ng = (float)g / t * sRGBFactor;
|
||||
float nb = (float)b / t * sRGBFactor;
|
||||
const float nr = static_cast<float>(r) / t * sRGBFactor;
|
||||
const float ng = static_cast<float>(g) / t * sRGBFactor;
|
||||
const float nb = static_cast<float>(b) / t * sRGBFactor;
|
||||
P050_data->applyTransformation(nr, ng, nb,
|
||||
&UserVar[event->BaseVarIndex + 0],
|
||||
&UserVar[event->BaseVarIndex + 1],
|
||||
@@ -403,9 +403,9 @@ boolean Plugin_050(uint8_t function, struct EventStruct *event, String& string)
|
||||
} else {
|
||||
RuleEvent += F("NormSRGBtransformed=");
|
||||
}
|
||||
nr = (float)r / t * sRGBFactor;
|
||||
ng = (float)g / t * sRGBFactor;
|
||||
nb = (float)b / t * sRGBFactor;
|
||||
nr = static_cast<float>(r) / t * sRGBFactor;
|
||||
ng = static_cast<float>(g) / t * sRGBFactor;
|
||||
nb = static_cast<float>(b) / t * sRGBFactor;
|
||||
P050_data->applyTransformation(nr, ng, nb, &tr, &tg, &tb);
|
||||
}
|
||||
RuleEvent += String(tr, 4);
|
||||
@@ -423,11 +423,11 @@ boolean Plugin_050(uint8_t function, struct EventStruct *event, String& string)
|
||||
} else {
|
||||
RuleEvent += F("NormSRGB=");
|
||||
}
|
||||
RuleEvent += String((float)r / t * sRGBFactor, 4);
|
||||
RuleEvent += String(static_cast<float>(r) / t * sRGBFactor, 4);
|
||||
RuleEvent += ',';
|
||||
RuleEvent += String((float)g / t * sRGBFactor, 4);
|
||||
RuleEvent += String(static_cast<float>(g) / t * sRGBFactor, 4);
|
||||
RuleEvent += ',';
|
||||
RuleEvent += String((float)b / t * sRGBFactor, 4);
|
||||
RuleEvent += String(static_cast<float>(b) / t * sRGBFactor, 4);
|
||||
break;
|
||||
default:
|
||||
RuleEvent = EMPTY_STRING;
|
||||
|
||||
@@ -661,9 +661,9 @@ boolean Plugin_052(uint8_t function, struct EventStruct *event, String& string)
|
||||
log += F("CO2: ");
|
||||
log += co2;
|
||||
log += F(" ppm Temp: ");
|
||||
log += (float)temperature / 100.0f;
|
||||
log += static_cast<float>(temperature) / 100.0f;
|
||||
log += F(" C Hum: ");
|
||||
log += (float)humidity / 100.0f;
|
||||
log += static_cast<float>(humidity) / 100.0f;
|
||||
log += F("%");
|
||||
if (!valid_measurement)
|
||||
log += F(" (old)");
|
||||
|
||||
@@ -139,7 +139,7 @@ boolean Plugin_055(uint8_t function, struct EventStruct *event, String& string)
|
||||
PCONFIG(1) = 400;
|
||||
|
||||
// FIXME TD-er: Should we add support for 4 pin definitions?
|
||||
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_output(F("Driver#8")), F("TDP4"), (int)(Settings.TaskDevicePin[3][event->TaskIndex]));
|
||||
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_output(F("Driver#8")), F("TDP4"), static_cast<int>(Settings.TaskDevicePin[3][event->TaskIndex]));
|
||||
|
||||
addFormSubHeader(F("Timing"));
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ boolean Plugin_058(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
if (P058_data->readKey(key))
|
||||
{
|
||||
UserVar[event->BaseVarIndex] = (float)key;
|
||||
UserVar[event->BaseVarIndex] = key;
|
||||
event->sensorType = Sensor_VType::SENSOR_TYPE_SWITCH;
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
|
||||
@@ -151,7 +151,7 @@ boolean Plugin_059(uint8_t function, struct EventStruct *event, String& string)
|
||||
if (P_059_sensordefs[event->TaskIndex]->hasChanged())
|
||||
{
|
||||
long c = P_059_sensordefs[event->TaskIndex]->read();
|
||||
UserVar[event->BaseVarIndex] = (float)c;
|
||||
UserVar[event->BaseVarIndex] = c;
|
||||
event->sensorType = Sensor_VType::SENSOR_TYPE_SWITCH;
|
||||
|
||||
String log = F("QEI : ");
|
||||
@@ -170,7 +170,7 @@ boolean Plugin_059(uint8_t function, struct EventStruct *event, String& string)
|
||||
{
|
||||
if (P_059_sensordefs.count(event->TaskIndex) != 0)
|
||||
{
|
||||
UserVar[event->BaseVarIndex] = (float)P_059_sensordefs[event->TaskIndex]->read();
|
||||
UserVar[event->BaseVarIndex] = P_059_sensordefs[event->TaskIndex]->read();
|
||||
}
|
||||
success = true;
|
||||
break;
|
||||
|
||||
@@ -151,7 +151,7 @@ boolean Plugin_060(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
if (adc1 != adc2)
|
||||
{
|
||||
float normalized = (float)(UserVar[event->BaseVarIndex] - adc1) / (float)(adc2 - adc1);
|
||||
const float normalized = (UserVar[event->BaseVarIndex] - adc1) / static_cast<float>(adc2 - adc1);
|
||||
UserVar[event->BaseVarIndex] = normalized * (out2 - out1) + out1;
|
||||
|
||||
log += F(" = ");
|
||||
|
||||
@@ -162,7 +162,7 @@ boolean Plugin_061(uint8_t function, struct EventStruct *event, String& string)
|
||||
{
|
||||
if (sentScanCode != actScanCode) // any change to last sent data?
|
||||
{
|
||||
UserVar[event->BaseVarIndex] = (float)actScanCode;
|
||||
UserVar[event->BaseVarIndex] = actScanCode;
|
||||
event->sensorType = Sensor_VType::SENSOR_TYPE_SWITCH;
|
||||
|
||||
String log = F("KPad : ScanCode=0x");
|
||||
|
||||
@@ -207,7 +207,7 @@ boolean Plugin_062(uint8_t function, struct EventStruct *event, String& string)
|
||||
log += sizeof(P062_data->StoredSettings);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif // PLUGIN_062_DEBUG
|
||||
SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&(P062_data->StoredSettings), sizeof(P062_data->StoredSettings));
|
||||
SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<const uint8_t *>(&(P062_data->StoredSettings)), sizeof(P062_data->StoredSettings));
|
||||
if (!canCalibrate) {
|
||||
delete P062_data;
|
||||
} else {
|
||||
@@ -271,7 +271,7 @@ boolean Plugin_062(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
if (P062_data->readKey(key))
|
||||
{
|
||||
UserVar[event->BaseVarIndex] = (float)key;
|
||||
UserVar[event->BaseVarIndex] = key;
|
||||
event->sensorType = Sensor_VType::SENSOR_TYPE_SWITCH;
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
|
||||
@@ -186,7 +186,7 @@ boolean Plugin_063(uint8_t function, struct EventStruct *event, String& string)
|
||||
if (keyLast != key)
|
||||
{
|
||||
keyLast = key;
|
||||
UserVar[event->BaseVarIndex] = (float)key;
|
||||
UserVar[event->BaseVarIndex] = key;
|
||||
event->sensorType = Sensor_VType::SENSOR_TYPE_SWITCH;
|
||||
|
||||
String log = F("Tkey : ");
|
||||
|
||||
@@ -205,7 +205,7 @@ float VEML6040_GetValue(uint8_t reg)
|
||||
{
|
||||
uint16_t lsb = Wire.read();
|
||||
uint16_t msb = Wire.read();
|
||||
return (float)((msb << 8) | lsb);
|
||||
return static_cast<float>((msb << 8) | lsb);
|
||||
}
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ boolean Plugin_067(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
if (Plugin_067_OversamplingCountChanA[event->TaskIndex] > 0)
|
||||
{
|
||||
UserVar[event->BaseVarIndex + 2] = (float)Plugin_067_OversamplingValueChanA[event->TaskIndex] / Plugin_067_OversamplingCountChanA[event->TaskIndex];
|
||||
UserVar[event->BaseVarIndex + 2] = static_cast<float>(Plugin_067_OversamplingValueChanA[event->TaskIndex]) / Plugin_067_OversamplingCountChanA[event->TaskIndex];
|
||||
|
||||
Plugin_067_OversamplingValueChanA[event->TaskIndex] = 0;
|
||||
Plugin_067_OversamplingCountChanA[event->TaskIndex] = 0;
|
||||
@@ -412,7 +412,7 @@ boolean Plugin_067(uint8_t function, struct EventStruct *event, String& string)
|
||||
float out2 = PCONFIG_FLOAT(1);
|
||||
if (adc1 != adc2)
|
||||
{
|
||||
float normalized = (float)(UserVar[event->BaseVarIndex] - adc1) / (float)(adc2 - adc1);
|
||||
const float normalized = static_cast<float>(UserVar[event->BaseVarIndex] - adc1) / static_cast<float>(adc2 - adc1);
|
||||
UserVar[event->BaseVarIndex] = normalized * (out2 - out1) + out1;
|
||||
|
||||
log += F(" = ");
|
||||
@@ -434,7 +434,7 @@ boolean Plugin_067(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
if (Plugin_067_OversamplingCountChanB[event->TaskIndex] > 0)
|
||||
{
|
||||
UserVar[event->BaseVarIndex + 3] = (float)Plugin_067_OversamplingValueChanB[event->TaskIndex] / Plugin_067_OversamplingCountChanB[event->TaskIndex];
|
||||
UserVar[event->BaseVarIndex + 3] = static_cast<float>(Plugin_067_OversamplingValueChanB[event->TaskIndex]) / Plugin_067_OversamplingCountChanB[event->TaskIndex];
|
||||
|
||||
Plugin_067_OversamplingValueChanB[event->TaskIndex] = 0;
|
||||
Plugin_067_OversamplingCountChanB[event->TaskIndex] = 0;
|
||||
@@ -452,7 +452,7 @@ boolean Plugin_067(uint8_t function, struct EventStruct *event, String& string)
|
||||
float out2 = PCONFIG_FLOAT(3);
|
||||
if (adc1 != adc2)
|
||||
{
|
||||
float normalized = (float)(UserVar[event->BaseVarIndex + 1] - adc1) / (float)(adc2 - adc1);
|
||||
float normalized = (UserVar[event->BaseVarIndex + 1] - adc1) / static_cast<float>(adc2 - adc1);
|
||||
UserVar[event->BaseVarIndex + 1] = normalized * (out2 - out1) + out1;
|
||||
|
||||
log += F(" = ");
|
||||
|
||||
@@ -167,7 +167,7 @@ boolean Plugin_075(uint8_t function, struct EventStruct *event, String& string)
|
||||
case PLUGIN_WEBFORM_LOAD: {
|
||||
|
||||
// ** DEVELOPER DEBUG MESSAGE AREA **
|
||||
// int datax = (int)(Settings.TaskDeviceEnabled[event->TaskIndex]); // Debug value.
|
||||
// int datax = static_cast<int>(Settings.TaskDeviceEnabled[event->TaskIndex]); // Debug value.
|
||||
// String Data = "Debug. Plugin Enable State: ";
|
||||
// Data += String(datax);
|
||||
// addFormNote(Data);
|
||||
|
||||
@@ -257,7 +257,7 @@ boolean Plugin_076(uint8_t function, struct EventStruct *event, String &string)
|
||||
hlwMultipliers[1] = getFormItemFloat(F("p076_voltmult"));
|
||||
hlwMultipliers[2] = getFormItemFloat(F("p076_powmult"));
|
||||
if (hlwMultipliers[0] > 1.0f && hlwMultipliers[1] > 1.0f && hlwMultipliers[2] > 1.0f) {
|
||||
SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&hlwMultipliers,
|
||||
SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<const uint8_t *>(&hlwMultipliers),
|
||||
sizeof(hlwMultipliers));
|
||||
if (PLUGIN_076_DEBUG) {
|
||||
addLog(LOG_LEVEL_INFO, F("P076: Saved Calibration from Config Page"));
|
||||
@@ -491,7 +491,7 @@ void Plugin076_SaveMultipliers() {
|
||||
if (StoredTaskIndex < 0) return; // Not yet initialized.
|
||||
double hlwMultipliers[3];
|
||||
if (Plugin076_ReadMultipliers(hlwMultipliers[0], hlwMultipliers[1], hlwMultipliers[2])) {
|
||||
SaveCustomTaskSettings(StoredTaskIndex, (uint8_t *)&hlwMultipliers,
|
||||
SaveCustomTaskSettings(StoredTaskIndex, reinterpret_cast<const uint8_t *>(&hlwMultipliers),
|
||||
sizeof(hlwMultipliers));
|
||||
}
|
||||
}
|
||||
@@ -517,7 +517,7 @@ bool Plugin076_LoadMultipliers(taskIndex_t TaskIndex, double& current, double& v
|
||||
return false;
|
||||
}
|
||||
double hlwMultipliers[3];
|
||||
LoadCustomTaskSettings(TaskIndex, (uint8_t *)&hlwMultipliers,
|
||||
LoadCustomTaskSettings(TaskIndex, reinterpret_cast<uint8_t *>(&hlwMultipliers),
|
||||
sizeof(hlwMultipliers));
|
||||
if (hlwMultipliers[0] > 1.0f) {
|
||||
current = hlwMultipliers[0];
|
||||
|
||||
@@ -81,7 +81,7 @@ struct P077_data_struct : public PluginTaskData_base {
|
||||
// if (energy_power_on) { // Powered on
|
||||
|
||||
if (adjustment & 0x40) { // Voltage valid
|
||||
energy_voltage = (float)(PCONFIG(0) * CSE_UREF) / (float)voltage_cycle;
|
||||
energy_voltage = static_cast<float>(PCONFIG(0) * CSE_UREF) / static_cast<float>(voltage_cycle);
|
||||
}
|
||||
if (adjustment & 0x10) { // Power valid
|
||||
if ((header & 0xF2) == 0xF2) { // Power cycle exceeds range
|
||||
@@ -91,7 +91,7 @@ struct P077_data_struct : public PluginTaskData_base {
|
||||
power_cycle_first = power_cycle; // Skip first incomplete power_cycle
|
||||
if (power_cycle_first != power_cycle) {
|
||||
power_cycle_first = -1;
|
||||
energy_power = (float)(PCONFIG(2) * CSE_PREF) / (float)power_cycle;
|
||||
energy_power = static_cast<float>(PCONFIG(2) * CSE_PREF) / static_cast<float>(power_cycle);
|
||||
} else {
|
||||
energy_power = 0;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ struct P077_data_struct : public PluginTaskData_base {
|
||||
if (0 == energy_power) {
|
||||
energy_current = 0;
|
||||
} else {
|
||||
energy_current = (float)PCONFIG(1) / (float)current_cycle;
|
||||
energy_current = static_cast<float>(PCONFIG(1)) / static_cast<float>(current_cycle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -80,7 +80,7 @@ String P081_getCronExpr(taskIndex_t taskIndex)
|
||||
char expression[PLUGIN_081_EXPRESSION_SIZE + 1];
|
||||
|
||||
ZERO_FILL(expression);
|
||||
LoadCustomTaskSettings(taskIndex, (uint8_t *)&expression, PLUGIN_081_EXPRESSION_SIZE);
|
||||
LoadCustomTaskSettings(taskIndex, reinterpret_cast<uint8_t *>(&expression), PLUGIN_081_EXPRESSION_SIZE);
|
||||
String res(expression);
|
||||
res.trim();
|
||||
return res;
|
||||
@@ -222,7 +222,7 @@ boolean Plugin_081(uint8_t function, struct EventStruct *event, String& string)
|
||||
char expression_c[PLUGIN_081_EXPRESSION_SIZE];
|
||||
ZERO_FILL(expression_c);
|
||||
safe_strncpy(expression_c, expression, PLUGIN_081_EXPRESSION_SIZE);
|
||||
log = SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&expression_c, PLUGIN_081_EXPRESSION_SIZE);
|
||||
log = SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<const uint8_t *>(&expression_c), PLUGIN_081_EXPRESSION_SIZE);
|
||||
}
|
||||
|
||||
if (log.length() > 0)
|
||||
|
||||
@@ -122,7 +122,7 @@ boolean Plugin_090(uint8_t function, struct EventStruct *event, String& string)
|
||||
{
|
||||
{
|
||||
// read frequency
|
||||
int frequencyChoice = (int)P090_READ_INTERVAL;
|
||||
int frequencyChoice = P090_READ_INTERVAL;
|
||||
const __FlashStringHelper * frequencyOptions[3] = { F("1 second"), F("10 seconds"), F("60 seconds") };
|
||||
int frequencyValues[3] = { 1, 2, 3 };
|
||||
addFormSelector(F("Take reading every"), F("p090_read_frequency"), 3, frequencyOptions, frequencyValues, frequencyChoice);
|
||||
|
||||
@@ -364,7 +364,7 @@ boolean Plugin_099(uint8_t function, struct EventStruct *event, String& string)
|
||||
log += sizeof(P099_data->StoredSettings);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif // PLUGIN_099_DEBUG
|
||||
SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&(P099_data->StoredSettings), sizeof(P099_data->StoredSettings) /*+ sizeof(P099_data->TouchObjects)*/);
|
||||
SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<const uint8_t *>(&(P099_data->StoredSettings)), sizeof(P099_data->StoredSettings) /*+ sizeof(P099_data->TouchObjects)*/);
|
||||
delete P099_data;
|
||||
|
||||
success = true;
|
||||
|
||||
@@ -171,8 +171,8 @@ boolean Plugin_101(uint8_t function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
case PLUGIN_WEBFORM_SAVE: {
|
||||
char ipString[IP_BUFF_SIZE_P101] = "";
|
||||
char macString[MAC_BUFF_SIZE_P101] = "";
|
||||
char ipString[IP_BUFF_SIZE_P101] = {0};
|
||||
char macString[MAC_BUFF_SIZE_P101] = {0};
|
||||
char deviceTemplate[2][CUSTOMTASK_STR_SIZE_P101];
|
||||
String errorStr;
|
||||
String msgStr;
|
||||
@@ -184,7 +184,7 @@ boolean Plugin_101(uint8_t function, struct EventStruct *event, String& string)
|
||||
uint8_t nameCode = safeName(event->TaskIndex);
|
||||
|
||||
if ((nameCode == NAME_MISSING) || (nameCode == NAME_UNSAFE)) { // Check to see if user submitted safe device name.
|
||||
strcpy(ExtraTaskSettings.TaskDeviceName, (char *)(F(DEF_TASK_NAME_P101))); // Use default name.
|
||||
strcpy(ExtraTaskSettings.TaskDeviceName, String(F(DEF_TASK_NAME_P101)).c_str()); // Use default name.
|
||||
|
||||
if (nameCode == NAME_UNSAFE) {
|
||||
errorStr = F("ALERT, Renamed Unsafe Task Name. ");
|
||||
@@ -200,7 +200,7 @@ boolean Plugin_101(uint8_t function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
if (strlen(ipString) == 0) { // IP Address missing, use default value (without webform warning).
|
||||
strcpy_P(ipString, (char *)(F(IP_STR_DEF_P101)));
|
||||
strcpy_P(ipString, String(F(IP_STR_DEF_P101)).c_str());
|
||||
|
||||
msgStr = wolStr;
|
||||
msgStr += F("Loaded Default IP = ");
|
||||
@@ -208,7 +208,7 @@ boolean Plugin_101(uint8_t function, struct EventStruct *event, String& string)
|
||||
addLog(LOG_LEVEL_INFO, msgStr);
|
||||
}
|
||||
else if (strlen(ipString) < IP_MIN_SIZE_P101) { // IP Address too short, load default value. Warn User.
|
||||
strcpy_P(ipString, (char *)(F(IP_STR_DEF_P101)));
|
||||
strcpy_P(ipString, String(F(IP_STR_DEF_P101)).c_str());
|
||||
|
||||
msgStr = F("Provided IP Invalid (Using Default). ");
|
||||
errorStr += msgStr;
|
||||
@@ -237,7 +237,7 @@ boolean Plugin_101(uint8_t function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
if (strlen(macString) == 0) { // MAC Address missing, use default value.
|
||||
strcpy_P(macString, (char *)(F(MAC_STR_DEF_P101)));
|
||||
strcpy_P(macString, String(F(MAC_STR_DEF_P101)).c_str());
|
||||
|
||||
msgStr = F("MAC Address Not Provided, Populated with Zero Values. ");
|
||||
errorStr += msgStr;
|
||||
@@ -262,7 +262,7 @@ boolean Plugin_101(uint8_t function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
// Save all the Task parameters.
|
||||
SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemplate, sizeof(deviceTemplate));
|
||||
SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<const uint8_t *>(&deviceTemplate), sizeof(deviceTemplate));
|
||||
UDP_PORT_P101 = getFormItemInt(F(FORM_PORT_P101));
|
||||
success = true;
|
||||
break;
|
||||
|
||||
@@ -277,7 +277,7 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
|
||||
|
||||
addFormSubHeader(F("Temperature compensation"));
|
||||
char deviceTemperatureTemplate[40] = {0};
|
||||
LoadCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemperatureTemplate, sizeof(deviceTemperatureTemplate));
|
||||
LoadCustomTaskSettings(event->TaskIndex, reinterpret_cast<uint8_t *>(&deviceTemperatureTemplate), sizeof(deviceTemperatureTemplate));
|
||||
ZERO_TERMINATE(deviceTemperatureTemplate);
|
||||
addFormTextBox(F("Temperature "), F("Plugin_103_temperature_template"), deviceTemperatureTemplate, sizeof(deviceTemperatureTemplate));
|
||||
addFormNote(F("You can use a formulae and idealy refer to a temp sensor (directly, via ESPEasyP2P or MQTT import) ,e.g. '[Pool#Temperature]'. If you don't have a sensor, you could type a fixed value like '25' for '25.5'."));
|
||||
@@ -385,7 +385,7 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
|
||||
safe_strncpy(deviceTemperatureTemplate, tmpString.c_str(), sizeof(deviceTemperatureTemplate) - 1);
|
||||
ZERO_TERMINATE(deviceTemperatureTemplate); // be sure that our string ends with a \0
|
||||
|
||||
addHtmlError(SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemperatureTemplate, sizeof(deviceTemperatureTemplate)));
|
||||
addHtmlError(SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<const uint8_t *>(&deviceTemperatureTemplate), sizeof(deviceTemperatureTemplate)));
|
||||
}
|
||||
|
||||
success = true;
|
||||
@@ -408,7 +408,7 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
|
||||
{
|
||||
// first set the temperature of reading
|
||||
char deviceTemperatureTemplate[40] = {0};
|
||||
LoadCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemperatureTemplate, sizeof(deviceTemperatureTemplate));
|
||||
LoadCustomTaskSettings(event->TaskIndex, reinterpret_cast<uint8_t *>(&deviceTemperatureTemplate), sizeof(deviceTemperatureTemplate));
|
||||
ZERO_TERMINATE(deviceTemperatureTemplate);
|
||||
|
||||
String deviceTemperatureTemplateString(deviceTemperatureTemplate);
|
||||
|
||||
@@ -179,7 +179,7 @@ boolean Plugin_109(byte function, struct EventStruct *event, String& string)
|
||||
const int optionValues1[] = { 1, 2 };
|
||||
addFormSelector(F("Rotation"), F("plugin_109_rotate"), 2, options1, optionValues1, PCONFIG(1));
|
||||
|
||||
LoadCustomTaskSettings(event->TaskIndex, (byte *)&P109_deviceTemplate, sizeof(P109_deviceTemplate));
|
||||
LoadCustomTaskSettings(event->TaskIndex, reinterpret_cast<byte *>(&P109_deviceTemplate), sizeof(P109_deviceTemplate));
|
||||
|
||||
for (byte varNr = 0; varNr < P109_Nlines; varNr++)
|
||||
{
|
||||
@@ -236,7 +236,7 @@ boolean Plugin_109(byte function, struct EventStruct *event, String& string)
|
||||
strncpy(P109_deviceTemplate[varNr], web_server.arg(argName).c_str(), sizeof(P109_deviceTemplate[varNr]));
|
||||
}
|
||||
|
||||
SaveCustomTaskSettings(event->TaskIndex, (byte *)&P109_deviceTemplate, sizeof(P109_deviceTemplate));
|
||||
SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<byte *>(&P109_deviceTemplate), sizeof(P109_deviceTemplate));
|
||||
|
||||
success = true;
|
||||
break;
|
||||
@@ -247,7 +247,7 @@ boolean Plugin_109(byte function, struct EventStruct *event, String& string)
|
||||
P109_lastWiFiState = P109_WIFI_STATE_UNSET;
|
||||
|
||||
// Load the custom settings from flash
|
||||
LoadCustomTaskSettings(event->TaskIndex, (byte *)&P109_deviceTemplate, sizeof(P109_deviceTemplate));
|
||||
LoadCustomTaskSettings(event->TaskIndex, reinterpret_cast<byte *>(&P109_deviceTemplate), sizeof(P109_deviceTemplate));
|
||||
|
||||
// Init the display and turn it on
|
||||
if (P109_display)
|
||||
@@ -300,7 +300,7 @@ boolean Plugin_109(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
if (f)
|
||||
{
|
||||
f.read(((uint8_t *)&UserVar[event->BaseVarIndex] + 0), 16);
|
||||
f.read(reinterpret_cast<uint8_t *>(&UserVar[event->BaseVarIndex]), 16);
|
||||
f.close();
|
||||
}
|
||||
Plugin_109_lastsavetime = millis();
|
||||
@@ -484,7 +484,7 @@ boolean Plugin_109(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
if (f)
|
||||
{
|
||||
f.write(((uint8_t *)&UserVar[event->BaseVarIndex] + 0), 16);
|
||||
f.write(reinterpret_cast<const uint8_t *>(&UserVar[event->BaseVarIndex]), 16);
|
||||
f.close();
|
||||
flashCount();
|
||||
}
|
||||
@@ -516,8 +516,8 @@ boolean Plugin_109(byte function, struct EventStruct *event, String& string)
|
||||
{
|
||||
P109_setHeater(F("1"));
|
||||
Plugin_109_changed = 1;
|
||||
} else if (((((float)atemp - (float)Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0]) >=
|
||||
(float)UserVar[event->BaseVarIndex])) && (UserVar[event->BaseVarIndex + 1] > 0)) {
|
||||
} else if ((((static_cast<float>(atemp) - static_cast<float>(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0])) >=
|
||||
UserVar[event->BaseVarIndex])) && (UserVar[event->BaseVarIndex + 1] > 0)) {
|
||||
P109_setHeater(F("0"));
|
||||
Plugin_109_changed = 1;
|
||||
} else {
|
||||
@@ -758,9 +758,9 @@ void P109_display_timeout() {
|
||||
if (UserVar[Plugin_109_varindex + 2] == 2) {
|
||||
if (Plugin_109_prev_timeout >= (UserVar[Plugin_109_varindex + 3] + 60)) {
|
||||
float timeinmin = UserVar[Plugin_109_varindex + 3] / 60;
|
||||
String thour = toString(((int)(timeinmin / 60)), 0);
|
||||
String thour = toString((static_cast<int>(timeinmin / 60)), 0);
|
||||
thour += F(":");
|
||||
String thour2 = toString(((int)timeinmin % 60), 0);
|
||||
String thour2 = toString((static_cast<int>(timeinmin) % 60), 0);
|
||||
|
||||
if (thour2.length() < 2) {
|
||||
thour += "0" + thour2;
|
||||
|
||||
@@ -46,32 +46,32 @@ String Command_Subnet (struct EventStruct *event, const char* Line)
|
||||
#ifdef HAS_ETHERNET
|
||||
String Command_ETH_Phy_Addr (struct EventStruct *event, const char* Line)
|
||||
{
|
||||
return Command_GetORSetUint8_t(event, F("ETH_Phy_Addr:"), Line, (uint8_t*)&Settings.ETH_Phy_Addr,1);
|
||||
return Command_GetORSetUint8_t(event, F("ETH_Phy_Addr:"), Line, reinterpret_cast<uint8_t*>(&Settings.ETH_Phy_Addr),1);
|
||||
}
|
||||
|
||||
String Command_ETH_Pin_mdc (struct EventStruct *event, const char* Line)
|
||||
{
|
||||
return Command_GetORSetInt8_t(event, F("ETH_Pin_mdc:"), Line, (int8_t*)&Settings.ETH_Pin_mdc,1);
|
||||
return Command_GetORSetInt8_t(event, F("ETH_Pin_mdc:"), Line, reinterpret_cast<int8_t*>(&Settings.ETH_Pin_mdc),1);
|
||||
}
|
||||
|
||||
String Command_ETH_Pin_mdio (struct EventStruct *event, const char* Line)
|
||||
{
|
||||
return Command_GetORSetInt8_t(event, F("ETH_Pin_mdio:"), Line, (int8_t*)&Settings.ETH_Pin_mdio,1);
|
||||
return Command_GetORSetInt8_t(event, F("ETH_Pin_mdio:"), Line, reinterpret_cast<int8_t*>(&Settings.ETH_Pin_mdio),1);
|
||||
}
|
||||
|
||||
String Command_ETH_Pin_power (struct EventStruct *event, const char* Line)
|
||||
{
|
||||
return Command_GetORSetInt8_t(event, F("ETH_Pin_power:"), Line, (int8_t*)&Settings.ETH_Pin_power,1);
|
||||
return Command_GetORSetInt8_t(event, F("ETH_Pin_power:"), Line, reinterpret_cast<int8_t*>(&Settings.ETH_Pin_power),1);
|
||||
}
|
||||
|
||||
String Command_ETH_Phy_Type (struct EventStruct *event, const char* Line)
|
||||
{
|
||||
return Command_GetORSetInt8_t(event, F("ETH_Phy_Type:"), Line, (int8_t*)&Settings.ETH_Phy_Type,1);
|
||||
return Command_GetORSetInt8_t(event, F("ETH_Phy_Type:"), Line, reinterpret_cast<int8_t*>(&Settings.ETH_Phy_Type),1);
|
||||
}
|
||||
|
||||
String Command_ETH_Clock_Mode (struct EventStruct *event, const char* Line)
|
||||
{
|
||||
return Command_GetORSetUint8_t(event, F("ETH_Clock_Mode:"), Line, (uint8_t*)&Settings.ETH_Clock_Mode,1);
|
||||
return Command_GetORSetUint8_t(event, F("ETH_Clock_Mode:"), Line, reinterpret_cast<uint8_t*>(&Settings.ETH_Clock_Mode),1);
|
||||
}
|
||||
|
||||
String Command_ETH_IP (struct EventStruct *event, const char* Line)
|
||||
@@ -96,7 +96,7 @@ String Command_ETH_DNS (struct EventStruct *event, const char* Line)
|
||||
|
||||
String Command_ETH_Wifi_Mode (struct EventStruct *event, const char* Line)
|
||||
{
|
||||
return Command_GetORSetUint8_t(event, F("NetworkMedium:"), Line, (uint8_t*)&Settings.NetworkMedium,1);
|
||||
return Command_GetORSetUint8_t(event, F("NetworkMedium:"), Line, reinterpret_cast<uint8_t*>(&Settings.NetworkMedium),1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -80,9 +80,9 @@ const __FlashStringHelper * Command_Settings_Print(struct EventStruct *event, co
|
||||
|
||||
serialPrintln(F("System Info"));
|
||||
serialPrint(F(" IP Address : ")); serialPrintln(NetworkLocalIP().toString());
|
||||
serialPrint(F(" Build : ")); serialPrintln(String((int)BUILD));
|
||||
serialPrint(F(" Build : ")); serialPrintln(String(static_cast<int>(BUILD)));
|
||||
serialPrint(F(" Name : ")); serialPrintln(Settings.Name);
|
||||
serialPrint(F(" Unit : ")); serialPrintln(String((int)Settings.Unit));
|
||||
serialPrint(F(" Unit : ")); serialPrintln(String(static_cast<int>(Settings.Unit)));
|
||||
serialPrint(F(" WifiSSID : ")); serialPrintln(SecuritySettings.WifiSSID);
|
||||
serialPrint(F(" WifiKey : ")); serialPrintln(SecuritySettings.WifiKey);
|
||||
serialPrint(F(" WifiSSID2 : ")); serialPrintln(SecuritySettings.WifiSSID2);
|
||||
|
||||
@@ -62,7 +62,7 @@ const __FlashStringHelper * Command_UDP_SendToUPD(struct EventStruct *event, con
|
||||
portUDP.write(message.c_str(), message.length());
|
||||
#endif // if defined(ESP8266)
|
||||
#if defined(ESP32)
|
||||
portUDP.write((uint8_t *)message.c_str(), message.length());
|
||||
portUDP.write(reinterpret_cast<const uint8_t *>(message.c_str()), message.length());
|
||||
#endif // if defined(ESP32)
|
||||
portUDP.endPacket();
|
||||
FeedSW_watchdog();
|
||||
|
||||
@@ -11,7 +11,7 @@ struct ControllerCache_struct {
|
||||
~ControllerCache_struct();
|
||||
|
||||
// Write a single sample set to the buffer
|
||||
bool write(uint8_t *data,
|
||||
bool write(const uint8_t *data,
|
||||
unsigned int size);
|
||||
|
||||
// Read a single sample set, either from file or buffer.
|
||||
|
||||
@@ -11,7 +11,7 @@ ControllerCache_struct::~ControllerCache_struct() {
|
||||
}
|
||||
|
||||
// Write a single sample set to the buffer
|
||||
bool ControllerCache_struct::write(uint8_t *data, unsigned int size) {
|
||||
bool ControllerCache_struct::write(const uint8_t *data, unsigned int size) {
|
||||
if (_RTC_cache_handler == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ bool Modbus::begin(uint8_t function, uint8_t ModbusID, uint16_t ModbusRegister,
|
||||
|
||||
for (unsigned int i = 0; i < sizeof(sendBuffer); i++) {
|
||||
LogString += ((unsigned int)(sendBuffer[i]));
|
||||
LogString += (" ");
|
||||
LogString += ' ';
|
||||
}
|
||||
TXRXstate = MODBUS_RECEIVE;
|
||||
|
||||
@@ -118,7 +118,8 @@ bool Modbus::handle() {
|
||||
rxValue = rxValue << 8;
|
||||
char a = ModbusClient->read();
|
||||
rxValue = rxValue | a;
|
||||
LogString += ((int)a); LogString += (" ");
|
||||
LogString += static_cast<int>(a);
|
||||
LogString += ' ';
|
||||
}
|
||||
|
||||
switch (incomingValue) {
|
||||
|
||||
@@ -92,7 +92,7 @@ bool RTC_cache_handler_struct::peek(uint8_t *data, unsigned int size) {
|
||||
}
|
||||
|
||||
// Write a single sample set to the buffer
|
||||
bool RTC_cache_handler_struct::write(uint8_t *data, unsigned int size) {
|
||||
bool RTC_cache_handler_struct::write(const uint8_t *data, unsigned int size) {
|
||||
#ifdef RTC_STRUCT_DEBUG
|
||||
rtc_debug_log(F("write RTC cache data"), size);
|
||||
#endif // ifdef RTC_STRUCT_DEBUG
|
||||
@@ -249,12 +249,12 @@ bool RTC_cache_handler_struct::loadMetaData()
|
||||
// No need to load on ESP32, as the data is already allocated to the RTC memory by the compiler
|
||||
|
||||
#ifdef ESP8266
|
||||
if (!system_rtc_mem_read(RTC_BASE_CACHE, (uint8_t *)&RTC_cache, sizeof(RTC_cache))) {
|
||||
if (!system_rtc_mem_read(RTC_BASE_CACHE, reinterpret_cast<uint8_t *>(&RTC_cache), sizeof(RTC_cache))) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return RTC_cache.checksumMetadata == calc_CRC32((uint8_t *)&RTC_cache, sizeof(RTC_cache) - sizeof(uint32_t));
|
||||
return RTC_cache.checksumMetadata == calc_CRC32(reinterpret_cast<const uint8_t *>(&RTC_cache), sizeof(RTC_cache) - sizeof(uint32_t));
|
||||
}
|
||||
|
||||
bool RTC_cache_handler_struct::loadData()
|
||||
@@ -263,7 +263,7 @@ bool RTC_cache_handler_struct::loadData()
|
||||
|
||||
// No need to load on ESP32, as the data is already allocated to the RTC memory by the compiler
|
||||
#ifdef ESP8266
|
||||
if (!system_rtc_mem_read(RTC_BASE_CACHE + (sizeof(RTC_cache) / 4), (uint8_t *)&RTC_cache_data[0], RTC_CACHE_DATA_SIZE)) {
|
||||
if (!system_rtc_mem_read(RTC_BASE_CACHE + (sizeof(RTC_cache) / 4), reinterpret_cast<uint8_t *>(&RTC_cache_data[0]), RTC_CACHE_DATA_SIZE)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -284,13 +284,13 @@ bool RTC_cache_handler_struct::saveRTCcache() {
|
||||
bool RTC_cache_handler_struct::saveRTCcache(unsigned int startOffset, size_t nrBytes)
|
||||
{
|
||||
RTC_cache.checksumData = getDataChecksum();
|
||||
RTC_cache.checksumMetadata = calc_CRC32((uint8_t *)&RTC_cache, sizeof(RTC_cache) - sizeof(uint32_t));
|
||||
RTC_cache.checksumMetadata = calc_CRC32(reinterpret_cast<const uint8_t *>(&RTC_cache), sizeof(RTC_cache) - sizeof(uint32_t));
|
||||
#ifdef ESP32
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef ESP8266
|
||||
if (!system_rtc_mem_write(RTC_BASE_CACHE, (uint8_t *)&RTC_cache, sizeof(RTC_cache)) || !loadMetaData())
|
||||
if (!system_rtc_mem_write(RTC_BASE_CACHE, reinterpret_cast<const uint8_t *>(&RTC_cache), sizeof(RTC_cache)) || !loadMetaData())
|
||||
{
|
||||
# ifdef RTC_STRUCT_DEBUG
|
||||
addLog(LOG_LEVEL_ERROR, F("RTC : Error while writing cache metadata to RTC"));
|
||||
@@ -302,7 +302,7 @@ bool RTC_cache_handler_struct::saveRTCcache(unsigned int startOffset, size_t nrB
|
||||
if (nrBytes > 0) { // Check needed?
|
||||
const size_t address = RTC_BASE_CACHE + ((sizeof(RTC_cache) + startOffset) / 4);
|
||||
|
||||
if (!system_rtc_mem_write(address, (uint8_t *)&RTC_cache_data[startOffset], nrBytes))
|
||||
if (!system_rtc_mem_write(address, reinterpret_cast<const uint8_t *>(&RTC_cache_data[startOffset]), nrBytes))
|
||||
{
|
||||
# ifdef RTC_STRUCT_DEBUG
|
||||
addLog(LOG_LEVEL_ERROR, F("RTC : Error while writing cache data to RTC"));
|
||||
@@ -329,7 +329,7 @@ uint32_t RTC_cache_handler_struct::getDataChecksum() {
|
||||
*/
|
||||
|
||||
// Only compute the checksum over the number of samples stored.
|
||||
return calc_CRC32((uint8_t *)&RTC_cache_data[0], /*dataLength*/ RTC_CACHE_DATA_SIZE);
|
||||
return calc_CRC32(reinterpret_cast<const uint8_t *>(&RTC_cache_data[0]), /*dataLength*/ RTC_CACHE_DATA_SIZE);
|
||||
}
|
||||
|
||||
void RTC_cache_handler_struct::initRTCcache_data() {
|
||||
|
||||
@@ -40,7 +40,7 @@ struct RTC_cache_handler_struct
|
||||
unsigned int size);
|
||||
|
||||
// Write a single sample set to the buffer
|
||||
bool write(uint8_t *data,
|
||||
bool write(const uint8_t *data,
|
||||
unsigned int size);
|
||||
|
||||
// Mark all content as being processed and empty buffer.
|
||||
|
||||
@@ -89,5 +89,5 @@ size_t UserVarStruct::getNrElements() const
|
||||
|
||||
uint8_t * UserVarStruct::get()
|
||||
{
|
||||
return (uint8_t *)(&_data[0]);
|
||||
return reinterpret_cast<uint8_t *>(&_data[0]);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ int calc_CRC16(const char *ptr, int count)
|
||||
|
||||
while (--count >= 0)
|
||||
{
|
||||
crc = crc ^ (int)*ptr++ << 8;
|
||||
crc = crc ^ static_cast<int>(*ptr++) << 8;
|
||||
char i = 8;
|
||||
|
||||
do
|
||||
|
||||
@@ -476,7 +476,7 @@ bool Dallas_readCounter(const uint8_t ROM[8], float *value, int8_t gpio_pin_rx,
|
||||
}
|
||||
|
||||
uint16_t crc = Dallas_crc16(data, 43, 0);
|
||||
uint8_t *crcBytes = (uint8_t *)&crc;
|
||||
const uint8_t *crcBytes = reinterpret_cast<const uint8_t *>(&crc);
|
||||
uint8_t crcLo = ~data[43];
|
||||
uint8_t crcHi = ~data[44];
|
||||
bool error = (crcLo != crcBytes[0]) || (crcHi != crcBytes[1]);
|
||||
|
||||
@@ -114,7 +114,7 @@ bool saveToRTC()
|
||||
#else // if defined(ESP32)
|
||||
|
||||
START_TIMER
|
||||
if (!system_rtc_mem_write(RTC_BASE_STRUCT, (uint8_t *)&RTC, sizeof(RTC)) || !readFromRTC())
|
||||
if (!system_rtc_mem_write(RTC_BASE_STRUCT, reinterpret_cast<const uint8_t *>(&RTC), sizeof(RTC)) || !readFromRTC())
|
||||
{
|
||||
# ifdef RTC_STRUCT_DEBUG
|
||||
addLog(LOG_LEVEL_ERROR, F("RTC : Error while writing to RTC"));
|
||||
@@ -154,7 +154,7 @@ bool readFromRTC()
|
||||
RTC = RTC_tmp;
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
if (!system_rtc_mem_read(RTC_BASE_STRUCT, (uint8_t *)&RTC, sizeof(RTC))) {
|
||||
if (!system_rtc_mem_read(RTC_BASE_STRUCT, reinterpret_cast<uint8_t *>(&RTC), sizeof(RTC))) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -172,7 +172,7 @@ bool saveUserVarToRTC()
|
||||
for (size_t i = 0; i < UserVar_nrelements; ++i) {
|
||||
UserVar_RTC[i] = UserVar[i];
|
||||
}
|
||||
UserVar_checksum = calc_CRC32((uint8_t *)(&UserVar[0]), UserVar_nrelements * sizeof(float));
|
||||
UserVar_checksum = calc_CRC32(reinterpret_cast<const uint8_t *>(&UserVar[0]), UserVar_nrelements * sizeof(float));
|
||||
return true;
|
||||
#endif
|
||||
|
||||
@@ -182,7 +182,7 @@ bool saveUserVarToRTC()
|
||||
size_t size = UserVar.getNrElements() * sizeof(float);
|
||||
uint32_t sum = calc_CRC32(buffer, size);
|
||||
bool ret = system_rtc_mem_write(RTC_BASE_USERVAR, buffer, size);
|
||||
ret &= system_rtc_mem_write(RTC_BASE_USERVAR + (size >> 2), (uint8_t *)&sum, 4);
|
||||
ret &= system_rtc_mem_write(RTC_BASE_USERVAR + (size >> 2), reinterpret_cast<const uint8_t *>(&sum), 4);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
@@ -195,7 +195,7 @@ bool readUserVarFromRTC()
|
||||
// ESP8266 has the RTC struct stored in memory which we must actively fetch
|
||||
// ESP32 Uses a temp structure which is mapped to the RTC address range.
|
||||
#if defined(ESP32)
|
||||
if (calc_CRC32((uint8_t *)(&UserVar_RTC[0]), UserVar_nrelements * sizeof(float)) == UserVar_checksum) {
|
||||
if (calc_CRC32(reinterpret_cast<const uint8_t *>(&UserVar_RTC[0]), UserVar_nrelements * sizeof(float)) == UserVar_checksum) {
|
||||
for (size_t i = 0; i < UserVar_nrelements; ++i) {
|
||||
UserVar[i] = UserVar_RTC[i];
|
||||
}
|
||||
@@ -211,7 +211,7 @@ bool readUserVarFromRTC()
|
||||
bool ret = system_rtc_mem_read(RTC_BASE_USERVAR, buffer, size);
|
||||
uint32_t sumRAM = calc_CRC32(buffer, size);
|
||||
uint32_t sumRTC = 0;
|
||||
ret &= system_rtc_mem_read(RTC_BASE_USERVAR + (size >> 2), (uint8_t *)&sumRTC, 4);
|
||||
ret &= system_rtc_mem_read(RTC_BASE_USERVAR + (size >> 2), reinterpret_cast<uint8_t *>(&sumRTC), 4);
|
||||
|
||||
if (!ret || (sumRTC != sumRAM))
|
||||
{
|
||||
|
||||
@@ -387,7 +387,7 @@ String SaveSettings()
|
||||
uint8_t tmp_md5[16] = { 0 };
|
||||
memcpy( Settings.ProgmemMd5, CRCValues.runTimeMD5, 16);
|
||||
md5.begin();
|
||||
md5.add((uint8_t *)&Settings, sizeof(Settings)-16);
|
||||
md5.add(reinterpret_cast<const uint8_t *>(&Settings), sizeof(Settings)-16);
|
||||
md5.calculate();
|
||||
md5.getBytes(tmp_md5);
|
||||
if (memcmp(tmp_md5, Settings.md5, 16) != 0) {
|
||||
@@ -395,7 +395,7 @@ String SaveSettings()
|
||||
memcpy(Settings.md5, tmp_md5, 16);
|
||||
*/
|
||||
Settings.validate();
|
||||
err = SaveToFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, (uint8_t *)&Settings, sizeof(Settings));
|
||||
err = SaveToFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, reinterpret_cast<const uint8_t *>(&Settings), sizeof(Settings));
|
||||
}
|
||||
|
||||
if (err.length()) {
|
||||
@@ -420,14 +420,14 @@ String SaveSecuritySettings() {
|
||||
SecuritySettings.validate();
|
||||
memcpy(SecuritySettings.ProgmemMd5, CRCValues.runTimeMD5, 16);
|
||||
md5.begin();
|
||||
md5.add((uint8_t *)&SecuritySettings, sizeof(SecuritySettings) - 16);
|
||||
md5.add(reinterpret_cast<uint8_t *>(&SecuritySettings), static_cast<uint16_t>(sizeof(SecuritySettings) - 16));
|
||||
md5.calculate();
|
||||
md5.getBytes(tmp_md5);
|
||||
|
||||
if (memcmp(tmp_md5, SecuritySettings.md5, 16) != 0) {
|
||||
// Settings have changed, save to file.
|
||||
memcpy(SecuritySettings.md5, tmp_md5, 16);
|
||||
err = SaveToFile((char *)FILE_SECURITY, 0, (uint8_t *)&SecuritySettings, sizeof(SecuritySettings));
|
||||
err = SaveToFile((char *)FILE_SECURITY, 0, reinterpret_cast<const uint8_t *>(&SecuritySettings), sizeof(SecuritySettings));
|
||||
|
||||
if (WifiIsAP(WiFi.getMode())) {
|
||||
// Security settings are saved, may be update of WiFi settings or hostname.
|
||||
@@ -471,7 +471,7 @@ String LoadSettings()
|
||||
uint8_t calculatedMd5[16];
|
||||
MD5Builder md5;
|
||||
|
||||
err = LoadFromFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, (uint8_t *)&Settings, sizeof(SettingsStruct));
|
||||
err = LoadFromFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, reinterpret_cast<uint8_t *>(&Settings), sizeof(SettingsStruct));
|
||||
|
||||
if (err.length()) {
|
||||
return err;
|
||||
@@ -483,7 +483,7 @@ String LoadSettings()
|
||||
/*
|
||||
if (Settings.StructSize > 16) {
|
||||
md5.begin();
|
||||
md5.add((uint8_t *)&Settings, Settings.StructSize -16);
|
||||
md5.add(reinterpret_cast<const uint8_t *>(&Settings), Settings.StructSize -16);
|
||||
md5.calculate();
|
||||
md5.getBytes(calculatedMd5);
|
||||
}
|
||||
@@ -497,9 +497,9 @@ String LoadSettings()
|
||||
}
|
||||
*/
|
||||
|
||||
err = LoadFromFile((char *)FILE_SECURITY, 0, (uint8_t *)&SecuritySettings, sizeof(SecurityStruct));
|
||||
err = LoadFromFile((char *)FILE_SECURITY, 0, reinterpret_cast<uint8_t *>(&SecuritySettings), sizeof(SecurityStruct));
|
||||
md5.begin();
|
||||
md5.add((uint8_t *)&SecuritySettings, sizeof(SecuritySettings) - 16);
|
||||
md5.add(reinterpret_cast< uint8_t *>(&SecuritySettings), sizeof(SecuritySettings) - 16);
|
||||
md5.calculate();
|
||||
md5.getBytes(calculatedMd5);
|
||||
|
||||
@@ -609,7 +609,7 @@ String LoadStringArray(SettingsType::Enum settingsType, int index, String string
|
||||
// FIXME TD-er: For now stack allocated, may need to be heap allocated?
|
||||
if (maxStringLength >= bufferSize) { return F("Max 128 chars allowed"); }
|
||||
|
||||
char buffer[bufferSize];
|
||||
char buffer[bufferSize] = {0};
|
||||
|
||||
String result;
|
||||
uint32_t readPos = 0;
|
||||
@@ -623,7 +623,7 @@ String LoadStringArray(SettingsType::Enum settingsType, int index, String string
|
||||
const uint32_t readSize = std::min(bufferSize, max_size - readPos);
|
||||
result += LoadFromFile(settingsType,
|
||||
index,
|
||||
(uint8_t *)&buffer,
|
||||
reinterpret_cast<uint8_t *>(&buffer),
|
||||
readSize,
|
||||
readPos);
|
||||
|
||||
@@ -764,7 +764,7 @@ String SaveTaskSettings(taskIndex_t TaskIndex)
|
||||
}
|
||||
String err = SaveToFile(SettingsType::Enum::TaskSettings_Type,
|
||||
TaskIndex,
|
||||
(uint8_t *)&ExtraTaskSettings,
|
||||
reinterpret_cast<const uint8_t *>(&ExtraTaskSettings),
|
||||
sizeof(struct ExtraTaskSettingsStruct));
|
||||
|
||||
if (err.isEmpty()) {
|
||||
@@ -791,7 +791,7 @@ String LoadTaskSettings(taskIndex_t TaskIndex)
|
||||
|
||||
START_TIMER
|
||||
ExtraTaskSettings.clear();
|
||||
const String result = LoadFromFile(SettingsType::Enum::TaskSettings_Type, TaskIndex, (uint8_t *)&ExtraTaskSettings, sizeof(struct ExtraTaskSettingsStruct));
|
||||
const String result = LoadFromFile(SettingsType::Enum::TaskSettings_Type, TaskIndex, reinterpret_cast<uint8_t *>(&ExtraTaskSettings), sizeof(struct ExtraTaskSettingsStruct));
|
||||
|
||||
// After loading, some settings may need patching.
|
||||
ExtraTaskSettings.TaskIndex = TaskIndex; // Needed when an empty task was requested
|
||||
@@ -823,7 +823,7 @@ String LoadTaskSettings(taskIndex_t TaskIndex)
|
||||
/********************************************************************************************\
|
||||
Save Custom Task settings to file system
|
||||
\*********************************************************************************************/
|
||||
String SaveCustomTaskSettings(taskIndex_t TaskIndex, uint8_t *memAddress, int datasize)
|
||||
String SaveCustomTaskSettings(taskIndex_t TaskIndex, const uint8_t *memAddress, int datasize)
|
||||
{
|
||||
#ifndef BUILD_NO_RAM_TRACKER
|
||||
checkRAM(F("SaveCustomTaskSettings"));
|
||||
@@ -903,7 +903,7 @@ String SaveControllerSettings(controllerIndex_t ControllerIndex, ControllerSetti
|
||||
#endif
|
||||
controller_settings.validate(); // Make sure the saved controller settings have proper values.
|
||||
return SaveToFile(SettingsType::Enum::ControllerSettings_Type, ControllerIndex,
|
||||
(uint8_t *)&controller_settings, sizeof(controller_settings));
|
||||
reinterpret_cast<const uint8_t *>(&controller_settings), sizeof(controller_settings));
|
||||
}
|
||||
|
||||
/********************************************************************************************\
|
||||
@@ -915,7 +915,7 @@ String LoadControllerSettings(controllerIndex_t ControllerIndex, ControllerSetti
|
||||
#endif
|
||||
String result =
|
||||
LoadFromFile(SettingsType::Enum::ControllerSettings_Type, ControllerIndex,
|
||||
(uint8_t *)&controller_settings, sizeof(controller_settings));
|
||||
reinterpret_cast<uint8_t *>(&controller_settings), sizeof(controller_settings));
|
||||
controller_settings.validate(); // Make sure the loaded controller settings have proper values.
|
||||
return result;
|
||||
}
|
||||
@@ -936,7 +936,7 @@ String ClearCustomControllerSettings(controllerIndex_t ControllerIndex)
|
||||
/********************************************************************************************\
|
||||
Save Custom Controller settings to file system
|
||||
\*********************************************************************************************/
|
||||
String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *memAddress, int datasize)
|
||||
String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, const uint8_t *memAddress, int datasize)
|
||||
{
|
||||
#ifndef BUILD_NO_RAM_TRACKER
|
||||
checkRAM(F("SaveCustomControllerSettings"));
|
||||
@@ -958,7 +958,7 @@ String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *
|
||||
/********************************************************************************************\
|
||||
Save Controller settings to file system
|
||||
\*********************************************************************************************/
|
||||
String SaveNotificationSettings(int NotificationIndex, uint8_t *memAddress, int datasize)
|
||||
String SaveNotificationSettings(int NotificationIndex, const uint8_t *memAddress, int datasize)
|
||||
{
|
||||
#ifndef BUILD_NO_RAM_TRACKER
|
||||
checkRAM(F("SaveNotificationSettings"));
|
||||
@@ -1271,11 +1271,11 @@ String LoadFromFile(SettingsType::Enum settingsType, int index, uint8_t *memAddr
|
||||
return LoadFromFile(settingsType, index, memAddress, datasize, 0);
|
||||
}
|
||||
|
||||
String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize) {
|
||||
String SaveToFile(SettingsType::Enum settingsType, int index, const uint8_t *memAddress, int datasize) {
|
||||
return SaveToFile(settingsType, index, memAddress, datasize, 0);
|
||||
}
|
||||
|
||||
String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize, int posInBlock) {
|
||||
String SaveToFile(SettingsType::Enum settingsType, int index, const uint8_t *memAddress, int datasize, int posInBlock) {
|
||||
bool read = false;
|
||||
int offset, max_size;
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ String LoadTaskSettings(taskIndex_t TaskIndex);
|
||||
/********************************************************************************************\
|
||||
Save Custom Task settings to file system
|
||||
\*********************************************************************************************/
|
||||
String SaveCustomTaskSettings(taskIndex_t TaskIndex, uint8_t *memAddress, int datasize);
|
||||
String SaveCustomTaskSettings(taskIndex_t TaskIndex, const uint8_t *memAddress, int datasize);
|
||||
|
||||
/********************************************************************************************\
|
||||
Save array of Strings to Custom Task settings
|
||||
@@ -152,7 +152,7 @@ String ClearCustomControllerSettings(controllerIndex_t ControllerIndex);
|
||||
/********************************************************************************************\
|
||||
Save Custom Controller settings to file system
|
||||
\*********************************************************************************************/
|
||||
String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *memAddress, int datasize);
|
||||
String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, const uint8_t *memAddress, int datasize);
|
||||
|
||||
/********************************************************************************************\
|
||||
Load Custom Controller settings to file system
|
||||
@@ -162,7 +162,7 @@ String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *
|
||||
/********************************************************************************************\
|
||||
Save Controller settings to file system
|
||||
\*********************************************************************************************/
|
||||
String SaveNotificationSettings(int NotificationIndex, uint8_t *memAddress, int datasize);
|
||||
String SaveNotificationSettings(int NotificationIndex, const uint8_t *memAddress, int datasize);
|
||||
|
||||
|
||||
/********************************************************************************************\
|
||||
@@ -209,9 +209,9 @@ String LoadFromFile(SettingsType::Enum settingsType, int index, uint8_t *memAddr
|
||||
|
||||
String LoadFromFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize);
|
||||
|
||||
String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize);
|
||||
String SaveToFile(SettingsType::Enum settingsType, int index, const uint8_t *memAddress, int datasize);
|
||||
|
||||
String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize, int posInBlock);
|
||||
String SaveToFile(SettingsType::Enum settingsType, int index, const uint8_t *memAddress, int datasize, int posInBlock);
|
||||
|
||||
String ClearInFile(SettingsType::Enum settingsType, int index);
|
||||
|
||||
|
||||
@@ -689,10 +689,10 @@ void ESPEasy_time::calcSunRiseAndSet() {
|
||||
float rise = 12 - da - eqt;
|
||||
float set = 12 + da - eqt;
|
||||
|
||||
tsRise.tm_hour = (int)rise;
|
||||
tsRise.tm_min = (rise - (int)rise) * 60.0f;
|
||||
tsSet.tm_hour = (int)set;
|
||||
tsSet.tm_min = (set - (int)set) * 60.0f;
|
||||
tsRise.tm_hour = rise;
|
||||
tsRise.tm_min = (rise - static_cast<int>(rise)) * 60.0f;
|
||||
tsSet.tm_hour = set;
|
||||
tsSet.tm_min = (set - static_cast<int>(set)) * 60.0f;
|
||||
tsRise.tm_mday = tsSet.tm_mday = tm.tm_mday;
|
||||
tsRise.tm_mon = tsSet.tm_mon = tm.tm_mon;
|
||||
tsRise.tm_year = tsSet.tm_year = tm.tm_year;
|
||||
|
||||
@@ -681,7 +681,9 @@ String getDeviceModelString(DeviceModel model) {
|
||||
}
|
||||
|
||||
bool modelMatchingFlashSize(DeviceModel model) {
|
||||
uint32_t size_MB = getFlashRealSizeInBytes() >> 20;
|
||||
#if defined(ESP8266) || (defined(ESP32) && defined(HAS_ETHERNET))
|
||||
const uint32_t size_MB = getFlashRealSizeInBytes() >> 20;
|
||||
#endif
|
||||
|
||||
// TD-er: This also checks for ESP8266/ESP8285/ESP32
|
||||
switch (model) {
|
||||
|
||||
@@ -157,7 +157,7 @@ void dump(uint32_t addr) { // Seems already included in core 2.4 ...
|
||||
serialPrint(String(pgm_read_byte(a), HEX));
|
||||
serialPrint(" ");
|
||||
}
|
||||
serialPrintln("");
|
||||
serialPrintln();
|
||||
}
|
||||
|
||||
#endif // if defined(ARDUINO_ESP8266_RELEASE_2_3_0)
|
||||
@@ -187,7 +187,7 @@ void dump(uint32_t addr) { // Seems already included in core 2.4 ...
|
||||
calcBuffer[buf] = pgm_read_dword((uint32_t*)i+buf); // read 4 bytes
|
||||
CRCValues.numberOfCRCBytes+=sizeof(calcBuffer[0]);
|
||||
}
|
||||
md5.add((uint8_t *)&calcBuffer[0],(*ptrEnd-i)<sizeof(calcBuffer) ? (*ptrEnd-i):sizeof(calcBuffer) ); // add buffer to md5.
|
||||
md5.add(reinterpret_cast<const uint8_t *>(&calcBuffer[0]),(*ptrEnd-i)<sizeof(calcBuffer) ? (*ptrEnd-i):sizeof(calcBuffer) ); // add buffer to md5.
|
||||
At the end not the whole buffer. md5 ptr to data in ram.
|
||||
}
|
||||
}
|
||||
@@ -335,7 +335,7 @@ void HSV2RGB(float H, float S, float I, int rgb[3]) {
|
||||
int r, g, b;
|
||||
|
||||
H = fmod(H, 360); // cycle H around to 0-360 degrees
|
||||
H = 3.14159f * H / (float)180; // Convert to radians.
|
||||
H = 3.14159f * H / static_cast<float>(180); // Convert to radians.
|
||||
S = S / 100;
|
||||
S = S > 0 ? (S < 1 ? S : 1) : 0; // clamp S and I to interval [0,1]
|
||||
I = I / 100;
|
||||
@@ -370,7 +370,7 @@ void HSV2RGBW(float H, float S, float I, int rgbw[4]) {
|
||||
float cos_h, cos_1047_h;
|
||||
|
||||
H = fmod(H, 360); // cycle H around to 0-360 degrees
|
||||
H = 3.14159f * H / (float)180; // Convert to radians.
|
||||
H = 3.14159f * H / static_cast<float>(180); // Convert to radians.
|
||||
S = S / 100;
|
||||
S = S > 0 ? (S < 1 ? S : 1) : 0; // clamp S and I to interval [0,1]
|
||||
I = I / 100;
|
||||
|
||||
@@ -87,7 +87,7 @@ void dump(uint32_t addr);
|
||||
calcBuffer[buf] = pgm_read_dword((uint32_t*)i+buf); // read 4 bytes
|
||||
CRCValues.numberOfCRCBytes+=sizeof(calcBuffer[0]);
|
||||
}
|
||||
md5.add((uint8_t *)&calcBuffer[0],(*ptrEnd-i)<sizeof(calcBuffer) ? (*ptrEnd-i):sizeof(calcBuffer) ); // add buffer to md5.
|
||||
md5.add(reinterpret_cast<const uint8_t *>(&calcBuffer[0]),(*ptrEnd-i)<sizeof(calcBuffer) ? (*ptrEnd-i):sizeof(calcBuffer) ); // add buffer to md5.
|
||||
At the end not the whole buffer. md5 ptr to data in ram.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,11 +404,11 @@ void ModbusRTU_struct::logModbusException(uint8_t value) {
|
||||
String hexvalue(buffer[i], HEX);
|
||||
hexvalue.toUpperCase();
|
||||
log += hexvalue;
|
||||
log += F(" ");
|
||||
log += ' ';
|
||||
}
|
||||
log += F("(");
|
||||
log += '(';
|
||||
log += length;
|
||||
log += F(")");
|
||||
log += ')';
|
||||
return log;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -115,11 +115,11 @@ struct ModbusRTU_struct {
|
||||
String hexvalue(buffer[i], HEX);
|
||||
hexvalue.toUpperCase();
|
||||
log += hexvalue;
|
||||
log += F(" ");
|
||||
log += ' ';
|
||||
}
|
||||
log += F("(");
|
||||
log += '(';
|
||||
log += length;
|
||||
log += F(")");
|
||||
log += ')';
|
||||
return log;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -109,7 +109,7 @@ void syslog(uint8_t logLevel, const char *message)
|
||||
portUDP.write(header.c_str(), header.length());
|
||||
#endif // ifdef ESP8266
|
||||
#ifdef ESP32
|
||||
portUDP.write((uint8_t *)header.c_str(), header.length());
|
||||
portUDP.write(reinterpret_cast<const uint8_t *>(header.c_str()), header.length());
|
||||
#endif // ifdef ESP32
|
||||
}
|
||||
const char *c = message;
|
||||
@@ -221,7 +221,7 @@ void checkUDP()
|
||||
int len = portUDP.read(&packetBuffer[0], packetSize);
|
||||
|
||||
if (len >= 2) {
|
||||
if (reinterpret_cast<unsigned char&>(packetBuffer[0]) != 255)
|
||||
if (static_cast<uint8_t>(packetBuffer[0]) != 255)
|
||||
{
|
||||
packetBuffer[len] = 0;
|
||||
addLog(LOG_LEVEL_DEBUG, &packetBuffer[0]);
|
||||
@@ -500,7 +500,7 @@ void sendSysInfoUDP(uint8_t repeats)
|
||||
data[12] = Settings.Unit;
|
||||
data[13] = lowByte(Settings.Build);
|
||||
data[14] = highByte(Settings.Build);
|
||||
memcpy((uint8_t *)data + 15, Settings.Name, 25);
|
||||
memcpy(reinterpret_cast<uint8_t *>(data) + 15, Settings.Name, 25);
|
||||
data[40] = NODE_TYPE_ID;
|
||||
data[41] = lowByte(Settings.WebserverPort);
|
||||
data[42] = highByte(Settings.WebserverPort);
|
||||
@@ -1247,7 +1247,7 @@ bool downloadFile(const String& url, String file_save, const String& user, const
|
||||
// read all data from server
|
||||
while (http.connected() && (len > 0 || len == -1)) {
|
||||
// read up to 128 uint8_t
|
||||
size_t c = stream->readBytes(buff, std::min((size_t)len, sizeof(buff)));
|
||||
size_t c = stream->readBytes(buff, std::min(static_cast<size_t>(len), sizeof(buff)));
|
||||
|
||||
if (c > 0) {
|
||||
timeout = millis() + 2000;
|
||||
|
||||
@@ -347,22 +347,22 @@ void transformValue(
|
||||
|
||||
if (isDigit(tempValueFormat[1]))
|
||||
{
|
||||
x = (int)tempValueFormat[1] - '0';
|
||||
x = static_cast<int>(tempValueFormat[1]) - '0';
|
||||
}
|
||||
break;
|
||||
case 3: // D.y
|
||||
|
||||
if ((tempValueFormat[1] == '.') && isDigit(tempValueFormat[2]))
|
||||
{
|
||||
y = (int)tempValueFormat[2] - '0';
|
||||
y = static_cast<int>(tempValueFormat[2]) - '0';
|
||||
}
|
||||
break;
|
||||
case 4: // Dx.y
|
||||
|
||||
if (isDigit(tempValueFormat[1]) && (tempValueFormat[2] == '.') && isDigit(tempValueFormat[3]))
|
||||
{
|
||||
x = (int)tempValueFormat[1] - '0';
|
||||
y = (int)tempValueFormat[3] - '0';
|
||||
x = static_cast<int>(tempValueFormat[1]) - '0';
|
||||
y = static_cast<int>(tempValueFormat[3]) - '0';
|
||||
}
|
||||
break;
|
||||
case 1: // D
|
||||
@@ -383,10 +383,10 @@ void transformValue(
|
||||
break;
|
||||
}
|
||||
case 'F': // FLOOR (round down)
|
||||
value = (int)floorf(valFloat);
|
||||
value = static_cast<int>(floorf(valFloat));
|
||||
break;
|
||||
case 'E': // CEILING (round up)
|
||||
value = (int)ceilf(valFloat);
|
||||
value = static_cast<int>(ceilf(valFloat));
|
||||
break;
|
||||
default:
|
||||
value = F("ERR");
|
||||
@@ -436,7 +436,7 @@ void transformValue(
|
||||
{
|
||||
if (isDigit(valueJust[1])) // Check n where n is between 0 and 9
|
||||
{
|
||||
value = value.substring(0, (int)valueJust[1] - '0');
|
||||
value = value.substring(0, static_cast<int>(valueJust[1]) - '0');
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -446,7 +446,7 @@ void transformValue(
|
||||
{
|
||||
if (isDigit(valueJust[1])) // Check n where n is between 0 and 9
|
||||
{
|
||||
value = value.substring(std::max(0, (int)value.length() - ((int)valueJust[1] - '0')));
|
||||
value = value.substring(std::max(0, static_cast<int>(value.length()) - (static_cast<int>(valueJust[1]) - '0')));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -456,8 +456,8 @@ void transformValue(
|
||||
{
|
||||
if (isDigit(valueJust[1]) && (valueJust[2] == '.') && isDigit(valueJust[3]) && (valueJust[1] > '0') && (valueJust[3] > '0'))
|
||||
{
|
||||
value = value.substring(std::min((int)value.length(), (int)valueJust[1] - '0' - 1),
|
||||
(int)valueJust[1] - '0' - 1 + (int)valueJust[3] - '0');
|
||||
value = value.substring(std::min(static_cast<int>(value.length()), static_cast<int>(valueJust[1]) - '0' - 1),
|
||||
static_cast<int>(valueJust[1]) - '0' - 1 + static_cast<int>(valueJust[3]) - '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -313,7 +313,7 @@ String getValue(LabelType::Enum label) {
|
||||
case LabelType::SYSTEM_LIBRARIES: return getSystemLibraryString();
|
||||
case LabelType::PLUGIN_COUNT: return String(deviceCount + 1);
|
||||
case LabelType::PLUGIN_DESCRIPTION: return getPluginDescriptionString();
|
||||
case LabelType::BUILD_TIME: return String(get_build_date()) + F(" ") + get_build_time();
|
||||
case LabelType::BUILD_TIME: return String(get_build_date()) + ' ' + get_build_time();
|
||||
case LabelType::BINARY_FILENAME: return get_binary_filename();
|
||||
case LabelType::BUILD_PLATFORM: return get_build_platform();
|
||||
case LabelType::GIT_HEAD: return get_git_head();
|
||||
|
||||
@@ -93,7 +93,7 @@ void SystemVariables::parseSystemVariables(String& s, boolean useURLencode)
|
||||
case BSSID: value = String((WiFiEventData.WiFiDisconnected()) ? MAC_address().toString() : WiFi.BSSIDstr()); break;
|
||||
case CR: value = '\r'; break;
|
||||
case IP: value = getValue(LabelType::IP_ADDRESS); break;
|
||||
case IP4: value = String( (int) NetworkLocalIP()[3] ); break; // 4th IP octet
|
||||
case IP4: value = String( static_cast<int>(NetworkLocalIP()[3]) ); break; // 4th IP octet
|
||||
case SUBNET: value = getValue(LabelType::IP_SUBNET); break;
|
||||
case DNS: value = getValue(LabelType::DNS); break;
|
||||
case DNS_1: value = getValue(LabelType::DNS_1); break;
|
||||
|
||||
@@ -60,7 +60,7 @@ void P012_data_struct::lcdWrite(const String& text, uint8_t col, uint8_t row) {
|
||||
lcd.setCursor(col, row);
|
||||
|
||||
for (uint8_t i = col; i < Plugin_012_cols; i++) {
|
||||
lcd.print(" ");
|
||||
lcd.print(' ');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ void P016_data_struct::convertCommandLines(struct EventStruct *event) {
|
||||
CommandLinesV1.push_back(tCommandLines());
|
||||
LoadFromFile(SettingsType::Enum::CustomTaskSettings_Type,
|
||||
event->TaskIndex,
|
||||
(uint8_t *)&(CommandLinesV1[i]),
|
||||
reinterpret_cast<uint8_t *>(&(CommandLinesV1[i])),
|
||||
sizeof(tCommandLines),
|
||||
loadOffset);
|
||||
loadOffset += sizeof(tCommandLines);
|
||||
@@ -146,7 +146,7 @@ void P016_data_struct::loadCommandLines(struct EventStruct *event) {
|
||||
CommandLines.push_back(tCommandLinesV2());
|
||||
LoadFromFile(SettingsType::Enum::CustomTaskSettings_Type,
|
||||
event->TaskIndex,
|
||||
(uint8_t *)&(CommandLines[i]),
|
||||
reinterpret_cast<uint8_t *>(&(CommandLines[i])),
|
||||
sizeof(tCommandLinesV2),
|
||||
loadOffset);
|
||||
loadOffset += sizeof(tCommandLinesV2);
|
||||
@@ -164,7 +164,7 @@ void P016_data_struct::saveCommandLines(struct EventStruct *event) {
|
||||
for (uint8_t i = 0; i < P16_Nlines; i++) {
|
||||
SaveToFile(SettingsType::Enum::CustomTaskSettings_Type,
|
||||
event->TaskIndex,
|
||||
(uint8_t *)&(CommandLines[i]),
|
||||
reinterpret_cast<const uint8_t *>(&(CommandLines[i])),
|
||||
sizeof(tCommandLinesV2),
|
||||
saveOffset);
|
||||
saveOffset += sizeof(tCommandLinesV2);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
# include "../Helpers/Misc.h"
|
||||
|
||||
# define P020_RX_WAIT PCONFIG(4)
|
||||
# define P020_RX_BUFFER PCONFIG(7)
|
||||
|
||||
|
||||
P020_Task::P020_Task(taskIndex_t taskIndex) : _taskIndex(taskIndex) {
|
||||
@@ -161,7 +162,7 @@ void P020_Task::handleSerialIn(struct EventStruct *event) {
|
||||
|
||||
do {
|
||||
if (ser2netSerial->available()) {
|
||||
if (serial_buffer.length() >= P020_DATAGRAM_MAX_SIZE) {
|
||||
if (serial_buffer.length() > P020_RX_BUFFER) {
|
||||
addLog(LOG_LEVEL_DEBUG, F("Ser2Net : Error: Buffer overflow, discarded input."));
|
||||
ser2netSerial->read();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# include <ESPeasySerial.h>
|
||||
|
||||
# ifndef PLUGIN_020_DEBUG
|
||||
# define PLUGIN_020_DEBUG false // extra logging in serial out
|
||||
# define PLUGIN_020_DEBUG false // extra logging in serial out
|
||||
# endif // ifndef PLUGIN_020_DEBUG
|
||||
|
||||
# define P020_STATUS_LED 12
|
||||
@@ -23,20 +23,20 @@ struct P020_Task : public PluginTaskData_base {
|
||||
void startServer(uint16_t portnumber);
|
||||
|
||||
void checkServer();
|
||||
|
||||
|
||||
void stopServer();
|
||||
|
||||
|
||||
bool hasClientConnected();
|
||||
|
||||
|
||||
void discardClientIn();
|
||||
|
||||
|
||||
void clearBuffer();
|
||||
|
||||
void serialBegin(const ESPEasySerialPort port,
|
||||
int16_t rxPin,
|
||||
int16_t txPin,
|
||||
unsigned long baud,
|
||||
uint8_t config);
|
||||
uint8_t config);
|
||||
|
||||
void serialEnd();
|
||||
|
||||
|
||||
@@ -127,8 +127,8 @@ bool P028_data_struct::updateMeasurements(float tempOffset, unsigned long task_i
|
||||
last_measurement = current_time;
|
||||
state = BMx_New_values;
|
||||
last_temp_val = readTemperature();
|
||||
last_press_val = ((float)readPressure()) / 100.0f;
|
||||
last_hum_val = ((float)readHumidity());
|
||||
last_press_val = readPressure() / 100.0f;
|
||||
last_hum_val = readHumidity();
|
||||
|
||||
|
||||
String log;
|
||||
@@ -366,7 +366,7 @@ float P028_data_struct::readPressure()
|
||||
var2 = (((int64_t)calib.dig_P8) * p) >> 19;
|
||||
|
||||
p = ((p + var1 + var2) >> 8) + (((int64_t)calib.dig_P7) << 4);
|
||||
return (float)p / 256;
|
||||
return static_cast<float>(p) / 256;
|
||||
}
|
||||
|
||||
float P028_data_struct::readHumidity()
|
||||
|
||||
@@ -171,7 +171,7 @@ void P036_data_struct::loadDisplayLines(taskIndex_t taskIndex, uint8_t LoadVersi
|
||||
}
|
||||
else {
|
||||
// read data of version 1 (beginning from 22.11.2019)
|
||||
LoadCustomTaskSettings(taskIndex, (uint8_t *)&(DisplayLinesV1), sizeof(DisplayLinesV1));
|
||||
LoadCustomTaskSettings(taskIndex, reinterpret_cast<uint8_t *>(&DisplayLinesV1), sizeof(DisplayLinesV1));
|
||||
|
||||
for (int i = 0; i < P36_Nlines; ++i) {
|
||||
DisplayLinesV1[i].Content[P36_NcharsV1 - 1] = 0; // Terminate in case of uninitalized data
|
||||
@@ -582,7 +582,7 @@ uint8_t P036_data_struct::display_scroll(ePageScrollSpeed lscrollspeed, int lTas
|
||||
String log;
|
||||
log.reserve(128); // estimated
|
||||
log = F("Start Scrolling: Speed: ");
|
||||
log += ((int) lscrollspeed);
|
||||
log += static_cast<int>(lscrollspeed);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
# endif // PLUGIN_036_DEBUG
|
||||
|
||||
@@ -597,7 +597,7 @@ uint8_t P036_data_struct::display_scroll(ePageScrollSpeed lscrollspeed, int lTas
|
||||
} else {
|
||||
iPageScrollTime = (P36_MaxDisplayWidth / (P36_PageScrollPix * static_cast<int>(lscrollspeed))) * P36_PageScrollTick;
|
||||
}
|
||||
int iScrollTime = (float)(lTaskTimer * 1000 - iPageScrollTime - 2 * P36_WaitScrollLines * 100) / 100; // scrollTime in ms
|
||||
int iScrollTime = static_cast<float>(lTaskTimer * 1000 - iPageScrollTime - 2 * P36_WaitScrollLines * 100) / 100; // scrollTime in ms
|
||||
|
||||
# ifdef PLUGIN_036_DEBUG
|
||||
log = F("PageScrollTime: ");
|
||||
@@ -625,8 +625,8 @@ uint8_t P036_data_struct::display_scroll(ePageScrollSpeed lscrollspeed, int lTas
|
||||
if (PixLengthLineIn > 255) {
|
||||
// shorten string because OLED controller can not handle such long strings
|
||||
int strlen = ScrollingPages.LineIn[j].length();
|
||||
float fAvgPixPerChar = ((float)PixLengthLineIn) / strlen;
|
||||
iCharToRemove = ceil(((float)(PixLengthLineIn - 255)) / fAvgPixPerChar);
|
||||
float fAvgPixPerChar = static_cast<float>(PixLengthLineIn) / strlen;
|
||||
iCharToRemove = ceil((static_cast<float>(PixLengthLineIn - 255)) / fAvgPixPerChar);
|
||||
ScrollingPages.LineIn[j] = ScrollingPages.LineIn[j].substring(0, strlen - iCharToRemove);
|
||||
PixLengthLineIn = display->getStringWidth(ScrollingPages.LineIn[j]);
|
||||
}
|
||||
@@ -634,8 +634,8 @@ uint8_t P036_data_struct::display_scroll(ePageScrollSpeed lscrollspeed, int lTas
|
||||
if (PixLengthLineOut > 255) {
|
||||
// shorten string because OLED controller can not handle such long strings
|
||||
int strlen = ScrollingPages.LineOut[j].length();
|
||||
float fAvgPixPerChar = ((float)PixLengthLineOut) / strlen;
|
||||
iCharToRemove = ceil(((float)(PixLengthLineOut - 255)) / fAvgPixPerChar);
|
||||
float fAvgPixPerChar = static_cast<float>(PixLengthLineOut) / strlen;
|
||||
iCharToRemove = ceil((static_cast<float>(PixLengthLineOut - 255)) / fAvgPixPerChar);
|
||||
ScrollingPages.LineOut[j] = ScrollingPages.LineOut[j].substring(0, strlen - iCharToRemove);
|
||||
PixLengthLineOut = display->getStringWidth(ScrollingPages.LineOut[j]);
|
||||
}
|
||||
@@ -652,10 +652,10 @@ uint8_t P036_data_struct::display_scroll(ePageScrollSpeed lscrollspeed, int lTas
|
||||
ScrollingLines.Line[j].LineContent = ScrollingPages.LineIn[j];
|
||||
ScrollingLines.Line[j].Width = PixLengthLineIn; // while page scrolling this line is left aligned
|
||||
ScrollingLines.Line[j].CurrentLeft = getDisplaySizeSettings(disp_resolution).PixLeft;
|
||||
ScrollingLines.Line[j].fPixSum = (float)getDisplaySizeSettings(disp_resolution).PixLeft;
|
||||
ScrollingLines.Line[j].fPixSum = getDisplaySizeSettings(disp_resolution).PixLeft;
|
||||
|
||||
// pix change per scrolling line tick
|
||||
ScrollingLines.Line[j].dPix = ((float)(PixLengthLineIn - getDisplaySizeSettings(disp_resolution).Width)) / iScrollTime;
|
||||
ScrollingLines.Line[j].dPix = (static_cast<float>(PixLengthLineIn - getDisplaySizeSettings(disp_resolution).Width)) / iScrollTime;
|
||||
|
||||
# ifdef PLUGIN_036_DEBUG
|
||||
log = String(F("Line: ")) + String(j + 1);
|
||||
@@ -674,18 +674,18 @@ uint8_t P036_data_struct::display_scroll(ePageScrollSpeed lscrollspeed, int lTas
|
||||
# ifdef PLUGIN_036_DEBUG
|
||||
String LineInStr = ScrollingPages.LineIn[j];
|
||||
# endif // PLUGIN_036_DEBUG
|
||||
float fAvgPixPerChar = ((float)PixLengthLineIn) / strlen;
|
||||
float fAvgPixPerChar = static_cast<float>(PixLengthLineIn) / strlen;
|
||||
|
||||
if (bLineScrollEnabled) {
|
||||
// shorten string on right side because line is displayed left aligned while scrolling
|
||||
// using floor() because otherwise empty space on right side
|
||||
iCharToRemove = floor(((float)(PixLengthLineIn - MaxPixWidthForPageScrolling)) / fAvgPixPerChar);
|
||||
iCharToRemove = floor((static_cast<float>(PixLengthLineIn - MaxPixWidthForPageScrolling)) / fAvgPixPerChar);
|
||||
ScrollingPages.LineIn[j] = ScrollingPages.LineIn[j].substring(0, strlen - iCharToRemove);
|
||||
}
|
||||
else {
|
||||
// shorten string on both sides because line is displayed centered
|
||||
// using floor() because otherwise empty space on both sides
|
||||
iCharToRemove = floor(((float)(PixLengthLineIn - MaxPixWidthForPageScrolling)) / (2 * fAvgPixPerChar));
|
||||
iCharToRemove = floor((static_cast<float>(PixLengthLineIn - MaxPixWidthForPageScrolling)) / (2 * fAvgPixPerChar));
|
||||
ScrollingPages.LineIn[j] = ScrollingPages.LineIn[j].substring(0, strlen - iCharToRemove);
|
||||
ScrollingPages.LineIn[j] = ScrollingPages.LineIn[j].substring(iCharToRemove);
|
||||
}
|
||||
@@ -710,12 +710,12 @@ uint8_t P036_data_struct::display_scroll(ePageScrollSpeed lscrollspeed, int lTas
|
||||
# ifdef PLUGIN_036_DEBUG
|
||||
String LineOutStr = ScrollingPages.LineOut[j];
|
||||
# endif // PLUGIN_036_DEBUG
|
||||
float fAvgPixPerChar = ((float)PixLengthLineOut) / strlen;
|
||||
float fAvgPixPerChar = static_cast<float>(PixLengthLineOut) / strlen;
|
||||
|
||||
if (bLineScrollEnabled) {
|
||||
// shorten string on left side because line is displayed right aligned while scrolling
|
||||
// using ceil() because otherwise overlapping the new text
|
||||
iCharToRemove = ceil(((float)(PixLengthLineOut - MaxPixWidthForPageScrolling)) / fAvgPixPerChar);
|
||||
iCharToRemove = ceil((static_cast<float>(PixLengthLineOut - MaxPixWidthForPageScrolling)) / fAvgPixPerChar);
|
||||
ScrollingPages.LineOut[j] = ScrollingPages.LineOut[j].substring(iCharToRemove);
|
||||
|
||||
if (display->getStringWidth(ScrollingPages.LineOut[j]) > MaxPixWidthForPageScrolling) {
|
||||
@@ -726,7 +726,7 @@ uint8_t P036_data_struct::display_scroll(ePageScrollSpeed lscrollspeed, int lTas
|
||||
else {
|
||||
// shorten string on both sides because line is displayed centered
|
||||
// using ceil() because otherwise overlapping the new text
|
||||
iCharToRemove = ceil(((float)(PixLengthLineOut - MaxPixWidthForPageScrolling)) / (2 * fAvgPixPerChar));
|
||||
iCharToRemove = ceil((static_cast<float>(PixLengthLineOut - MaxPixWidthForPageScrolling)) / (2 * fAvgPixPerChar));
|
||||
ScrollingPages.LineOut[j] = ScrollingPages.LineOut[j].substring(0, strlen - iCharToRemove);
|
||||
ScrollingPages.LineOut[j] = ScrollingPages.LineOut[j].substring(iCharToRemove);
|
||||
}
|
||||
|
||||
@@ -45,27 +45,27 @@ void P050_data_struct::resetTransformation() {
|
||||
* applyTransformation : calibrate r/g/b inputs (uint16_t) to rc/gc/bc outputs (float, by reference)
|
||||
*/
|
||||
void P050_data_struct::applyTransformation(uint16_t r, uint16_t g, uint16_t b, float *rc, float *gc, float *bc) {
|
||||
*rc = TransformationSettings.matrix[0][0] * (float)r + TransformationSettings.matrix[0][1] * (float)g + TransformationSettings.matrix[0][2] * (float)b;
|
||||
*gc = TransformationSettings.matrix[1][0] * (float)r + TransformationSettings.matrix[1][1] * (float)g + TransformationSettings.matrix[1][2] * (float)b;
|
||||
*bc = TransformationSettings.matrix[2][0] * (float)r + TransformationSettings.matrix[2][1] * (float)g + TransformationSettings.matrix[2][2] * (float)b;
|
||||
*rc = TransformationSettings.matrix[0][0] * static_cast<float>(r) + TransformationSettings.matrix[0][1] * static_cast<float>(g) + TransformationSettings.matrix[0][2] * static_cast<float>(b);
|
||||
*gc = TransformationSettings.matrix[1][0] * static_cast<float>(r) + TransformationSettings.matrix[1][1] * static_cast<float>(g) + TransformationSettings.matrix[1][2] * static_cast<float>(b);
|
||||
*bc = TransformationSettings.matrix[2][0] * static_cast<float>(r) + TransformationSettings.matrix[2][1] * static_cast<float>(g) + TransformationSettings.matrix[2][2] * static_cast<float>(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* applyTransformation : calibrate normalized r/g/b inputs (float) to rc/gc/bc outputs (float, by reference)
|
||||
*/
|
||||
void P050_data_struct::applyTransformation(float nr, float ng, float nb, float *rc, float *gc, float *bc) {
|
||||
*rc = TransformationSettings.matrix[0][0] * (float)nr + TransformationSettings.matrix[0][1] * (float)ng + TransformationSettings.matrix[0][2] * (float)nb;
|
||||
*gc = TransformationSettings.matrix[1][0] * (float)nr + TransformationSettings.matrix[1][1] * (float)ng + TransformationSettings.matrix[1][2] * (float)nb;
|
||||
*bc = TransformationSettings.matrix[2][0] * (float)nr + TransformationSettings.matrix[2][1] * (float)ng + TransformationSettings.matrix[2][2] * (float)nb;
|
||||
*rc = TransformationSettings.matrix[0][0] * static_cast<float>(nr) + TransformationSettings.matrix[0][1] * static_cast<float>(ng) + TransformationSettings.matrix[0][2] * static_cast<float>(nb);
|
||||
*gc = TransformationSettings.matrix[1][0] * static_cast<float>(nr) + TransformationSettings.matrix[1][1] * static_cast<float>(ng) + TransformationSettings.matrix[1][2] * static_cast<float>(nb);
|
||||
*bc = TransformationSettings.matrix[2][0] * static_cast<float>(nr) + TransformationSettings.matrix[2][1] * static_cast<float>(ng) + TransformationSettings.matrix[2][2] * static_cast<float>(nb);
|
||||
}
|
||||
|
||||
bool P050_data_struct::loadSettings(taskIndex_t taskIndex) {
|
||||
LoadCustomTaskSettings(taskIndex, (uint8_t *)&(TransformationSettings), sizeof(TransformationSettings));
|
||||
LoadCustomTaskSettings(taskIndex, reinterpret_cast<uint8_t *>(&TransformationSettings), sizeof(TransformationSettings));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool P050_data_struct::saveSettings(taskIndex_t taskIndex) {
|
||||
SaveCustomTaskSettings(taskIndex, (uint8_t *)&(TransformationSettings), sizeof(TransformationSettings));
|
||||
SaveCustomTaskSettings(taskIndex, reinterpret_cast<const uint8_t *>(&TransformationSettings), sizeof(TransformationSettings));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ float P060_data_struct::getValue()
|
||||
|
||||
if (OversamplingCount > 0)
|
||||
{
|
||||
value = (float)OversamplingValue / OversamplingCount;
|
||||
value = static_cast<float>(OversamplingValue) / OversamplingCount;
|
||||
OversamplingValue = 0;
|
||||
OversamplingCount = 0;
|
||||
} else {
|
||||
|
||||
@@ -103,7 +103,7 @@ void P062_data_struct::loadTouchObjects(taskIndex_t taskIndex) {
|
||||
log += sizeof(StoredSettings);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif // PLUGIN_062_DEBUG
|
||||
LoadCustomTaskSettings(taskIndex, (uint8_t *)&(StoredSettings), sizeof(StoredSettings));
|
||||
LoadCustomTaskSettings(taskIndex, reinterpret_cast<uint8_t *>(&StoredSettings), sizeof(StoredSettings));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,7 +75,7 @@ float P069_data_struct::getTemperatureInDegrees() const
|
||||
}
|
||||
|
||||
// Real value can be calculated with sensor resolution
|
||||
real_result = (float)value * LM75A_DEGREES_RESOLUTION;
|
||||
real_result = static_cast<float>(value) * LM75A_DEGREES_RESOLUTION;
|
||||
|
||||
return real_result;
|
||||
}
|
||||
|
||||
@@ -257,10 +257,10 @@ unsigned char LOLIN_I2C_MOTOR::sendData(unsigned char *data, unsigned char len)
|
||||
delay(50);
|
||||
|
||||
if (data[0] == GET_SLAVE_STATUS) {
|
||||
Wire.requestFrom((int)_address, 2);
|
||||
Wire.requestFrom(static_cast<int>(_address), 2);
|
||||
}
|
||||
else {
|
||||
Wire.requestFrom((int)_address, 1);
|
||||
Wire.requestFrom(static_cast<int>(_address), 1);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
@@ -464,21 +464,21 @@ CCS811Core::status CCS811::readNTC(void)
|
||||
return SENSOR_I2C_ERROR;
|
||||
}
|
||||
|
||||
vrefCounts = ((uint16_t)data[CSS811_NTC + 0] << 8) | data[CSS811_NTC + 1];
|
||||
vrefCounts = (static_cast<uint16_t>(data[CSS811_NTC + 0]) << 8) | data[CSS811_NTC + 1];
|
||||
|
||||
// Serial.print("vrefCounts: ");
|
||||
// Serial.println(vrefCounts);
|
||||
ntcCounts = ((uint16_t)data[CSS811_NTC + 2] << 8) | data[CSS811_NTC + 3];
|
||||
ntcCounts = (static_cast<uint16_t>(data[CSS811_NTC + 2]) << 8) | data[CSS811_NTC + 3];
|
||||
|
||||
// Serial.print("ntcCounts: ");
|
||||
// Serial.println(ntcCounts);
|
||||
// Serial.print("sum: ");
|
||||
// Serial.println(ntcCounts + vrefCounts);
|
||||
resistance = ((float)ntcCounts * refResistance / (float)vrefCounts);
|
||||
resistance = (static_cast<float>(ntcCounts) * refResistance / static_cast<float>(vrefCounts));
|
||||
|
||||
// Code from Milan Malesevic and Zoran Stupic, 2011,
|
||||
// Modified by Max Mayfield,
|
||||
_temperature = log((long)resistance);
|
||||
_temperature = log(static_cast<long>(resistance));
|
||||
_temperature = 1 / (0.001129148f + (0.000234125f * _temperature) + (0.0000000876741f * _temperature * _temperature * _temperature));
|
||||
_temperature = _temperature - 273.15f; // Convert Kelvin to Celsius
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ void P099_data_struct::loadTouchObjects(taskIndex_t taskIndex) {
|
||||
log += sizeof(StoredSettings);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
#endif // PLUGIN_099_DEBUG
|
||||
LoadCustomTaskSettings(taskIndex, (uint8_t *)&(StoredSettings), sizeof(StoredSettings));
|
||||
LoadCustomTaskSettings(taskIndex, reinterpret_cast<uint8_t *>(&StoredSettings), sizeof(StoredSettings));
|
||||
|
||||
for (int i = 0; i < P099_MaxObjectCount; i++) {
|
||||
StoredSettings.TouchObjects[i].objectname[P099_MaxObjectNameLength - 1] = 0; // Terminate strings in case of uninitialized data
|
||||
|
||||
@@ -43,8 +43,8 @@ bool P114_data_struct::read_sensor(float& _UVA, float& _UVB, float& _UVIndex) {
|
||||
_UVA = UVData[0] / pow(2, IT - 1); // UVA light sensitivity increases linear with integration time
|
||||
_UVB = UVData[2] / pow(2, IT - 1); // UVB light sensitivity increases linear with integration time
|
||||
|
||||
// float UVASensitivity = 0.93/((float) (IT + 1)); // UVA light sensitivity increases with integration time
|
||||
// float UVBSensitivity = 2.10/((float) (IT + 1)); // UVB light sensitivity increases with integration time
|
||||
// float UVASensitivity = 0.93/(static_cast<float>(IT + 1)); // UVA light sensitivity increases with integration time
|
||||
// float UVBSensitivity = 2.10/(static_cast<float>(IT + 1)); // UVB light sensitivity increases with integration time
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
log = F("VEML6075: IT raw: 0x");
|
||||
log += String(IT + 1, HEX);
|
||||
|
||||
@@ -81,7 +81,7 @@ void handle_notifications() {
|
||||
}
|
||||
|
||||
// Save the settings.
|
||||
addHtmlError(SaveNotificationSettings(notificationindex, (uint8_t *)&NotificationSettings, sizeof(NotificationSettingsStruct)));
|
||||
addHtmlError(SaveNotificationSettings(notificationindex, reinterpret_cast<const uint8_t *>(&NotificationSettings), sizeof(NotificationSettingsStruct)));
|
||||
addHtmlError(SaveSettings());
|
||||
|
||||
if (web_server.hasArg(F("test"))) {
|
||||
@@ -114,7 +114,7 @@ void handle_notifications() {
|
||||
|
||||
for (uint8_t x = 0; x < NOTIFICATION_MAX; x++)
|
||||
{
|
||||
LoadNotificationSettings(x, (uint8_t *)&NotificationSettings, sizeof(NotificationSettingsStruct));
|
||||
LoadNotificationSettings(x, reinterpret_cast<uint8_t *>(&NotificationSettings), sizeof(NotificationSettingsStruct));
|
||||
NotificationSettings.validate();
|
||||
html_TR_TD();
|
||||
html_add_button_prefix();
|
||||
@@ -174,7 +174,7 @@ void handle_notifications() {
|
||||
if (Settings.Notification[notificationindex])
|
||||
{
|
||||
MakeNotificationSettings(NotificationSettings);
|
||||
LoadNotificationSettings(notificationindex, (uint8_t *)&NotificationSettings, sizeof(NotificationSettingsStruct));
|
||||
LoadNotificationSettings(notificationindex, reinterpret_cast<uint8_t *>(&NotificationSettings), sizeof(NotificationSettingsStruct));
|
||||
NotificationSettings.validate();
|
||||
|
||||
nprotocolIndex_t NotificationProtocolIndex = getNProtocolIndex_from_NotifierIndex(notificationindex);
|
||||
|
||||
@@ -133,7 +133,7 @@ void handleFileUpload() {
|
||||
for (unsigned int x = 0; x < sizeof(struct TempStruct); x++)
|
||||
{
|
||||
uint8_t b = upload.buf[x];
|
||||
memcpy((uint8_t *)&Temp + x, &b, 1);
|
||||
memcpy(reinterpret_cast<uint8_t *>(&Temp) + x, &b, 1);
|
||||
}
|
||||
|
||||
if ((Temp.Version == VERSION) && (Temp.PID == ESP_PROJECT_PID)) {
|
||||
|
||||
Reference in New Issue
Block a user