переход на асинхронный ws

This commit is contained in:
Dmitry Borisenko
2022-11-23 15:10:58 +01:00
parent 8507aaf1e6
commit c9d0d0360f
10 changed files with 132 additions and 225 deletions

View File

@@ -333,76 +333,7 @@
},
{
"global": 0,
"name": "23. GY21 Температура",
"type": "Reading",
"subtype": "GY21t",
"id": "tmp4",
"widget": "anydataTmp",
"page": "Сенсоры",
"descr": "Температура",
"round": 1,
"int": 15,
"num": 23
},
{
"global": 0,
"name": "24. GY21 Влажность",
"type": "Reading",
"subtype": "GY21h",
"id": "Hum4",
"widget": "anydataHum",
"page": "Сенсоры",
"descr": "Влажность",
"round": 1,
"int": 15,
"num": 24
},
{
"global": 0,
"name": "25. HDC1080 Температура",
"type": "Reading",
"subtype": "Hdc1080t",
"id": "Temp1080",
"widget": "anydataTmp",
"page": "Сенсоры",
"descr": "1080 Температура",
"int": 15,
"addr": "0x40",
"round": 1,
"num": 25
},
{
"global": 0,
"name": "26. HDC1080 Влажность",
"type": "Reading",
"subtype": "Hdc1080h",
"id": "Hum1080",
"widget": "anydataHum",
"page": "Сенсоры",
"descr": "1080 Влажность",
"int": 15,
"addr": "0x40",
"round": 1,
"num": 26
},
{
"global": 0,
"name": "27. MAX6675 Температура",
"type": "Reading",
"subtype": "Max6675t",
"id": "maxtmp",
"widget": "anydataTmp",
"page": "Сенсоры",
"descr": "MAX Температура",
"int": 15,
"DO": 12,
"CS": 13,
"CLK": 14,
"num": 27
},
{
"global": 0,
"name": "28. PZEM 004t Напряжение",
"name": "23. PZEM 004t Напряжение",
"type": "Reading",
"subtype": "Pzem004v",
"id": "v",
@@ -412,11 +343,11 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 28
"num": 23
},
{
"global": 0,
"name": "29. PZEM 004t Сила тока",
"name": "24. PZEM 004t Сила тока",
"type": "Reading",
"subtype": "Pzem004a",
"id": "a",
@@ -426,11 +357,11 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 29
"num": 24
},
{
"global": 0,
"name": "30. PZEM 004t Мощность",
"name": "25. PZEM 004t Мощность",
"type": "Reading",
"subtype": "Pzem004w",
"id": "w",
@@ -440,11 +371,11 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 30
"num": 25
},
{
"global": 0,
"name": "31. PZEM 004t Энергия",
"name": "26. PZEM 004t Энергия",
"type": "Reading",
"subtype": "Pzem004wh",
"id": "wh",
@@ -454,11 +385,11 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 31
"num": 26
},
{
"global": 0,
"name": "32. PZEM 004t Частота",
"name": "27. PZEM 004t Частота",
"type": "Reading",
"subtype": "Pzem004hz",
"id": "hz",
@@ -468,11 +399,11 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 32
"num": 27
},
{
"global": 0,
"name": "33. PZEM 004t Косинус",
"name": "28. PZEM 004t Косинус",
"type": "Reading",
"subtype": "Pzem004pf",
"id": "pf",
@@ -482,22 +413,11 @@
"int": 15,
"addr": "0xF8",
"round": 1,
"num": 33
"num": 28
},
{
"global": 0,
"name": "34. Сканер кнопок 433 MHz",
"num": 34,
"type": "Reading",
"subtype": "RCswitch",
"id": "rsw",
"int": 500,
"pinRx": 12,
"pinTx": 12
},
{
"global": 0,
"name": "35. Sht20 Температура",
"name": "29. Sht20 Температура",
"type": "Reading",
"subtype": "Sht20t",
"id": "tmp2",
@@ -506,11 +426,11 @@
"descr": "Температура",
"int": 15,
"round": 1,
"num": 35
"num": 29
},
{
"global": 0,
"name": "36. Sht20 Влажность",
"name": "30. Sht20 Влажность",
"type": "Reading",
"subtype": "Sht20h",
"id": "Hum2",
@@ -519,11 +439,11 @@
"descr": "Влажность",
"int": 15,
"round": 1,
"num": 36
"num": 30
},
{
"global": 0,
"name": "37. Sht30 Температура",
"name": "31. Sht30 Температура",
"type": "Reading",
"subtype": "Sht30t",
"id": "tmp30",
@@ -532,11 +452,11 @@
"descr": "SHT30 Температура",
"int": 15,
"round": 1,
"num": 37
"num": 31
},
{
"global": 0,
"name": "38. Sht30 Влажность",
"name": "32. Sht30 Влажность",
"type": "Reading",
"subtype": "Sht30h",
"id": "Hum30",
@@ -545,12 +465,12 @@
"descr": "SHT30 Влажность",
"int": 15,
"round": 1,
"num": 38
"num": 32
},
{
"global": 0,
"name": "39. HC-SR04 Ультразвуковой дальномер",
"num": 39,
"name": "33. HC-SR04 Ультразвуковой дальномер",
"num": 33,
"type": "Reading",
"subtype": "Sonar",
"id": "sonar",
@@ -562,7 +482,7 @@
"int": 5
},
{
"name": "40. UART",
"name": "34. UART",
"type": "Reading",
"subtype": "UART",
"page": "",
@@ -574,14 +494,14 @@
"line": 2,
"speed": 9600,
"eventFormat": 0,
"num": 40
"num": 34
},
{
"header": "Исполнительные устройства"
},
{
"global": 0,
"name": "41. Кнопка подключенная к пину",
"name": "35. Кнопка подключенная к пину",
"type": "Writing",
"subtype": "ButtonIn",
"id": "btn",
@@ -595,11 +515,11 @@
"pinMode": "INPUT",
"debounceDelay": 50,
"fixState": 0,
"num": 41
"num": 35
},
{
"global": 0,
"name": "42. Управление пином",
"name": "36. Управление пином",
"type": "Writing",
"subtype": "ButtonOut",
"needSave": 0,
@@ -610,11 +530,11 @@
"int": 0,
"inv": 0,
"pin": 2,
"num": 42
"num": 36
},
{
"global": 0,
"name": "43. Сервопривод",
"name": "37. Сервопривод",
"type": "Writing",
"subtype": "IoTServo",
"id": "servo",
@@ -625,11 +545,11 @@
"pin": 12,
"apin": -1,
"amap": "0, 4096, 0, 180",
"num": 43
"num": 37
},
{
"global": 0,
"name": "44. Расширитель портов Mcp23017",
"name": "38. Расширитель портов Mcp23017",
"type": "Reading",
"subtype": "Mcp23017",
"id": "Mcp",
@@ -639,11 +559,11 @@
"int": "0",
"addr": "0x20",
"index": 1,
"num": 44
"num": 38
},
{
"global": 0,
"name": "45. MP3 плеер",
"name": "39. MP3 плеер",
"type": "Reading",
"subtype": "Mp3",
"id": "mp3",
@@ -653,11 +573,11 @@
"int": 1,
"pins": "14,12",
"volume": 20,
"num": 45
"num": 39
},
{
"global": 0,
"name": "46. Сенсорная кнопка",
"name": "40. Сенсорная кнопка",
"type": "Writing",
"subtype": "Multitouch",
"id": "impulse",
@@ -671,11 +591,11 @@
"pinMode": "INPUT",
"debounceDelay": 50,
"PWMDelay": 500,
"num": 46
"num": 40
},
{
"global": 0,
"name": "47. Расширитель портов Pcf8574",
"name": "41. Расширитель портов Pcf8574",
"type": "Reading",
"subtype": "Pcf8574",
"id": "Pcf",
@@ -685,11 +605,11 @@
"int": "0",
"addr": "0x20",
"index": 1,
"num": 47
"num": 41
},
{
"global": 0,
"name": "48. PWM ESP8266",
"name": "42. PWM ESP8266",
"type": "Writing",
"subtype": "Pwm8266",
"id": "pwm",
@@ -701,11 +621,11 @@
"freq": 5000,
"val": 0,
"apin": -1,
"num": 48
"num": 42
},
{
"global": 0,
"name": "49. Телеграм-Лайт",
"name": "43. Телеграм-Лайт",
"type": "Writing",
"subtype": "TelegramLT",
"id": "tg",
@@ -714,14 +634,14 @@
"descr": "",
"token": "",
"chatID": "",
"num": 49
"num": 43
},
{
"header": "Экраны"
},
{
"global": 0,
"name": "50. LCD экран 2004",
"name": "44. LCD экран 2004",
"type": "Reading",
"subtype": "Lcd2004",
"id": "Lcd",
@@ -733,10 +653,10 @@
"size": "20,4",
"coord": "0,0",
"id2show": "id датчика",
"num": 50
"num": 44
},
{
"name": "51. LCD экран 1602",
"name": "45. LCD экран 1602",
"type": "Reading",
"subtype": "Lcd2004",
"id": "Lcd",
@@ -748,26 +668,6 @@
"size": "16,2",
"coord": "0,0",
"id2show": "id датчика",
"num": 51
},
{
"global": 0,
"name": "52. Strip ws2812b",
"type": "Reading",
"subtype": "Ws2812b",
"id": "strip",
"widget": "range",
"page": "Кнопки",
"descr": "Лента",
"int": 15,
"needSave": 0,
"pin": "4",
"numLeds": "8",
"brightness": "100",
"mode": "1",
"min": "15",
"max": "30",
"idshow": "t",
"num": 52
"num": 45
}
]

View File

@@ -26,9 +26,9 @@
//#define LOOP_DEBUG
//выбор сервера
//#define ASYNC_WEB_SERVER
#define ASYNC_WEB_SERVER
//#define ASYNC_WEB_SOCKETS
#define STANDARD_WEB_SERVER
//#define STANDARD_WEB_SERVER
#define STANDARD_WEB_SOCKETS
#define UDP_ENABLED

View File

@@ -101,11 +101,19 @@
},
{
"path": "src/modules/sensors/GY21",
"active": true
"active": false
},
{
"path": "src/modules/sensors/Hdc1080",
"active": true
"active": false
},
{
"path": "src/modules/sensors/Hx710",
"active": false
},
{
"path": "src/modules/sensors/Hx711",
"active": false
},
{
"path": "src/modules/sensors/Ina219",
@@ -117,7 +125,7 @@
},
{
"path": "src/modules/sensors/Max6675",
"active": true
"active": false
},
{
"path": "src/modules/sensors/Mhz19",
@@ -129,12 +137,16 @@
},
{
"path": "src/modules/sensors/RCswitch",
"active": true
"active": false
},
{
"path": "src/modules/sensors/Sds011",
"active": false
},
{
"path": "src/modules/sensors/Sgp30",
"active": false
},
{
"path": "src/modules/sensors/Sht20",
"active": true
@@ -217,7 +229,7 @@
},
{
"path": "src/modules/display/Ws2812b",
"active": true
"active": false
}
]
}

View File

@@ -90,6 +90,7 @@ data_dir = data_svelte
lib_deps_external =
bblanchon/ArduinoJson @6.18.0
knolleary/PubSubClient
me-no-dev/ESP Async WebServer
[env:esp8266_1mb_ota_fromitems]
lib_deps =
@@ -144,10 +145,6 @@ lib_deps =
adafruit/Adafruit BMP280 Library
beegee-tokyo/DHT sensor library for ESPx
milesburton/DallasTemperature@^3.9.1
https://github.com/JonasGMorsch/GY-21.git
ClosedCube HDC1080
adafruit/MAX6675 library
rc-switch @ ^2.6.4
robtillaart/SHT2x@^0.1.1
WEMOS SHT3x@1.0.0
plerup/espsoftwareserial
@@ -156,7 +153,6 @@ lib_deps =
dfrobot/DFRobotDFPlayerMini @ ^1.0.5
adafruit/Adafruit BusIO @ ^1.13.2
marcoschwartz/LiquidCrystal_I2C@^1.1.4
adafruit/Adafruit NeoPixel@^1.10.6
build_src_filter =
+<modules/virtual/Cron>
+<modules/virtual/Loging>
@@ -171,11 +167,7 @@ build_src_filter =
+<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>
@@ -190,7 +182,6 @@ build_src_filter =
+<modules/exec/Pwm8266>
+<modules/exec/TelegramLT>
+<modules/display/Lcd2004>
+<modules/display/Ws2812b>
[env:esp32_4mb_fromitems]
lib_deps =

View File

@@ -13,11 +13,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_GY21(String subtype, String params);
void* getAPI_Hdc1080(String subtype, String params);
void* getAPI_Max6675(String subtype, String params);
void* getAPI_Pzem004(String subtype, String params);
void* getAPI_RCswitch(String subtype, String params);
void* getAPI_Sht20(String subtype, String params);
void* getAPI_Sht30(String subtype, String params);
void* getAPI_Sonar(String subtype, String params);
@@ -32,7 +28,6 @@ void* getAPI_Pcf8574(String subtype, String params);
void* getAPI_Pwm8266(String subtype, String params);
void* getAPI_TelegramLT(String subtype, String params);
void* getAPI_Lcd2004(String subtype, String params);
void* getAPI_Ws2812b(String subtype, String params);
void* getAPI(String subtype, String params) {
void* tmpAPI;
@@ -49,11 +44,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_GY21(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Hdc1080(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Max6675(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Pzem004(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_RCswitch(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Sht20(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Sht30(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Sonar(subtype, params)) != nullptr) return tmpAPI;
@@ -68,6 +59,5 @@ if ((tmpAPI = getAPI_Pcf8574(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Pwm8266(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_Ws2812b(subtype, params)) != nullptr) return tmpAPI;
return nullptr;
}

View File

@@ -1,26 +1,26 @@
{
{
"menuSection": "Экраны",
"configItem": [
{
"global": 0,
"name": "Strip ws2812b",
"type": "Reading",
"subtype": "Ws2812b",
"id": "strip",
"widget": "range",
"page": "Кнопки",
"descr": "Лента",
"int": 15,
"needSave": 0,
"pin": "4",
"numLeds": "8",
"brightness": "100",
"mode": "1",
"min": "15",
"max": "30",
"idshow": "t"
}],
{
"global": 0,
"name": "Strip ws2812b",
"type": "Reading",
"subtype": "Ws2812b",
"id": "strip",
"widget": "range",
"page": "Кнопки",
"descr": "Лента",
"int": 15,
"needSave": 0,
"pin": "4",
"numLeds": "8",
"brightness": "100",
"mode": "1",
"min": "15",
"max": "30",
"idshow": "t"
}
],
"about": {
"authorName": "Yuriy Kuneev",
"authorContact": "https://t.me/Kuneev07",
@@ -44,7 +44,9 @@
{
"name": "noShow",
"descr": "Выключить ленту",
"params": ["номер пикселя"]
"params": [
"номер пикселя"
]
},
{
"name": "noShowOne",
@@ -59,17 +61,26 @@
{
"name": "showLed",
"descr": "Зажечь один диод",
"params": ["номер пикселя","цвет 255,255,255 или red,green"]
"params": [
"номер пикселя",
"цвет 255,255,255 или red,green"
]
},
{
"name": "showLedAll",
"descr": "Зажечь все диоды",
"params": ["Цвет красного светодиода от 0 до 255","Цвет зеленого светодиода от 0 до 255","Цвет синего светодиода от 0 до 255"]
"params": [
"Цвет красного светодиода от 0 до 255",
"Цвет зеленого светодиода от 0 до 255",
"Цвет синего светодиода от 0 до 255"
]
},
{
"name": "Brightness",
"descr": "Устанавливает общую яркость ленты от 0 до 255",
"params": ["яркость от 0 до 255"]
"params": [
"яркость от 0 до 255"
]
},
{
"name": "enableIndication",
@@ -83,15 +94,13 @@
}
]
},
"defActive": true,
"defActive": false,
"usedLibs": {
"esp32_4mb": [
"adafruit/Adafruit NeoPixel@^1.10.6"
],
"esp8266_4mb": [
"adafruit/Adafruit NeoPixel@^1.10.6"
"adafruit/Adafruit NeoPixel@^1.10.6"
]
}
}

View File

@@ -47,7 +47,7 @@
"int": "Количество секунд между опросами датчика."
}
},
"defActive": true,
"defActive": false,
"usedLibs": {
"esp32_4mb": [
"https://github.com/JonasGMorsch/GY-21.git"

View File

@@ -50,7 +50,7 @@
"int": "Количество секунд между опросами датчика."
}
},
"defActive": true,
"defActive": false,
"usedLibs": {
"esp32_4mb": [
"ClosedCube HDC1080"

View File

@@ -36,7 +36,7 @@
"int": "Количество секунд между опросами датчика."
}
},
"defActive": true,
"defActive": false,
"usedLibs": {
"esp32_4mb": [
"adafruit/MAX6675 library"

View File

@@ -1,18 +1,18 @@
{
{
"menuSection": "Сенсоры",
"configItem": [{
"global": 0,
"name": "Сканер кнопок 433 MHz",
"num": 31,
"type": "Reading",
"subtype": "RCswitch",
"id": "rsw",
"int": 500,
"pinRx": 12,
"pinTx": 12
}],
"configItem": [
{
"global": 0,
"name": "Сканер кнопок 433 MHz",
"num": 31,
"type": "Reading",
"subtype": "RCswitch",
"id": "rsw",
"int": 500,
"pinRx": 12,
"pinTx": 12
}
],
"about": {
"authorName": "Serghei Crasnicov",
"authorContact": "https://t.me/Serghei63",
@@ -36,23 +36,28 @@
{
"name": "sendBitStr",
"descr": "Отправляем строку вида 000000000001010100010001",
"params": ["Строка 000000000001010100010001"]
"params": [
"Строка 000000000001010100010001"
]
},
{
"name": "sendTriState",
"descr": "отправляем строку вида 00000FFF0F0F",
"params": ["Строка 00000FFF0F0F"]
"params": [
"Строка 00000FFF0F0F"
]
},
{
"name": "sendDecimal",
"descr": "отправляем строку вида 5393",
"params": ["Код в виде числа", "Количество бит чтоб заполнить нулями"]
"params": [
"Код в виде числа",
"Количество бит чтоб заполнить нулями"
]
}
]
},
"defActive": true,
"defActive": false,
"usedLibs": {
"esp32_4mb": [
"rc-switch @ ^2.6.4"