From 29a2762788d6c10611fb01f08a675f9d049ccd8d Mon Sep 17 00:00:00 2001 From: biver Date: Thu, 19 May 2022 08:20:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BF=D1=83=D1=81=D0=BA=D0=B0=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D1=83=D0=BB=D0=B5=D0=B9=20=D0=BF=D1=80=D0=B8=20=D1=81?= =?UTF-8?q?=D0=B1=D0=BE=D1=80=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- accembleItems.py | 2 + data_svelte/items.json | 295 ++++++++++++++++++++++++++++++++++------- src/modules/API.cpp | 18 +++ 3 files changed, 266 insertions(+), 49 deletions(-) diff --git a/accembleItems.py b/accembleItems.py index 3ef6af89..9a382e49 100644 --- a/accembleItems.py +++ b/accembleItems.py @@ -28,6 +28,8 @@ def getDirs(path): excludeDirs = excludeDirs + "\n-<" + maybeDir + ">" else: yield file + else: + yield file def getPIOLibs(patch): diff --git a/data_svelte/items.json b/data_svelte/items.json index 0b71d33e..a4ccfb6c 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -7,9 +7,26 @@ "header": "Расширения" }, { - "name": "1. Расширитель портов Mcp23017", + "name": "1. Поддержка DS1302(1), DS1307(2), DS3231(3), RX8025(4)", "num": 1, "type": "Reading", + "subtype": "IarduinoRTC", + "id": "RTC", + "widget": "", + "page": "", + "descr": "", + "int": "1", + "chipNum": 1, + "rst": 16, + "clk": 5, + "dat": 4, + "defFormat": "d-m-Y", + "ticker": 0 + }, + { + "name": "2. Расширитель портов Mcp23017", + "num": 2, + "type": "Reading", "subtype": "Mcp23017", "id": "Mcp", "widget": "", @@ -19,12 +36,64 @@ "addr": "0x20", "index": 1 }, + { + "name": "3. Доп. функции системы", + "num": 3, + "type": "Reading", + "subtype": "SysExt", + "id": "SysExt", + "widget": "", + "page": "", + "descr": "", + "int": 15 + }, + { + "name": "4. Переменная", + "num": 4, + "type": "Reading", + "subtype": "Variable", + "id": "var", + "widget": "", + "page": "", + "descr": "", + "int": "0", + "val": "0" + }, { "header": "Модули управления" }, { - "name": "2. MP3 плеер", - "num": 2, + "name": "5. Кнопка (подключенная физически)", + "num": 5, + "type": "Writing", + "subtype": "ButtonIn", + "id": "btn", + "widget": "toggle", + "page": "Кнопки", + "descr": "", + "int": 0, + "pin": 16, + "execLevel": "1", + "pinMode": "INPUT", + "debounceDelay": 50, + "fixState": 1 + }, + { + "name": "6. Кнопка управляющая пином (Реле с кнопкой)", + "num": 6, + "type": "Writing", + "subtype": "ButtonOut", + "id": "btn", + "widget": "toggle", + "page": "Кнопки", + "descr": "", + "int": 0, + "inv": 0, + "pin": 2 + }, + { + "name": "7. MP3 плеер", + "num": 7, "type": "Reading", "subtype": "Mp3", "id": "mp3", @@ -36,8 +105,8 @@ "volume": 20 }, { - "name": "3. Телеграм-Бот", - "num": 3, + "name": "8. Телеграм-Бот", + "num": 8, "type": "Writing", "subtype": "Telegram", "id": "tg", @@ -50,12 +119,27 @@ "receiveMsg": 0, "chatID": "" }, + { + "name": "9. Таймер", + "num": 9, + "type": "Writing", + "subtype": "Timer", + "id": "timer", + "widget": "", + "page": "", + "descr": "", + "int": 1, + "countDown": 15, + "ticker": 0, + "repeat": 0, + "needSave": 0 + }, { "header": "Сенсоры" }, { - "name": "4. Датчик напряжения ADS1115", - "num": 4, + "name": "10. Датчик напряжения ADS1115", + "num": 10, "type": "Reading", "subtype": "Ads1115", "id": "Ads3", @@ -71,8 +155,8 @@ "int": 10 }, { - "name": "5. Cенсор температуры AHT20", - "num": 5, + "name": "11. Cенсор температуры AHT20", + "num": 11, "type": "Reading", "subtype": "Aht20t", "id": "Temp20", @@ -84,8 +168,8 @@ "round": 1 }, { - "name": "6. Cенсор влажности AHT20", - "num": 6, + "name": "12. Cенсор влажности AHT20", + "num": 12, "type": "Reading", "subtype": "Aht20h", "id": "Hum20", @@ -97,8 +181,24 @@ "round": 1 }, { - "name": "7. Cенсор температуры Bme280", - "num": 7, + "name": "13. Аналоговый сенсор", + "num": 13, + "type": "Reading", + "subtype": "AnalogAdc", + "id": "t", + "widget": "anydataTmp", + "page": "Сенсоры", + "descr": "Температура", + "map": "1,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 1, + "pin": 0, + "int": 15 + }, + { + "name": "14. Cенсор температуры Bme280", + "num": 14, "type": "Reading", "subtype": "Bme280t", "id": "tmp3", @@ -110,8 +210,8 @@ "round": 1 }, { - "name": "8. Cенсор давления Bme280", - "num": 8, + "name": "15. Cенсор давления Bme280", + "num": 15, "type": "Reading", "subtype": "Bme280p", "id": "Press3", @@ -123,8 +223,8 @@ "round": 1 }, { - "name": "9. Cенсор влажности Bme280", - "num": 9, + "name": "16. Cенсор влажности Bme280", + "num": 16, "type": "Reading", "subtype": "Bme280h", "id": "Hum3", @@ -136,8 +236,8 @@ "round": 1 }, { - "name": "10. Cенсор температуры Bmp280", - "num": 10, + "name": "17. Cенсор температуры Bmp280", + "num": 17, "type": "Reading", "subtype": "Bmp280t", "id": "tmp3", @@ -149,8 +249,8 @@ "round": 1 }, { - "name": "11. Cенсор давления Bmp280", - "num": 11, + "name": "18. Cенсор давления Bmp280", + "num": 18, "type": "Reading", "subtype": "Bmp280p", "id": "Press3", @@ -162,8 +262,8 @@ "round": 1 }, { - "name": "12. Cенсор температуры dht11", - "num": 12, + "name": "19. Cенсор температуры dht11", + "num": 19, "type": "Reading", "subtype": "Dht1122t", "id": "tmp3", @@ -175,8 +275,8 @@ "senstype": "dht11" }, { - "name": "13. Cенсор влажности dht11", - "num": 13, + "name": "20. Cенсор влажности dht11", + "num": 20, "type": "Reading", "subtype": "Dht1122h", "id": "Hum3", @@ -188,8 +288,8 @@ "senstype": "dht11" }, { - "name": "14. Cенсор температуры ds18b20", - "num": 14, + "name": "21. Cенсор температуры ds18b20", + "num": 21, "type": "Reading", "subtype": "Ds18b20", "id": "dstmp", @@ -203,8 +303,8 @@ "round": 1 }, { - "name": "15. Cенсор температуры GY21", - "num": 15, + "name": "22. Cенсор температуры GY21", + "num": 22, "type": "Reading", "subtype": "GY21t", "id": "tmp4", @@ -215,8 +315,8 @@ "int": 15 }, { - "name": "16. Cенсор влажности GY21", - "num": 16, + "name": "23. Cенсор влажности GY21", + "num": 23, "type": "Reading", "subtype": "GY21h", "id": "Hum4", @@ -227,8 +327,8 @@ "int": 15 }, { - "name": "17. Cенсор температуры HDC1080", - "num": 17, + "name": "24. Cенсор температуры HDC1080", + "num": 24, "type": "Reading", "subtype": "Hdc1080t", "id": "Temp1080", @@ -240,8 +340,8 @@ "round": 1 }, { - "name": "18. Cенсор влажности HDC1080", - "num": 18, + "name": "25. Cенсор влажности HDC1080", + "num": 25, "type": "Reading", "subtype": "Hdc1080h", "id": "Hum1080", @@ -253,8 +353,8 @@ "round": 1 }, { - "name": "19. Cенсор температуры MAX6675", - "num": 19, + "name": "26. Cенсор температуры MAX6675", + "num": 26, "type": "Reading", "subtype": "Max6675t", "id": "maxtmp", @@ -267,8 +367,92 @@ "CLK": 14 }, { - "name": "20. Датчик пыли SDS011 PM25", - "num": 20, + "name": "27. Датчик CO2 MHZ-19 UART", + "num": 27, + "type": "Reading", + "subtype": "Mhz19uart", + "id": "co2uart", + "widget": "anydataPpm", + "page": "Сенсоры", + "descr": "CO2uart", + "plus": 0, + "multiply": 1, + "round": 1, + "pin": 0, + "rxPin": 14, + "txPin": 16, + "int": 15, + "range": 5000, + "ABC": 1 + }, + { + "name": "28. Датчик CO2 MHZ-19 PWM", + "num": 28, + "type": "Reading", + "subtype": "Mhz19pwm", + "id": "co2pwm", + "widget": "anydataPpm", + "page": "Сенсоры", + "descr": "CO2pwm", + "plus": 0, + "multiply": 1, + "round": 1, + "pin": 16, + "int": 300 + }, + { + "name": "29. Cенсор температуры от MHZ-19 UART", + "num": 29, + "type": "Reading", + "subtype": "Mhz19temp", + "id": "Mhz19temp", + "widget": "anydataTmp", + "page": "Сенсоры", + "descr": "Температура", + "plus": 0, + "multiply": 1, + "round": 1, + "rxPin": 14, + "txPin": 16, + "ABC": 1, + "int": 30 + }, + { + "name": "30. Рабочий диапазон от MHZ-19 UART", + "num": 30, + "type": "Reading", + "subtype": "Mhz19range", + "id": "Mhz19range", + "widget": "anydataPpm", + "page": "Сенсоры", + "descr": "Диапазон", + "plus": 0, + "multiply": 1, + "round": 1, + "rxPin": 14, + "txPin": 16, + "range": 5000, + "ABC": 1, + "int": 30 + }, + { + "name": "31. Автокалибровка от MHZ-19 UART", + "num": 31, + "type": "Reading", + "subtype": "Mhz19ABC", + "id": "Mhz19ABC", + "widget": "anydataDef", + "page": "Сенсоры", + "descr": "ABC", + "rxPin": 14, + "txPin": 16, + "range": 5000, + "ABC": 1, + "int": 30 + }, + { + "name": "32. Датчик пыли SDS011 PM25", + "num": 32, "type": "Reading", "subtype": "Sds011_25", "id": "pmuart25", @@ -285,8 +469,8 @@ "period": 300 }, { - "name": "21. Датчик пыли SDS011 PM10", - "num": 21, + "name": "33. Датчик пыли SDS011 PM10", + "num": 33, "type": "Reading", "subtype": "Sds011_10", "id": "pmuart10", @@ -303,8 +487,8 @@ "period": 300 }, { - "name": "22. Cенсор температуры Sht20", - "num": 22, + "name": "34. Cенсор температуры Sht20", + "num": 34, "type": "Reading", "subtype": "Sht20t", "id": "tmp2", @@ -315,8 +499,8 @@ "round": 1 }, { - "name": "23. Cенсор влажности Sht20", - "num": 23, + "name": "35. Cенсор влажности Sht20", + "num": 35, "type": "Reading", "subtype": "Sht20h", "id": "Hum2", @@ -326,12 +510,25 @@ "int": 15, "round": 1 }, + { + "name": "36. Сонар HC-SR04", + "num": 36, + "type": "Reading", + "subtype": "Sonar", + "id": "sonar", + "widget": "anydataTmp", + "page": "Сенсоры", + "descr": "Расстояние", + "pinTrig": 5, + "pinEcho": 4, + "int": 5 + }, { "header": "Экраны" }, { - "name": "24. LCD экран 2004", - "num": 24, + "name": "37. LCD экран 2004", + "num": 37, "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -345,8 +542,8 @@ "id2show": "id датчика" }, { - "name": "25. LCD экран 1602", - "num": 25, + "name": "38. LCD экран 1602", + "num": 38, "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", diff --git a/src/modules/API.cpp b/src/modules/API.cpp index 0e7e4a83..cb2ef008 100644 --- a/src/modules/API.cpp +++ b/src/modules/API.cpp @@ -1,10 +1,17 @@ #include "ESPConfiguration.h" +void* getAPI_IarduinoRTC(String subtype, String params); void* getAPI_Mcp23017(String subtype, String params); +void* getAPI_SysExt(String subtype, String params); +void* getAPI_Variable(String subtype, String params); +void* getAPI_ButtonIn(String subtype, String params); +void* getAPI_ButtonOut(String subtype, String params); void* getAPI_Mp3(String subtype, String params); void* getAPI_Telegram(String subtype, String params); +void* getAPI_Timer(String subtype, String params); void* getAPI_Ads1115(String subtype, String params); void* getAPI_Aht20(String subtype, String params); +void* getAPI_AnalogAdc(String subtype, String params); void* getAPI_Bme280(String subtype, String params); void* getAPI_Bmp280(String subtype, String params); void* getAPI_Dht1122(String subtype, String params); @@ -12,17 +19,26 @@ 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_Mhz19(String subtype, String params); void* getAPI_Sds011(String subtype, String params); void* getAPI_Sht20(String subtype, String params); +void* getAPI_Sonar(String subtype, String params); void* getAPI_Lcd2004(String subtype, String params); void* getAPI(String subtype, String params) { void* tmpAPI; +if ((tmpAPI = getAPI_IarduinoRTC(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_SysExt(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_ButtonIn(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Telegram(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_Timer(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Ads1115(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Aht20(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_AnalogAdc(subtype, params)) != nullptr) return tmpAPI; 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; @@ -30,7 +46,9 @@ 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_Mhz19(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Sds011(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Sht20(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_Sonar(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI;return nullptr; } \ No newline at end of file