diff --git a/data_svelte/items.json b/data_svelte/items.json index c6e8cb70..54939b56 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -22,19 +22,7 @@ "num": 1 }, { - "name": "2. Кнопка", - "type": "Reading", - "subtype": "Variable", - "id": "vbtn", - "widget": "", - "page": "", - "descr": "", - "int": "0", - "val": "0", - "num": 2 - }, - { - "name": "3. Окно ввода цифры", + "name": "2. Окно ввода цифры", "type": "Reading", "subtype": "Variable", "id": "dedit", @@ -43,10 +31,10 @@ "descr": "", "int": "0", "val": "0", - "num": 3 + "num": 2 }, { - "name": "4. Окно ввода времени", + "name": "3. Окно ввода времени", "type": "Reading", "subtype": "Variable", "id": "tedit", @@ -55,10 +43,10 @@ "descr": "", "int": "0", "val": "0", - "num": 4 + "num": 3 }, { - "name": "5. Переменная", + "name": "4. Переменная", "type": "Reading", "subtype": "Variable", "id": "var", @@ -67,6 +55,18 @@ "descr": "", "int": "0", "val": "0", + "num": 4 + }, + { + "name": "5. Кнопка", + "type": "Reading", + "subtype": "VButton", + "id": "vbtn", + "widget": "button", + "page": "Кнопки", + "descr": "", + "int": "0", + "val": "0", "num": 5 }, { diff --git a/platformio.ini b/platformio.ini index 65a2ce53..e4a9c4b1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -68,6 +68,7 @@ lib_deps = build_src_filter = + + + + + + + @@ -93,9 +94,6 @@ build_src_filter = [env:esp32_4mb_fromitems] lib_deps = - marcoschwartz/LiquidCrystal_I2C@^1.1.4 - https://github.com/RoboticsBrno/ServoESP32 - dfrobot/DFRobotDFPlayerMini @ ^1.0.5 Adafruit AHTX0 adafruit/Adafruit BME280 Library adafruit/Adafruit BMP280 Library @@ -107,16 +105,14 @@ lib_deps = rc-switch @ ^2.6.4 robtillaart/SHT2x@^0.1.1 WEMOS SHT3x@1.0.0 + https://github.com/RoboticsBrno/ServoESP32 adafruit/Adafruit MCP23017 Arduino Library@^2.0.2 adafruit/Adafruit BusIO @ ^1.13.0 + dfrobot/DFRobotDFPlayerMini @ ^1.0.5 + marcoschwartz/LiquidCrystal_I2C@^1.1.4 build_src_filter = - + - + - + - + - + - + - + + + + + + + + @@ -130,8 +126,13 @@ build_src_filter = + + + - + - + - + - + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/API.cpp b/src/modules/API.cpp index 5edd6349..db2bda52 100644 --- a/src/modules/API.cpp +++ b/src/modules/API.cpp @@ -2,6 +2,7 @@ void* getAPI_Timer(String subtype, String params); void* getAPI_Variable(String subtype, String params); +void* getAPI_VButton(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); @@ -29,6 +30,7 @@ void* getAPI(String subtype, String params) { void* tmpAPI; if ((tmpAPI = getAPI_Timer(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_VButton(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; diff --git a/src/modules/virtual/VButton/VButton.cpp b/src/modules/virtual/VButton/VButton.cpp new file mode 100644 index 00000000..6bfcb5ea --- /dev/null +++ b/src/modules/virtual/VButton/VButton.cpp @@ -0,0 +1,23 @@ +#include "Global.h" +#include "classes/IoTItem.h" + + +class VButton : public IoTItem { + public: + VButton(String parameters): IoTItem(parameters) { } + + void setValue(IoTValue Value) { + value = Value; + regEvent((String)(int)value.valD, ""); + } + + void doByInterval() { } +}; + +void* getAPI_VButton(String subtype, String param) { + if (subtype == F("VButton")) { + return new VButton(param); + } else { + return nullptr; + } +} diff --git a/src/modules/virtual/VButton/modinfo.json b/src/modules/virtual/VButton/modinfo.json new file mode 100644 index 00000000..f33072dc --- /dev/null +++ b/src/modules/virtual/VButton/modinfo.json @@ -0,0 +1,37 @@ +{ + "menuSection": "Виртуальные элементы", + + "configItem": [{ + "name": "Кнопка", + "type": "Reading", + "subtype": "VButton", + "id": "vbtn", + "widget": "button", + "page": "Кнопки", + "descr": "Кнопка1", + + "int": "0", + "val": "0" + }], + + "about": { + "authorName": "Ilya Belyakov", + "authorContact": "https://t.me/Biveraxe", + "authorGit": "https://github.com/biveraxe", + "specialThanks": "", + "moduleName": "VButton", + "moduleVersion": "1.0", + "moduleDesc": "Специальный системный модуль для добавления виртуальной кнопки.", + "propInfo": { + "int": "Не используется", + "val": "Значение при старте" + } + }, + + "defActive": true, + + "devices": { + "esp32_4mb": [], + "esp8266_4mb": [] + } +} \ No newline at end of file diff --git a/src/modules/virtual/Variable/modinfo.json b/src/modules/virtual/Variable/modinfo.json index 8f5182b5..2cdd34f9 100644 --- a/src/modules/virtual/Variable/modinfo.json +++ b/src/modules/virtual/Variable/modinfo.json @@ -1,18 +1,7 @@ { "menuSection": "Виртуальные элементы", - "configItem": [{ - "name": "Кнопка", - "type": "Reading", - "subtype": "Variable", - "id": "vbtn", - "widget": "", - "page": "", - "descr": "", - - "int": "0", - "val": "0" - }, + "configItem": [ { "name": "Окно ввода цифры", "type": "Reading",