Новый модуль Math для хранения математических функция для сценариев

This commit is contained in:
2023-10-24 21:24:33 +07:00
parent 4474d98d59
commit d1c6e0e04f
6 changed files with 96 additions and 3 deletions

View File

@@ -144,6 +144,10 @@
"path": "src/modules/virtual/LogingDaily", "path": "src/modules/virtual/LogingDaily",
"active": true "active": true
}, },
{
"path": "src/modules/virtual/Math",
"active": false
},
{ {
"path": "src/modules/virtual/owmWeather", "path": "src/modules/virtual/owmWeather",
"active": true "active": true

View File

@@ -22,6 +22,10 @@
"path": "src/modules/virtual/LogingDaily", "path": "src/modules/virtual/LogingDaily",
"active": true "active": true
}, },
{
"path": "src/modules/virtual/Math",
"active": false
},
{ {
"path": "src/modules/virtual/owmWeather", "path": "src/modules/virtual/owmWeather",
"active": true "active": true

View File

@@ -723,10 +723,11 @@
"widget": "rangeServo", "widget": "rangeServo",
"page": "servo", "page": "servo",
"descr": "угол", "descr": "угол",
"int": 1,
"pin": 12, "pin": 12,
"apin": -1, "minPulseWidth": 544,
"amap": "0, 4096, 0, 180", "maxPulseWidth": 2400,
"neutralPulseWidth": 1500,
"trackingID": "",
"num": 47 "num": 47
}, },
{ {

View File

@@ -144,6 +144,10 @@
"path": "src/modules/virtual/LogingDaily", "path": "src/modules/virtual/LogingDaily",
"active": true "active": true
}, },
{
"path": "src/modules/virtual/Math",
"active": false
},
{ {
"path": "src/modules/virtual/owmWeather", "path": "src/modules/virtual/owmWeather",
"active": true "active": true

View File

@@ -0,0 +1,25 @@
#include "Global.h"
#include "classes/IoTItem.h"
class IoTMath : public IoTItem {
private:
public:
IoTMath(String parameters) : IoTItem(parameters) {}
IoTValue execute(String command, std::vector<IoTValue> &param) {
if(command == "map" & param.size() == 5) {
IoTValue valTmp;
valTmp.isDecimal = true;
valTmp.valD = map(param[0].valD, param[1].valD, param[2].valD, param[3].valD, param[4].valD);
return valTmp;
}
return {};
}
};
void *getAPI_IoTMath(String subtype, String param) {
if (subtype == F("IoTMath")) {
return new IoTMath(param);
}
return nullptr;
}

View File

@@ -0,0 +1,55 @@
{
"menuSection": "virtual_elments",
"configItem": [
{
"global": 0,
"name": "Math library",
"type": "Reading",
"subtype": "IoTMath",
"id": "math",
"widget": "anydataValue",
"page": "Математика",
"descr": ""
}
],
"about": {
"authorName": "Berenbaum Maxim",
"authorContact": "https://t.me/Bermax_sys",
"authorGit": "https://github.com/xpohuk8",
"exampleURL": "https://iotmanager.org/wiki",
"specialThanks": "Ilya Belyakov",
"moduleName": "IoTMath",
"moduleVersion": "1.0",
"usedRam": {
"esp32_4mb": 15,
"esp8266_4mb": 15
},
"title": "Модуль Math",
"moduleDesc": "Модуль для расчета значений с использованием математических функций. Подходит для коррекции показаний датчиков.",
"propInfo": {
},
"funcInfo": [
{
"name": "map",
"descr": "Аналог функции map",
"params": [
"Значение1", "Значение2", "Значение3", "Значение4"
]
}
]
},
"defActive": false,
"usedLibs": {
"esp32_4mb": [],
"esp32_4mb3f": [],
"esp32cam_4mb": [],
"esp32s2_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],
"esp8266_1mb_ota": [],
"esp8285_1mb": [],
"esp8285_1mb_ota": [],
"esp8266_2mb": [],
"esp8266_2mb_ota": []
}
}