Optimization

This commit is contained in:
Dmitry Borisenko
2020-10-20 23:58:23 +03:00
parent a5171f1178
commit 29e5a55ad3
14 changed files with 63 additions and 121 deletions

View File

@@ -63,8 +63,8 @@ void sensorsInit() {
nullptr, true);
ts.add(
SENSORS60SEC, 60000, [&](void *) {
String buf = sensorReadingMap60sec;
SENSORS30SEC, 30000, [&](void *) {
String buf = sensorReadingMap30sec;
while (buf.length()) {
String tmp = selectToMarker(buf, ",");
sCmd.readStr(tmp);
@@ -74,8 +74,3 @@ void sensorsInit() {
nullptr, true);
}
//void loopSerial() {
// if (term) {
// term->loop();
// }
//}

16
src/Clock.cpp Normal file
View File

@@ -0,0 +1,16 @@
#include "Clock.h"
#include "Global.h"
Clock* timeNow;
void clock_init() {
timeNow = new Clock;
timeNow->setNtpPool(jsonReadStr(configSetupJson, "ntp"));
timeNow->setTimezone(jsonReadStr(configSetupJson, "timezone").toInt());
ts.add(
TIME_SYNC, 30000, [&](void*) {
timeNow->hasSync();
},
nullptr, true);
}

View File

@@ -4,7 +4,7 @@
AsyncWebSocket ws;
//AsyncEventSource events;
#endif
Clock* timeNow;
TickerScheduler ts(TEST + 1);
WiFiClient espClient;
PubSubClient mqtt(espClient);
@@ -40,7 +40,7 @@ String itemsLine = "";
// Sensors
int8_t dallasEnterCounter = -1;
String sensorReadingMap10sec;
String sensorReadingMap60sec;
String sensorReadingMap30sec;
// Logging
String logging_value_names_list;

View File

@@ -14,8 +14,6 @@ String xmlNode(String tags, String data);
String decToHex(uint32_t decValue, byte desiredStringLength);
//39164
//457684
void SsdpInit() {
server.on("/description.xml", HTTP_GET, [](AsyncWebServerRequest* request) {
String ssdpSend = F("<root xmlns=\"urn:schemas-upnp-org:device-1-0\">");

View File

@@ -1,5 +1,6 @@
#include "Utils/FileUtils.h"
#include "Utils/PrintMessage.h"
#include "Utils\SerialPrint.h"
#include "Utils/StringUtils.h"

View File

@@ -1,7 +1,7 @@
#include "Utils/SysUtils.h"
#include "Global.h"
#include "Utils/PrintMessage.h"
const String getUniqueId(const char* name) {
return String(name) + getMacAddress();

View File

@@ -20,8 +20,6 @@ void inputTimeSet() {
void handle_time_init() {
ts.add(
TIME, 1000, [&](void *) {
//jsonWriteStr(configLiveJson, "time", timeNow->getTime());
//jsonWriteStr(configLiveJson, "timenow", timeNow->getTimeJson());
jsonWriteStr(configLiveJson, "timenow", timeNow->getTime());
eventGen("timenow", "");
},

View File

@@ -7,7 +7,7 @@ void sysUptime() {
myLineParsing.update();
String key = myLineParsing.gkey();
sCmd.addCommand(key.c_str(), uptimeReading);
sensorReadingMap60sec += key + ",";
sensorReadingMap30sec += key + ",";
myLineParsing.clear();
}

View File

@@ -116,16 +116,4 @@ void loop() {
myNotAsyncActions->loop();
ts.update();
}
void clock_init() {
timeNow = new Clock();
timeNow->setNtpPool(jsonReadStr(configSetupJson, "ntp"));
timeNow->setTimezone(jsonReadStr(configSetupJson, "timezone").toInt());
ts.add(
TIME_SYNC, 30000, [&](void*) {
timeNow->hasSync();
},
nullptr, true);
}
}