mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
reduced mem C001 C002
This commit is contained in:
+1
-1
@@ -220,7 +220,7 @@ try:
|
||||
total['bss']-base['bss'],
|
||||
total['irom0_text']-base['irom0_text'],
|
||||
))
|
||||
except:
|
||||
finally:
|
||||
enable_all()
|
||||
|
||||
raise
|
||||
|
||||
@@ -2526,5 +2526,29 @@ void ArduinoOTAInit()
|
||||
|
||||
}
|
||||
|
||||
String getBearing(int degrees)
|
||||
{
|
||||
const char* bearing[] = {
|
||||
PSTR("N"),
|
||||
PSTR("NNE"),
|
||||
PSTR("NE"),
|
||||
PSTR("ENE"),
|
||||
PSTR("E"),
|
||||
PSTR("ESE"),
|
||||
PSTR("SE"),
|
||||
PSTR("SSE"),
|
||||
PSTR("S"),
|
||||
PSTR("SSW"),
|
||||
PSTR("SW"),
|
||||
PSTR("WSW"),
|
||||
PSTR("W"),
|
||||
PSTR("WNW"),
|
||||
PSTR("NW"),
|
||||
PSTR("NNW")
|
||||
};
|
||||
|
||||
return(bearing[int(degrees/22.5)]);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+3
-18
@@ -157,24 +157,9 @@ boolean CPlugin_001(byte function, struct EventStruct *event, String& string)
|
||||
case (SENSOR_TYPE_WIND):
|
||||
url += PSTR("&svalue="); // WindDir in degrees; WindDir as text; Wind speed average ; Wind speed gust; 0
|
||||
url += toString(UserVar[event->BaseVarIndex],ExtraTaskSettings.TaskDeviceValueDecimals[0]);
|
||||
const char* bearing[] = {
|
||||
PSTR(";N;"),
|
||||
PSTR(";NNE;"),
|
||||
PSTR(";NE;"),
|
||||
PSTR(";ENE;"),
|
||||
PSTR(";E;"),
|
||||
PSTR(";ESE;"),
|
||||
PSTR(";SE;"),
|
||||
PSTR(";SSE;"),
|
||||
PSTR(";S;"),
|
||||
PSTR(";SSW;"),
|
||||
PSTR(";SW;"),
|
||||
PSTR(";WSW;"),
|
||||
PSTR(";W;"),
|
||||
PSTR(";WNW;"),
|
||||
PSTR(";NW;"),
|
||||
PSTR(";NNW;") };
|
||||
url += bearing[int(UserVar[event->BaseVarIndex] / 22.5)];
|
||||
url += ";";
|
||||
url += getBearing(UserVar[event->BaseVarIndex]);
|
||||
url += ";";
|
||||
// Domoticz expects the wind speed in (m/s * 10)
|
||||
url += toString((UserVar[event->BaseVarIndex + 1] * 10),ExtraTaskSettings.TaskDeviceValueDecimals[1]);
|
||||
url += ";";
|
||||
|
||||
+27
-26
@@ -50,15 +50,15 @@ boolean CPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
if (root.success())
|
||||
{
|
||||
long idx = root["idx"];
|
||||
float nvalue = root["nvalue"];
|
||||
long nvaluealt = root["nvalue"];
|
||||
long idx = root[F("idx")];
|
||||
float nvalue = root[F("nvalue")];
|
||||
long nvaluealt = root[F("nvalue")];
|
||||
//const char* name = root["name"]; // Not used
|
||||
//const char* svalue = root["svalue"]; // Not used
|
||||
const char* svalue1 = root["svalue1"];
|
||||
const char* svalue1 = root[F("svalue1")];
|
||||
//const char* svalue2 = root["svalue2"]; // Not used
|
||||
//const char* svalue3 = root["svalue3"]; // Not used
|
||||
const char* switchtype = root["switchType"]; // Expect "On/Off" or "dimmer"
|
||||
const char* switchtype = root[F("switchType")]; // Expect "On/Off" or "dimmer"
|
||||
if (nvalue == 0)
|
||||
nvalue = nvaluealt;
|
||||
if ((int)switchtype == 0)
|
||||
@@ -138,7 +138,7 @@ boolean CPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
|
||||
root["idx"] = event->idx;
|
||||
root[F("idx")] = event->idx;
|
||||
|
||||
String values;
|
||||
char str[80];
|
||||
@@ -146,45 +146,45 @@ boolean CPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
switch (event->sensorType)
|
||||
{
|
||||
case SENSOR_TYPE_SINGLE: // single value sensor, used for Dallas, BH1750, etc
|
||||
root["nvalue"] = 0;
|
||||
root[F("nvalue")] = 0;
|
||||
values = toString(UserVar[event->BaseVarIndex], ExtraTaskSettings.TaskDeviceValueDecimals[0]);
|
||||
values.toCharArray(str, 80);
|
||||
root["svalue"] = str;
|
||||
root[F("svalue")] = str;
|
||||
break;
|
||||
case SENSOR_TYPE_LONG: // single LONG value, stored in two floats (rfid tags)
|
||||
root["nvalue"] = 0;
|
||||
root[F("nvalue")] = 0;
|
||||
values = (unsigned long)UserVar[event->BaseVarIndex] + ((unsigned long)UserVar[event->BaseVarIndex + 1] << 16);
|
||||
values.toCharArray(str, 80);
|
||||
root["svalue"] = str;
|
||||
root[F("svalue")] = str;
|
||||
break;
|
||||
case SENSOR_TYPE_DUAL: // any sensor that uses two simple values
|
||||
root["nvalue"] = 0;
|
||||
root[F("nvalue")] = 0;
|
||||
values = toString(UserVar[event->BaseVarIndex ], ExtraTaskSettings.TaskDeviceValueDecimals[0]);
|
||||
values += ";";
|
||||
values += toString(UserVar[event->BaseVarIndex + 1], ExtraTaskSettings.TaskDeviceValueDecimals[1]);
|
||||
values.toCharArray(str, 80);
|
||||
root["svalue"] = str;
|
||||
root[F("svalue")] = str;
|
||||
break;
|
||||
case SENSOR_TYPE_TEMP_HUM: // temp + hum + hum_stat, used for DHT11
|
||||
root["nvalue"] = 0;
|
||||
root[F("nvalue")] = 0;
|
||||
values = toString(UserVar[event->BaseVarIndex], ExtraTaskSettings.TaskDeviceValueDecimals[0]);
|
||||
values += ";";
|
||||
values += toString(UserVar[event->BaseVarIndex + 1], ExtraTaskSettings.TaskDeviceValueDecimals[1]);
|
||||
values += ";0";
|
||||
values.toCharArray(str, 80);
|
||||
root["svalue"] = str;
|
||||
root[F("svalue")] = str;
|
||||
break;
|
||||
case SENSOR_TYPE_TEMP_BARO: // temp + hum + hum_stat + bar + bar_fore, used for BMP085
|
||||
root["nvalue"] = 0;
|
||||
root[F("nvalue")] = 0;
|
||||
values = toString(UserVar[event->BaseVarIndex], ExtraTaskSettings.TaskDeviceValueDecimals[0]);
|
||||
values += ";0;0;";
|
||||
values += toString(UserVar[event->BaseVarIndex + 1], ExtraTaskSettings.TaskDeviceValueDecimals[1]);
|
||||
values += ";0";
|
||||
values.toCharArray(str, 80);
|
||||
root["svalue"] = str;
|
||||
root[F("svalue")] = str;
|
||||
break;
|
||||
case SENSOR_TYPE_TEMP_HUM_BARO: // temp + hum + hum_stat + bar + bar_fore, used for BME280
|
||||
root["nvalue"] = 0;
|
||||
root[F("nvalue")] = 0;
|
||||
values = toString(UserVar[event->BaseVarIndex], ExtraTaskSettings.TaskDeviceValueDecimals[0]);
|
||||
values += ";";
|
||||
values += toString(UserVar[event->BaseVarIndex + 1], ExtraTaskSettings.TaskDeviceValueDecimals[1]);
|
||||
@@ -192,26 +192,27 @@ boolean CPlugin_002(byte function, struct EventStruct *event, String& string)
|
||||
values += toString(UserVar[event->BaseVarIndex + 2], ExtraTaskSettings.TaskDeviceValueDecimals[2]);
|
||||
values += ";0";
|
||||
values.toCharArray(str, 80);
|
||||
root["svalue"] = str;
|
||||
root[F("svalue")] = str;
|
||||
break;
|
||||
case SENSOR_TYPE_SWITCH:
|
||||
root["command"] = "switchlight";
|
||||
root[F("command")] = PSTR("switchlight");
|
||||
if (UserVar[event->BaseVarIndex] == 0)
|
||||
root["switchcmd"] = "Off";
|
||||
root[F("switchcmd")] = PSTR("Off");
|
||||
else
|
||||
root["switchcmd"] = "On";
|
||||
root[F("switchcmd")] = PSTR("On");
|
||||
break;
|
||||
case SENSOR_TYPE_DIMMER:
|
||||
root["command"] = "switchlight";
|
||||
root[F("command")] = PSTR("switchlight");
|
||||
if (UserVar[event->BaseVarIndex] == 0)
|
||||
root["switchcmd"] = "Off";
|
||||
root[F("switchcmd")] = PSTR("Off");
|
||||
else
|
||||
root["Set%20Level"] = UserVar[event->BaseVarIndex];
|
||||
root[F("Set%20Level")] = UserVar[event->BaseVarIndex];
|
||||
break;
|
||||
case SENSOR_TYPE_WIND: // WindDir in degrees; WindDir as text; Wind speed average ; Wind speed gust
|
||||
values = toString(UserVar[event->BaseVarIndex],ExtraTaskSettings.TaskDeviceValueDecimals[0]);
|
||||
const char* bearing[] = {";N;",";NNE;",";NE;",";ENE;",";E;",";ESE;",";SE;",";SSE;",";S;",";SSW;",";SW;",";WSW;",";W;",";WNW;",";NW;",";NNW;" };
|
||||
values += bearing[int(UserVar[event->BaseVarIndex] / 22.5)];
|
||||
values += ";";
|
||||
values += getBearing(int(UserVar[event->BaseVarIndex] / 22.5));
|
||||
values += ";";
|
||||
// Domoticz expects the wind speed in (m/s * 10)
|
||||
values += toString((UserVar[event->BaseVarIndex + 1] * 10),ExtraTaskSettings.TaskDeviceValueDecimals[1]);
|
||||
values += ";";
|
||||
|
||||
Reference in New Issue
Block a user