diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..889b02bd --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "array": "cpp" + } +} \ No newline at end of file diff --git a/data_esp/set.device.json.gz b/data_esp/set.device.json.gz index 07a38015..fb8dfba7 100644 Binary files a/data_esp/set.device.json.gz and b/data_esp/set.device.json.gz differ diff --git a/platformio.ini b/platformio.ini index 57768031..01c01df3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -default_envs = esp32_4mb +default_envs = esp8266_4mb data_dir = data_esp [common_env_data] diff --git a/src/YourSensor.cpp b/src/YourSensor.cpp index e88da3c1..5f70e308 100644 --- a/src/YourSensor.cpp +++ b/src/YourSensor.cpp @@ -2,12 +2,22 @@ float yourSensorReading(String type) { float value; - if (type == "type1") { - value++; + if (type == "type1") { // type1 - замените на название вашего датчика, потом это же название указывайте в type[] в вебе + //сюда вставляем процедуру чтения одного датчика + static int a; + a++; + value = a; } else if (type == "type2") { - value--; + //сюда вставляем процедуру чтения другого датчика + static int b; + b--; + value = b; } else if (type == "type3") { - value = value + 10; + //сюда третьего и так далее, создавайте сколько угодно else if.... + //если у одного датчика несколько параметров то под каждый из них делайте свой else if и свое имя type + static int c; + c++; + value = c * 10; } return value; } diff --git a/src/items/vSensorAny.cpp b/src/items/vSensorAny.cpp index 280a3382..12917194 100644 --- a/src/items/vSensorAny.cpp +++ b/src/items/vSensorAny.cpp @@ -22,7 +22,7 @@ SensorAny::~SensorAny() {} void SensorAny::loop() { difference = millis() - prevMillis; - if (difference >= _interval) { + if (difference >= _interval * 1000) { prevMillis = millis(); read(); } @@ -54,6 +54,7 @@ void AnySensor() { jsonWriteStr(params, "addr", myLineParsing.gaddr()); jsonWriteStr(params, "int", myLineParsing.gint()); jsonWriteStr(params, "c", myLineParsing.gc()); + jsonWriteStr(params, "type", myLineParsing.gtype()); myLineParsing.clear(); static bool firstTime = true; diff --git a/src/main.cpp b/src/main.cpp index 8f54d67c..8cf99b10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,6 +24,7 @@ #include "items/vImpulsOut.h" #include "items/vLogging.h" #include "items/vSensorAnalog.h" +#include "items/vSensorAny.h" #include "items/vSensorBme280.h" #include "items/vSensorBmp280.h" #include "items/vSensorCcs811.h" @@ -34,13 +35,12 @@ #include "items/vSensorSht20.h" #include "items/vSensorUltrasonic.h" #include "items/vSensorUptime.h" - //#include "WebServer.h" void not_async_actions(); Timings metric; boolean initialized = false; -extern int flagq ; +extern int flagq; void setup() { Serial.begin(115200); Serial.flush(); @@ -97,12 +97,12 @@ void loop() { #endif #ifdef WEBSOCKET_ENABLED - ws.cleanupClients(); - if ( flagq == 1){ - SerialPrint("I", "WS ", "choose_log_date_and_send()"); - choose_log_date_and_sendWS(); - flagq = 0; -} + ws.cleanupClients(); + if (flagq == 1) { + SerialPrint("I", "WS ", "choose_log_date_and_send()"); + choose_log_date_and_sendWS(); + flagq = 0; + } #endif timeNow->loop(); mqttLoop(); @@ -188,6 +188,13 @@ void loop() { } } #endif +#ifdef EnableSensorAny + if (mySensorAny != nullptr) { + for (unsigned int i = 0; i < mySensorAny->size(); i++) { + mySensorAny->at(i).loop(); + } + } +#endif #ifdef EnableSensorBmp280 if (mySensorBmp280 != nullptr) { for (unsigned int i = 0; i < mySensorBmp280->size(); i++) {