Выделяем виртуальную кнопку в отдельный модуль

This commit is contained in:
2022-08-12 01:08:24 +03:00
parent ca3cc0e840
commit e1341a532f
6 changed files with 95 additions and 43 deletions

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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": []
}
}

View File

@@ -1,18 +1,7 @@
{
"menuSection": "Виртуальные элементы",
"configItem": [{
"name": "Кнопка",
"type": "Reading",
"subtype": "Variable",
"id": "vbtn",
"widget": "",
"page": "",
"descr": "",
"int": "0",
"val": "0"
},
"configItem": [
{
"name": "Окно ввода цифры",
"type": "Reading",