исправление бага графиков с датой

This commit is contained in:
Dmitry Borisenko
2022-10-11 22:33:42 +02:00
parent 1726dafb18
commit b61cfca3ed
9 changed files with 165 additions and 104 deletions

2
.gitignore vendored
View File

@@ -3,4 +3,6 @@
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
/myProfile_wm.json
/myProfile.json
data_svelte/settings.json

View File

@@ -276,7 +276,58 @@
"num": 20
},
{
"name": "21. GY21 Температура",
"name": "21. Частотомер на ADC, Частота",
"type": "Reading",
"subtype": "FreqMeterF",
"id": "freq",
"widget": "anydataHtz",
"page": "Частотомер",
"descr": "Частота",
"plus": 0,
"multiply": 1,
"round": 1,
"pin-Esp32": 33,
"samples": 512,
"samplingFrequency": 5000,
"int": 5,
"num": 21
},
{
"name": "22. Частотомер на ADC, Процент Пульсации",
"type": "Reading",
"subtype": "FreqMeterPcFl",
"id": "pctFlicker",
"widget": "anydataPct",
"page": "Частотомер",
"descr": "Процент Пульсации",
"plus": 0,
"multiply": 1,
"round": 1,
"pin-Esp32": 33,
"samples": 512,
"samplingFrequency": 5000,
"int": 5,
"num": 22
},
{
"name": "23. Частотомер на ADC, Индекс Пульсации",
"type": "Reading",
"subtype": "FreqMeterFlIn",
"id": "flickerIndex",
"widget": "anydataDef",
"page": "Частотомер",
"descr": "Индекс Пульсации",
"plus": 0,
"multiply": 1,
"round": 10,
"pin-Esp32": 33,
"samples": 512,
"samplingFrequency": 5000,
"int": 5,
"num": 23
},
{
"name": "24. GY21 Температура",
"type": "Reading",
"subtype": "GY21t",
"id": "tmp4",
@@ -285,10 +336,10 @@
"descr": "Температура",
"round": 1,
"int": 15,
"num": 21
"num": 24
},
{
"name": "22. GY21 Влажность",
"name": "25. GY21 Влажность",
"type": "Reading",
"subtype": "GY21h",
"id": "Hum4",
@@ -297,10 +348,10 @@
"descr": "Влажность",
"round": 1,
"int": 15,
"num": 22
"num": 25
},
{
"name": "23. HDC1080 Температура",
"name": "26. HDC1080 Температура",
"type": "Reading",
"subtype": "Hdc1080t",
"id": "Temp1080",
@@ -310,10 +361,10 @@
"int": 15,
"addr": "0x40",
"round": 1,
"num": 23
"num": 26
},
{
"name": "24. HDC1080 Влажность",
"name": "27. HDC1080 Влажность",
"type": "Reading",
"subtype": "Hdc1080h",
"id": "Hum1080",
@@ -323,10 +374,10 @@
"int": 15,
"addr": "0x40",
"round": 1,
"num": 24
"num": 27
},
{
"name": "25. MAX6675 Температура",
"name": "28. MAX6675 Температура",
"type": "Reading",
"subtype": "Max6675t",
"id": "maxtmp",
@@ -337,10 +388,10 @@
"DO": 12,
"CS": 13,
"CLK": 14,
"num": 25
"num": 28
},
{
"name": "26. PZEM 004t Напряжение",
"name": "29. PZEM 004t Напряжение",
"type": "Reading",
"subtype": "Pzem004v",
"id": "v",
@@ -350,10 +401,10 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 26
"num": 29
},
{
"name": "27. PZEM 004t Сила тока",
"name": "30. PZEM 004t Сила тока",
"type": "Reading",
"subtype": "Pzem004a",
"id": "a",
@@ -363,10 +414,10 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 27
"num": 30
},
{
"name": "28. PZEM 004t Мощность",
"name": "31. PZEM 004t Мощность",
"type": "Reading",
"subtype": "Pzem004w",
"id": "w",
@@ -376,10 +427,10 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 28
"num": 31
},
{
"name": "29. PZEM 004t Энергия",
"name": "32. PZEM 004t Энергия",
"type": "Reading",
"subtype": "Pzem004wh",
"id": "wh",
@@ -389,10 +440,10 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 29
"num": 32
},
{
"name": "30. PZEM 004t Частота",
"name": "33. PZEM 004t Частота",
"type": "Reading",
"subtype": "Pzem004hz",
"id": "hz",
@@ -402,10 +453,10 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 30
"num": 33
},
{
"name": "31. PZEM 004t Косинус",
"name": "34. PZEM 004t Косинус",
"type": "Reading",
"subtype": "Pzem004pf",
"id": "pf",
@@ -415,11 +466,11 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 31
"num": 34
},
{
"name": "32. Сканер кнопок 433 MHz",
"num": 32,
"name": "35. Сканер кнопок 433 MHz",
"num": 35,
"type": "Reading",
"subtype": "RCswitch",
"id": "rsw",
@@ -428,7 +479,7 @@
"pinTx": 12
},
{
"name": "33. Sht20 Температура",
"name": "36. Sht20 Температура",
"type": "Reading",
"subtype": "Sht20t",
"id": "tmp2",
@@ -437,10 +488,10 @@
"descr": "Температура",
"int": 15,
"round": 1,
"num": 33
"num": 36
},
{
"name": "34. Sht20 Влажность",
"name": "37. Sht20 Влажность",
"type": "Reading",
"subtype": "Sht20h",
"id": "Hum2",
@@ -449,10 +500,10 @@
"descr": "Влажность",
"int": 15,
"round": 1,
"num": 34
"num": 37
},
{
"name": "35. Sht30 Температура",
"name": "38. Sht30 Температура",
"type": "Reading",
"subtype": "Sht30t",
"id": "tmp30",
@@ -461,10 +512,10 @@
"descr": "SHT30 Температура",
"int": 15,
"round": 1,
"num": 35
"num": 38
},
{
"name": "36. Sht30 Влажность",
"name": "39. Sht30 Влажность",
"type": "Reading",
"subtype": "Sht30h",
"id": "Hum30",
@@ -473,11 +524,11 @@
"descr": "SHT30 Влажность",
"int": 15,
"round": 1,
"num": 36
"num": 39
},
{
"name": "37. HC-SR04 Ультразвуковой дальномер",
"num": 37,
"name": "40. HC-SR04 Ультразвуковой дальномер",
"num": 40,
"type": "Reading",
"subtype": "Sonar",
"id": "sonar",
@@ -489,7 +540,7 @@
"int": 5
},
{
"name": "38. UART",
"name": "41. UART",
"type": "Reading",
"subtype": "UART",
"page": "",
@@ -499,13 +550,13 @@
"tx": 12,
"rx": 13,
"speed": 9600,
"num": 38
"num": 41
},
{
"header": "Исполнительные устройства"
},
{
"name": "39. Кнопка подключенная к пину",
"name": "42. Кнопка подключенная к пину",
"type": "Writing",
"subtype": "ButtonIn",
"id": "btn",
@@ -518,10 +569,10 @@
"pinMode": "INPUT",
"debounceDelay": 50,
"fixState": 0,
"num": 39
"num": 42
},
{
"name": "40. Управление пином",
"name": "43. Управление пином",
"type": "Writing",
"subtype": "ButtonOut",
"id": "btn",
@@ -531,10 +582,10 @@
"int": 0,
"inv": 0,
"pin": 2,
"num": 40
"num": 43
},
{
"name": "41. Сервопривод",
"name": "44. Сервопривод",
"type": "Writing",
"subtype": "IoTServo",
"id": "servo",
@@ -545,10 +596,10 @@
"pin": 12,
"apin": -1,
"amap": "0, 4096, 0, 180",
"num": 41
"num": 44
},
{
"name": "42. Расширитель портов Mcp23017",
"name": "45. Расширитель портов Mcp23017",
"type": "Reading",
"subtype": "Mcp23017",
"id": "Mcp",
@@ -558,10 +609,10 @@
"int": "0",
"addr": "0x20",
"index": 1,
"num": 42
"num": 45
},
{
"name": "43. MP3 плеер",
"name": "46. MP3 плеер",
"type": "Reading",
"subtype": "Mp3",
"id": "mp3",
@@ -571,10 +622,10 @@
"int": 1,
"pins": "14,12",
"volume": 20,
"num": 43
"num": 46
},
{
"name": "44. Расширитель портов Pcf8574",
"name": "47. Расширитель портов Pcf8574",
"type": "Reading",
"subtype": "Pcf8574",
"id": "Pcf",
@@ -584,25 +635,27 @@
"int": "0",
"addr": "0x20",
"index": 1,
"num": 44
"num": 47
},
{
"name": "45. PWM ESP8266",
"name": "48. PWM ESP32",
"type": "Writing",
"subtype": "Pwm8266",
"subtype": "Pwm32",
"id": "pwm",
"widget": "range",
"page": "Кнопки",
"descr": "PWM",
"int": 0,
"pin": 15,
"pin": 2,
"freq": 5000,
"ledChannel": 2,
"PWM_resolution": 10,
"val": 0,
"apin": -1,
"num": 45
"num": 48
},
{
"name": "46. Телеграм-Лайт",
"name": "49. Телеграм-Лайт",
"type": "Writing",
"subtype": "TelegramLT",
"id": "tg",
@@ -611,13 +664,13 @@
"descr": "",
"token": "",
"chatID": "",
"num": 46
"num": 49
},
{
"header": "Экраны"
},
{
"name": "47. LCD экран 2004",
"name": "50. LCD экран 2004",
"type": "Reading",
"subtype": "Lcd2004",
"id": "Lcd",
@@ -629,10 +682,10 @@
"size": "20,4",
"coord": "0,0",
"id2show": "id датчика",
"num": 47
"num": 50
},
{
"name": "48. LCD экран 1602",
"name": "51. LCD экран 1602",
"type": "Reading",
"subtype": "Lcd2004",
"id": "Lcd",
@@ -644,6 +697,6 @@
"size": "16,2",
"coord": "0,0",
"id2show": "id датчика",
"num": 48
"num": 51
}
]

View File

@@ -18,5 +18,6 @@
"mqttin": 0,
"pinSCL": 0,
"pinSDA": 0,
"i2cFreq": 100000
"i2cFreq": 100000,
"settings_": ""
}

View File

@@ -17,5 +17,5 @@ void publishStatusWs(const String& topic, const String& data);
void publishChartWs(int num, String& path);
void periodicWsSend();
void sendFileToWsByFrames(const String& filename, const String& header, const String& json, uint8_t client_id, size_t frameSize);
void sendFileToWsByFrames(const String& filename, const String& header, const String& json, int client_id, size_t frameSize);
void sendStringToWs(const String& header, String& payload, int client_id);

View File

@@ -24,7 +24,7 @@
},
"projectProp": {
"platformio": {
"default_envs": "esp8266_4mb",
"default_envs": "esp32_4mb",
"data_dir": "data_svelte"
}
},
@@ -90,7 +90,7 @@
},
{
"path": "src/modules/sensors/FreqMeter",
"active": false
"active": true
},
{
"path": "src/modules/sensors/GY21",

View File

@@ -41,7 +41,7 @@ build_src_filter =
${env:esp32_4mb_fromitems.build_src_filter}
[platformio]
default_envs = esp8266_4mb
default_envs = esp32_4mb
data_dir = data_svelte
[common_env_data]
@@ -57,6 +57,7 @@ lib_deps =
adafruit/Adafruit BMP280 Library
beegee-tokyo/DHT sensor library for ESPx
milesburton/DallasTemperature@^3.9.1
kosme/arduinoFFT@^1.5.6
https://github.com/JonasGMorsch/GY-21.git
ClosedCube HDC1080
adafruit/MAX6675 library
@@ -82,6 +83,7 @@ build_src_filter =
+<modules/sensors/Bmp280>
+<modules/sensors/Dht1122>
+<modules/sensors/Ds18b20>
+<modules/sensors/FreqMeter>
+<modules/sensors/GY21>
+<modules/sensors/Hdc1080>
+<modules/sensors/Max6675>
@@ -103,15 +105,15 @@ build_src_filter =
[env:esp32_4mb_fromitems]
lib_deps =
Adafruit AHTX0
https://github.com/enjoyneering/AHTxx.git
adafruit/Adafruit BME280 Library
adafruit/Adafruit BMP280 Library
beegee-tokyo/DHT sensor library for ESPx
milesburton/DallasTemperature@^3.9.1
kosme/arduinoFFT@^1.5.6
https://github.com/JonasGMorsch/GY-21.git
ClosedCube HDC1080
adafruit/MAX6675 library
mandulaj/PZEM-004T-v30
rc-switch @ ^2.6.4
robtillaart/SHT2x@^0.1.1
WEMOS SHT3x@1.0.0
@@ -120,35 +122,38 @@ lib_deps =
adafruit/Adafruit MCP23017 Arduino Library@^2.1.0
adafruit/Adafruit BusIO @ ^1.13.2
dfrobot/DFRobotDFPlayerMini @ ^1.0.5
adafruit/Adafruit BusIO @ ^1.13.2
marcoschwartz/LiquidCrystal_I2C@^1.1.4
build_src_filter =
+<modules\virtual\Loging>
+<modules\virtual\LogingDaily>
+<modules\virtual\Timer>
+<modules\virtual\Variable>
+<modules\virtual\VButton>
+<modules\sensors\Acs712>
+<modules\sensors\Aht20>
+<modules\sensors\AnalogAdc>
+<modules\sensors\Bme280>
+<modules\sensors\Bmp280>
+<modules\sensors\Dht1122>
+<modules\sensors\Ds18b20>
+<modules\sensors\GY21>
+<modules\sensors\Hdc1080>
+<modules\sensors\Max6675>
+<modules\sensors\Pzem004t>
+<modules\sensors\RCswitch>
+<modules\sensors\Sht20>
+<modules\sensors\Sht30>
+<modules\sensors\Sonar>
+<modules\sensors\UART>
+<modules\exec\ButtonIn>
+<modules\exec\ButtonOut>
+<modules\exec\IoTServo>
+<modules\exec\Mcp23017>
+<modules\exec\Mp3>
+<modules\exec\Pwm32>
+<modules\exec\TelegramLT>
+<modules\display\Lcd2004>
+<modules/virtual/Loging>
+<modules/virtual/LogingDaily>
+<modules/virtual/Timer>
+<modules/virtual/Variable>
+<modules/virtual/VButton>
+<modules/sensors/Acs712>
+<modules/sensors/AhtXX>
+<modules/sensors/AnalogAdc>
+<modules/sensors/Bme280>
+<modules/sensors/Bmp280>
+<modules/sensors/Dht1122>
+<modules/sensors/Ds18b20>
+<modules/sensors/FreqMeter>
+<modules/sensors/GY21>
+<modules/sensors/Hdc1080>
+<modules/sensors/Max6675>
+<modules/sensors/Pzem004t>
+<modules/sensors/RCswitch>
+<modules/sensors/Sht20>
+<modules/sensors/Sht30>
+<modules/sensors/Sonar>
+<modules/sensors/UART>
+<modules/exec/ButtonIn>
+<modules/exec/ButtonOut>
+<modules/exec/IoTServo>
+<modules/exec/Mcp23017>
+<modules/exec/Mp3>
+<modules/exec/Pcf8574>
+<modules/exec/Pwm32>
+<modules/exec/TelegramLT>
+<modules/display/Lcd2004>

View File

@@ -27,10 +27,6 @@ void handleOrder() {
String id = selectToMarker(order, " ");
//это модификатор для даты графика
// if (id.endsWith("-date")) {
//}
//здесь нужно перебрать все методы execute всех векторов и выполнить те id которых совпали с id события
IoTItem* item = findIoTItem(id);
if (item) {

View File

@@ -292,7 +292,7 @@ void hexdump(const void* mem, uint32_t len, uint8_t cols = 16) {
#endif
#endif
void sendFileToWsByFrames(const String& filename, const String& header, const String& json, uint8_t client_id, size_t frameSize) {
void sendFileToWsByFrames(const String& filename, const String& header, const String& json, int client_id, size_t frameSize) {
if (header.length() != 6) {
SerialPrint("E", "FS", F("wrong header size"));
return;
@@ -305,8 +305,8 @@ void sendFileToWsByFrames(const String& filename, const String& header, const St
return;
}
// size_t totalSize = file.size();
// Serial.println("Send file '" + String(filename) + "', file size: " + String(totalSize));
size_t totalSize = file.size();
Serial.println("Send file '" + String(filename) + "', file size: " + String(totalSize));
char buf[32];
sprintf(buf, "%04d", json.length() + 12);
@@ -346,9 +346,11 @@ void sendFileToWsByFrames(const String& filename, const String& header, const St
continuation = true;
}
// Serial.println(String(i) + ") fr sz: " + String(size) + " fin: " + String(fin) + " cnt: " + String(continuation));
Serial.println(String(i) + ") " + "ws: " + String(client_id) + " fr sz: " + String(size) + " fin: " + String(fin) + " cnt: " + String(continuation));
if (client_id == -1) {
standWebSocket.broadcastBIN(frameBuf, size, fin, continuation);
} else {
standWebSocket.sendBIN(client_id, frameBuf, size, fin, continuation);
}

View File

@@ -12,6 +12,7 @@ void* getAPI_Bme280(String subtype, String params);
void* getAPI_Bmp280(String subtype, String params);
void* getAPI_Dht1122(String subtype, String params);
void* getAPI_Ds18b20(String subtype, String params);
void* getAPI_FreqMeter(String subtype, String params);
void* getAPI_GY21(String subtype, String params);
void* getAPI_Hdc1080(String subtype, String params);
void* getAPI_Max6675(String subtype, String params);
@@ -27,7 +28,7 @@ void* getAPI_IoTServo(String subtype, String params);
void* getAPI_Mcp23017(String subtype, String params);
void* getAPI_Mp3(String subtype, String params);
void* getAPI_Pcf8574(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_Lcd2004(String subtype, String params);
@@ -45,6 +46,7 @@ if ((tmpAPI = getAPI_Bme280(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Bmp280(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Dht1122(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Ds18b20(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_FreqMeter(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_GY21(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Hdc1080(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Max6675(subtype, params)) != nullptr) return tmpAPI;
@@ -60,7 +62,7 @@ if ((tmpAPI = getAPI_IoTServo(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_Pcf8574(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_Lcd2004(subtype, params)) != nullptr) return tmpAPI;
return nullptr;