доработки логирования

This commit is contained in:
Dmitry Borisenko
2022-09-08 18:48:27 +02:00
parent 12ef79c558
commit 5da6b61b36
9 changed files with 127 additions and 86 deletions

View File

@@ -14,8 +14,8 @@
"widget": "chart1", "widget": "chart1",
"page": "Графики", "page": "Графики",
"descr": "График", "descr": "График",
"int": 60, "int": 1,
"logid": "tmp", "logid": "t",
"num": 1, "num": 1,
"points": 300, "points": 300,
"keepdays": 2 "keepdays": 2
@@ -30,8 +30,8 @@
"descr": "Таймер", "descr": "Таймер",
"int": 1, "int": 1,
"countDown": 15, "countDown": 15,
"ticker": 0, "ticker": 1,
"repeat": 0, "repeat": 1,
"needSave": 0, "needSave": 0,
"num": 2 "num": 2
}, },
@@ -72,7 +72,19 @@
"num": 5 "num": 5
}, },
{ {
"name": "6. Виртуальная кнопка", "name": "6. Окно ввода текста",
"type": "Reading",
"subtype": "Variable",
"id": "txt",
"widget": "inputTxt",
"page": "Ввод",
"descr": "Введите текст",
"int": "0",
"val": "текст",
"num": 6
},
{
"name": "7. Виртуальная кнопка",
"type": "Reading", "type": "Reading",
"subtype": "VButton", "subtype": "VButton",
"id": "vbtn", "id": "vbtn",
@@ -81,13 +93,13 @@
"descr": "Кнопка", "descr": "Кнопка",
"int": "0", "int": "0",
"val": "0", "val": "0",
"num": 6 "num": 7
}, },
{ {
"header": "Сенсоры" "header": "Сенсоры"
}, },
{ {
"name": "7. Cенсор температуры AHT20", "name": "8. Cенсор температуры AHT20",
"type": "Reading", "type": "Reading",
"subtype": "Aht20t", "subtype": "Aht20t",
"id": "Temp20", "id": "Temp20",
@@ -97,10 +109,10 @@
"int": 15, "int": 15,
"addr": "0x38", "addr": "0x38",
"round": 1, "round": 1,
"num": 7 "num": 8
}, },
{ {
"name": "8. Cенсор влажности AHT20", "name": "9. Cенсор влажности AHT20",
"type": "Reading", "type": "Reading",
"subtype": "Aht20h", "subtype": "Aht20h",
"id": "Hum20", "id": "Hum20",
@@ -110,10 +122,10 @@
"int": 15, "int": 15,
"addr": "0x38", "addr": "0x38",
"round": 1, "round": 1,
"num": 8 "num": 9
}, },
{ {
"name": "9. Аналоговый сенсор", "name": "10. Аналоговый сенсор",
"type": "Reading", "type": "Reading",
"subtype": "AnalogAdc", "subtype": "AnalogAdc",
"id": "t", "id": "t",
@@ -127,10 +139,10 @@
"pin": 0, "pin": 0,
"int": 15, "int": 15,
"avgSteps": 1, "avgSteps": 1,
"num": 9 "num": 10
}, },
{ {
"name": "10. Cенсор температуры Bme280", "name": "11. Cенсор температуры Bme280",
"type": "Reading", "type": "Reading",
"subtype": "Bme280t", "subtype": "Bme280t",
"id": "tmp3", "id": "tmp3",
@@ -140,10 +152,10 @@
"int": 15, "int": 15,
"addr": "0x77", "addr": "0x77",
"round": 1, "round": 1,
"num": 10 "num": 11
}, },
{ {
"name": "11. Cенсор давления Bme280", "name": "12. Cенсор давления Bme280",
"type": "Reading", "type": "Reading",
"subtype": "Bme280p", "subtype": "Bme280p",
"id": "Press3", "id": "Press3",
@@ -153,10 +165,10 @@
"int": 15, "int": 15,
"addr": "0x77", "addr": "0x77",
"round": 1, "round": 1,
"num": 11 "num": 12
}, },
{ {
"name": "12. Cенсор влажности Bme280", "name": "13. Cенсор влажности Bme280",
"type": "Reading", "type": "Reading",
"subtype": "Bme280h", "subtype": "Bme280h",
"id": "Hum3", "id": "Hum3",
@@ -166,10 +178,10 @@
"int": 15, "int": 15,
"addr": "0x77", "addr": "0x77",
"round": 1, "round": 1,
"num": 12 "num": 13
}, },
{ {
"name": "13. Cенсор температуры Bmp280", "name": "14. Cенсор температуры Bmp280",
"type": "Reading", "type": "Reading",
"subtype": "Bmp280t", "subtype": "Bmp280t",
"id": "tmp3", "id": "tmp3",
@@ -179,10 +191,10 @@
"int": 15, "int": 15,
"addr": "0x77", "addr": "0x77",
"round": 1, "round": 1,
"num": 13 "num": 14
}, },
{ {
"name": "14. Cенсор давления Bmp280", "name": "15. Cенсор давления Bmp280",
"type": "Reading", "type": "Reading",
"subtype": "Bmp280p", "subtype": "Bmp280p",
"id": "Press3", "id": "Press3",
@@ -192,10 +204,10 @@
"int": 15, "int": 15,
"addr": "0x77", "addr": "0x77",
"round": 1, "round": 1,
"num": 14 "num": 15
}, },
{ {
"name": "15. Cенсор температуры dht11", "name": "16. Cенсор температуры dht11",
"type": "Reading", "type": "Reading",
"subtype": "Dht1122t", "subtype": "Dht1122t",
"id": "tmp3", "id": "tmp3",
@@ -205,10 +217,10 @@
"int": 15, "int": 15,
"pin": 0, "pin": 0,
"senstype": "dht11", "senstype": "dht11",
"num": 15 "num": 16
}, },
{ {
"name": "16. Cенсор влажности dht11", "name": "17. Cенсор влажности dht11",
"type": "Reading", "type": "Reading",
"subtype": "Dht1122h", "subtype": "Dht1122h",
"id": "Hum3", "id": "Hum3",
@@ -218,10 +230,10 @@
"int": 15, "int": 15,
"pin": 0, "pin": 0,
"senstype": "dht11", "senstype": "dht11",
"num": 16 "num": 17
}, },
{ {
"name": "17. Cенсор температуры ds18b20", "name": "18. Cенсор температуры ds18b20",
"type": "Reading", "type": "Reading",
"subtype": "Ds18b20", "subtype": "Ds18b20",
"id": "dstmp", "id": "dstmp",
@@ -233,10 +245,10 @@
"index": 0, "index": 0,
"addr": "", "addr": "",
"round": 1, "round": 1,
"num": 17 "num": 18
}, },
{ {
"name": "18. Cенсор температуры GY21", "name": "19. Cенсор температуры GY21",
"type": "Reading", "type": "Reading",
"subtype": "GY21t", "subtype": "GY21t",
"id": "tmp4", "id": "tmp4",
@@ -245,10 +257,10 @@
"descr": "Температура", "descr": "Температура",
"round": 1, "round": 1,
"int": 15, "int": 15,
"num": 18 "num": 19
}, },
{ {
"name": "19. Cенсор влажности GY21", "name": "20. Cенсор влажности GY21",
"type": "Reading", "type": "Reading",
"subtype": "GY21h", "subtype": "GY21h",
"id": "Hum4", "id": "Hum4",
@@ -257,10 +269,10 @@
"descr": "Влажность", "descr": "Влажность",
"round": 1, "round": 1,
"int": 15, "int": 15,
"num": 19 "num": 20
}, },
{ {
"name": "20. Cенсор температуры HDC1080", "name": "21. Cенсор температуры HDC1080",
"type": "Reading", "type": "Reading",
"subtype": "Hdc1080t", "subtype": "Hdc1080t",
"id": "Temp1080", "id": "Temp1080",
@@ -270,10 +282,10 @@
"int": 15, "int": 15,
"addr": "0x40", "addr": "0x40",
"round": 1, "round": 1,
"num": 20 "num": 21
}, },
{ {
"name": "21. Cенсор влажности HDC1080", "name": "22. Cенсор влажности HDC1080",
"type": "Reading", "type": "Reading",
"subtype": "Hdc1080h", "subtype": "Hdc1080h",
"id": "Hum1080", "id": "Hum1080",
@@ -283,10 +295,10 @@
"int": 15, "int": 15,
"addr": "0x40", "addr": "0x40",
"round": 1, "round": 1,
"num": 21 "num": 22
}, },
{ {
"name": "22. Cенсор температуры MAX6675", "name": "23. Cенсор температуры MAX6675",
"type": "Reading", "type": "Reading",
"subtype": "Max6675t", "subtype": "Max6675t",
"id": "maxtmp", "id": "maxtmp",
@@ -297,11 +309,11 @@
"DO": 12, "DO": 12,
"CS": 13, "CS": 13,
"CLK": 14, "CLK": 14,
"num": 22 "num": 23
}, },
{ {
"name": "23. Сканер кнопок 433 MHz", "name": "24. Сканер кнопок 433 MHz",
"num": 23, "num": 24,
"type": "Reading", "type": "Reading",
"subtype": "RCswitch", "subtype": "RCswitch",
"id": "rsw", "id": "rsw",
@@ -310,7 +322,7 @@
"pinTx": 12 "pinTx": 12
}, },
{ {
"name": "24. Cенсор температуры Sht20", "name": "25. Cенсор температуры Sht20",
"type": "Reading", "type": "Reading",
"subtype": "Sht20t", "subtype": "Sht20t",
"id": "tmp2", "id": "tmp2",
@@ -319,10 +331,10 @@
"descr": "Температура", "descr": "Температура",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 24 "num": 25
}, },
{ {
"name": "25. Cенсор влажности Sht20", "name": "26. Cенсор влажности Sht20",
"type": "Reading", "type": "Reading",
"subtype": "Sht20h", "subtype": "Sht20h",
"id": "Hum2", "id": "Hum2",
@@ -331,10 +343,10 @@
"descr": "Влажность", "descr": "Влажность",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 25 "num": 26
}, },
{ {
"name": "26. Cенсор температуры Sht30", "name": "27. Cенсор температуры Sht30",
"type": "Reading", "type": "Reading",
"subtype": "Sht30t", "subtype": "Sht30t",
"id": "tmp30", "id": "tmp30",
@@ -343,10 +355,10 @@
"descr": "SHT30 Температура", "descr": "SHT30 Температура",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 26 "num": 27
}, },
{ {
"name": "27. Cенсор влажности Sht30", "name": "28. Cенсор влажности Sht30",
"type": "Reading", "type": "Reading",
"subtype": "Sht30h", "subtype": "Sht30h",
"id": "Hum30", "id": "Hum30",
@@ -355,11 +367,11 @@
"descr": "SHT30 Влажность", "descr": "SHT30 Влажность",
"int": 15, "int": 15,
"round": 1, "round": 1,
"num": 27 "num": 28
}, },
{ {
"name": "28. Сонар HC-SR04", "name": "29. Сонар HC-SR04",
"num": 28, "num": 29,
"type": "Reading", "type": "Reading",
"subtype": "Sonar", "subtype": "Sonar",
"id": "sonar", "id": "sonar",
@@ -374,7 +386,7 @@
"header": "Исполнительные устройства" "header": "Исполнительные устройства"
}, },
{ {
"name": "29. Кнопка подключенная к пину", "name": "30. Кнопка подключенная к пину",
"type": "Writing", "type": "Writing",
"subtype": "ButtonIn", "subtype": "ButtonIn",
"id": "btn", "id": "btn",
@@ -387,10 +399,10 @@
"pinMode": "INPUT", "pinMode": "INPUT",
"debounceDelay": 50, "debounceDelay": 50,
"fixState": 1, "fixState": 1,
"num": 29 "num": 30
}, },
{ {
"name": "30. Кнопка управляющая пином (Реле)", "name": "31. Кнопка управляющая пином (Реле)",
"type": "Writing", "type": "Writing",
"subtype": "ButtonOut", "subtype": "ButtonOut",
"id": "btn", "id": "btn",
@@ -400,10 +412,10 @@
"int": 0, "int": 0,
"inv": 0, "inv": 0,
"pin": 2, "pin": 2,
"num": 30 "num": 31
}, },
{ {
"name": "31. Сервопривод", "name": "32. Сервопривод",
"type": "Writing", "type": "Writing",
"subtype": "IoTServo", "subtype": "IoTServo",
"id": "servo", "id": "servo",
@@ -414,10 +426,10 @@
"pin": 12, "pin": 12,
"apin": -1, "apin": -1,
"amap": "0, 4096, 0, 180", "amap": "0, 4096, 0, 180",
"num": 31 "num": 32
}, },
{ {
"name": "32. Расширитель портов Mcp23017", "name": "33. Расширитель портов Mcp23017",
"type": "Reading", "type": "Reading",
"subtype": "Mcp23017", "subtype": "Mcp23017",
"id": "Mcp", "id": "Mcp",
@@ -427,10 +439,10 @@
"int": "0", "int": "0",
"addr": "0x20", "addr": "0x20",
"index": 1, "index": 1,
"num": 32 "num": 33
}, },
{ {
"name": "33. MP3 плеер", "name": "34. MP3 плеер",
"type": "Reading", "type": "Reading",
"subtype": "Mp3", "subtype": "Mp3",
"id": "mp3", "id": "mp3",
@@ -440,25 +452,27 @@
"int": 1, "int": 1,
"pins": "14,12", "pins": "14,12",
"volume": 20, "volume": 20,
"num": 33 "num": 34
}, },
{ {
"name": "34. PWM ESP8266", "name": "35. PWM ESP32",
"type": "Writing", "type": "Writing",
"subtype": "Pwm8266", "subtype": "Pwm32",
"id": "pwm", "id": "pwm",
"widget": "range", "widget": "range",
"page": "Кнопки", "page": "Кнопки",
"descr": "PWM", "descr": "PWM",
"int": 0, "int": 0,
"pin": 15, "pin": 2,
"freq": 5000, "freq": 5000,
"ledChannel": 2,
"PWM_resolution": 10,
"val": 0, "val": 0,
"apin": -1, "apin": -1,
"num": 34 "num": 35
}, },
{ {
"name": "35. Телеграм-Лайт", "name": "36. Телеграм-Лайт",
"type": "Writing", "type": "Writing",
"subtype": "TelegramLT", "subtype": "TelegramLT",
"id": "tg", "id": "tg",
@@ -467,13 +481,13 @@
"descr": "", "descr": "",
"token": "", "token": "",
"chatID": "", "chatID": "",
"num": 35 "num": 36
}, },
{ {
"header": "Экраны" "header": "Экраны"
}, },
{ {
"name": "36. LCD экран 2004", "name": "37. LCD экран 2004",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -485,10 +499,10 @@
"size": "20,4", "size": "20,4",
"coord": "0,0", "coord": "0,0",
"id2show": "id датчика", "id2show": "id датчика",
"num": 36 "num": 37
}, },
{ {
"name": "37. LCD экран 1602", "name": "38. LCD экран 1602",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -500,6 +514,6 @@
"size": "16,2", "size": "16,2",
"coord": "0,0", "coord": "0,0",
"id2show": "id датчика", "id2show": "id датчика",
"num": 37 "num": 38
} }
] ]

View File

@@ -35,7 +35,7 @@
#define USE_LITTLEFS false #define USE_LITTLEFS false
#endif #endif
#define START_DATETIME 1640995200 // 01.01.2022 00:00:00 константа для сокращения unix time #define START_DATETIME 1661990400 // 01.09.2022 00:00:00 константа для сокращения unix time
#define MIN_DATETIME 1575158400 #define MIN_DATETIME 1575158400
#define LEAP_YEAR(Y) (((1970 + Y) > 0) && !((1970 + Y) % 4) && (((1970 + Y) % 100) || !((1970 + Y) % 400))) #define LEAP_YEAR(Y) (((1970 + Y) > 0) && !((1970 + Y) % 4) && (((1970 + Y) % 100) || !((1970 + Y) % 400)))

View File

@@ -21,7 +21,7 @@
}, },
"projectProp": { "projectProp": {
"platformio": { "platformio": {
"default_envs": "esp8266_4mb", "default_envs": "esp32_4mb",
"data_dir": "data_svelte" "data_dir": "data_svelte"
} }
}, },

View File

@@ -40,7 +40,7 @@ build_src_filter =
${env:esp32_4mb_fromitems.build_src_filter} ${env:esp32_4mb_fromitems.build_src_filter}
[platformio] [platformio]
default_envs = esp8266_4mb default_envs = esp32_4mb
data_dir = data_svelte data_dir = data_svelte
[common_env_data] [common_env_data]
@@ -135,5 +135,6 @@ build_src_filter =
+<modules\exec\Mcp23017> +<modules\exec\Mcp23017>
+<modules\exec\Mp3> +<modules\exec\Mp3>
+<modules\exec\Pwm32> +<modules\exec\Pwm32>
+<modules\exec\TelegramLT>
+<modules\display\Lcd2004> +<modules\display\Lcd2004>

View File

@@ -22,7 +22,7 @@ void* getAPI_ButtonOut(String subtype, String params);
void* getAPI_IoTServo(String subtype, String params); void* getAPI_IoTServo(String subtype, String params);
void* getAPI_Mcp23017(String subtype, String params); void* getAPI_Mcp23017(String subtype, String params);
void* getAPI_Mp3(String subtype, String params); void* getAPI_Mp3(String subtype, String params);
void* getAPI_Pwm8266(String subtype, String params); void* getAPI_Pwm32(String subtype, String params);
void* getAPI_TelegramLT(String subtype, String params); void* getAPI_TelegramLT(String subtype, String params);
void* getAPI_Lcd2004(String subtype, String params); void* getAPI_Lcd2004(String subtype, String params);
@@ -50,7 +50,7 @@ if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_IoTServo(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_IoTServo(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Pwm8266(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Pwm32(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_TelegramLT(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_TelegramLT(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI;
return nullptr; return nullptr;

View File

@@ -11,7 +11,7 @@ class Loging : public IoTItem {
int points; int points;
int keepdays; int keepdays;
int interval; unsigned long interval;
bool firstTime = true; bool firstTime = true;
public: public:
@@ -24,6 +24,7 @@ class Loging : public IoTItem {
SerialPrint("E", F("Loging"), "'" + id + "' user set more points than allowed, value reset to 300"); SerialPrint("E", F("Loging"), "'" + id + "' user set more points than allowed, value reset to 300");
} }
jsonRead(parameters, F("int"), interval); jsonRead(parameters, F("int"), interval);
interval = interval * 1000 * 60;
jsonRead(parameters, F("keepdays"), keepdays); jsonRead(parameters, F("keepdays"), keepdays);
} }
@@ -31,6 +32,17 @@ class Loging : public IoTItem {
return ""; return "";
} }
void loop() {
if (enableDoByInt) {
currentMillis = millis();
difference = currentMillis - prevMillis;
if (difference >= interval) {
prevMillis = millis();
this->doByInterval();
}
}
}
void doByInterval() { void doByInterval() {
//если объект логгирования не был создан //если объект логгирования не был создан
if (!isItemExist(logid)) { if (!isItemExist(logid)) {
@@ -267,6 +279,8 @@ class Loging : public IoTItem {
int calculateMaxCount() { int calculateMaxCount() {
return 86400 / interval; return 86400 / interval;
} }
// new Variable(param);
}; };
void *getAPI_Loging(String subtype, String param) { void *getAPI_Loging(String subtype, String param) {

View File

@@ -9,8 +9,8 @@
"widget": "chart1", "widget": "chart1",
"page": "Графики", "page": "Графики",
"descr": "График", "descr": "График",
"int": 60, "int": 1,
"logid": "tmp", "logid": "t",
"num": 1, "num": 1,
"points": 300, "points": 300,
"keepdays": 2 "keepdays": 2
@@ -22,10 +22,10 @@
"authorGit": "https://github.com/DmitryBorisenko33", "authorGit": "https://github.com/DmitryBorisenko33",
"specialThanks": "", "specialThanks": "",
"moduleName": "Loging", "moduleName": "Loging",
"moduleVersion": "1.0", "moduleVersion": "2.0",
"moduleDesc": "Расширение позволяющее логировать любую величину в график. Графики доступны в мобильном приложении и в веб интерфейсе", "moduleDesc": "Расширение позволяющее логировать любую величину в график. Графики доступны в мобильном приложении и в веб интерфейсе",
"propInfo": { "propInfo": {
"int": "Интервал логирования", "int": "Интервал логирования в мнутах, рекомендуется для esp8266 использоать интервал не менее 5ти минут.",
"logid": "ID величины которую будем логировать", "logid": "ID величины которую будем логировать",
"points": "Максимальное количество точек в одном файле, может быть не более 300", "points": "Максимальное количество точек в одном файле, может быть не более 300",
"keepdays": "Количество дней за которое необходимо хранить историю. Данные старее будут удалены автоматически" "keepdays": "Количество дней за которое необходимо хранить историю. Данные старее будут удалены автоматически"

View File

@@ -11,8 +11,8 @@
"descr": "Таймер", "descr": "Таймер",
"int": 1, "int": 1,
"countDown": 15, "countDown": 15,
"ticker": 0, "ticker": 1,
"repeat": 0, "repeat": 1,
"needSave": 0, "needSave": 0,
"num": 1 "num": 1
} }
@@ -33,22 +33,22 @@
"needSave": "Требуется сохранять(1) или нет(0) состояние в энерго независимую память. Функция находится в разработке." "needSave": "Требуется сохранять(1) или нет(0) состояние в энерго независимую память. Функция находится в разработке."
}, },
"funcInfo": [ "funcInfo": [
{ {
"name": "stop", "name": "stop",
"descr": "Поставить процесс на паузу, при этом не будет событий и не будет уменьшаться счетчик.", "descr": "Поставить процесс на паузу, при этом не будет событий и не будет уменьшаться счетчик.",
"params": [] "params": []
}, },
{ {
"name": "reset", "name": "reset",
"descr": "Вернуть таймер к началу, установленному в countDown.", "descr": "Вернуть таймер к началу, установленному в countDown.",
"params": [] "params": []
}, },
{ {
"name": "continue", "name": "continue",
"descr": "Продолжить выполнение с момента остановки.", "descr": "Продолжить выполнение с момента остановки.",
"params": [] "params": []
}, },
{ {
"name": "int", "name": "int",
"descr": "Можно изменить шаг тиков.", "descr": "Можно изменить шаг тиков.",
"params": [] "params": []

View File

@@ -36,6 +36,18 @@
"int": "0", "int": "0",
"val": "24.05.2022", "val": "24.05.2022",
"num": 4 "num": 4
},
{
"name": "Окно ввода текста",
"type": "Reading",
"subtype": "Variable",
"id": "txt",
"widget": "inputTxt",
"page": "Ввод",
"descr": "Введите текст",
"int": "0",
"val": "текст",
"num": 5
} }
], ],
"about": { "about": {