mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 14:42:18 +03:00
@@ -43,13 +43,16 @@ public:
|
||||
#if defined ESP8266
|
||||
if (!http.begin(_host, 80, _url))
|
||||
{
|
||||
#elif defined ESP32
|
||||
if (!http.begin(String("http://") + _host + _url))
|
||||
{
|
||||
#endif
|
||||
// Serial.println("connection failed");
|
||||
SerialPrint("I", F("NextionUpdate"), "connection failed ");
|
||||
}
|
||||
#elif defined ESP32
|
||||
if (!http.begin(String("http://") + _host + _url))
|
||||
{
|
||||
// Serial.println("connection failed");
|
||||
SerialPrint("I", F("NextionUpdate"), "connection failed ");
|
||||
}
|
||||
#endif
|
||||
|
||||
SerialPrint("I", F("NextionUpdate"), "Requesting file: " + (String)_url);
|
||||
int code = http.GET();
|
||||
|
||||
174
src/modules/display/Oled128/Oled128.cpp
Normal file
174
src/modules/display/Oled128/Oled128.cpp
Normal file
@@ -0,0 +1,174 @@
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
|
||||
#include <GyverOLED.h>
|
||||
|
||||
GyverOLED<SSD1306_128x64, OLED_BUFFER> oled;
|
||||
|
||||
// GyverOLED<SSD1306_128x32, OLED_BUFFER> oled;
|
||||
// GyverOLED<SSD1306_128x32, OLED_NO_BUFFER> oled;
|
||||
// GyverOLED<SSD1306_128x64, OLED_NO_BUFFER> oled;
|
||||
// GyverOLED<SSD1306_128x64, OLED_BUFFER, OLED_SPI, 8, 7, 6> oled;
|
||||
// GyverOLED<SSH1106_128x64> oled;
|
||||
|
||||
class Oled128 : public IoTItem {
|
||||
private:
|
||||
unsigned int _x;
|
||||
unsigned int _y;
|
||||
|
||||
unsigned int _k;
|
||||
|
||||
int _shrift;
|
||||
|
||||
String _id2show;
|
||||
String _descr;
|
||||
String _descr1;
|
||||
|
||||
int _prevStrSize;
|
||||
|
||||
bool _isShow = true; // экран показывает
|
||||
|
||||
public:
|
||||
Oled128(String parameters) : IoTItem(parameters) {
|
||||
String addr, size, xy, k;
|
||||
_prevStrSize = 0;
|
||||
|
||||
jsonRead(parameters, "addr", addr);
|
||||
if (addr == "") {
|
||||
// scanI2C();
|
||||
return;
|
||||
}
|
||||
|
||||
jsonRead(parameters, "coord", xy);
|
||||
_x = selectFromMarkerToMarker(xy, ",", 0).toInt();
|
||||
_y = selectFromMarkerToMarker(xy, ",", 1).toInt();
|
||||
|
||||
jsonRead(parameters, "descr", _descr);
|
||||
jsonRead(parameters, "id2show", _id2show);
|
||||
jsonRead(parameters, "descr1", _descr1);
|
||||
// jsonRead(parameters, "scale", _k);
|
||||
jsonRead(parameters, "shrift", _shrift);
|
||||
|
||||
// Wire.begin(2,0); // Инициализация шины I2C для модуля E01
|
||||
|
||||
oled.init(); // инициализация экрана
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
printBlankStr(_prevStrSize);
|
||||
|
||||
String tmpStr = "";
|
||||
|
||||
// if (_descr != "none") tmpStr = _descr + " " + getItemValue(_id2show);
|
||||
if (_descr != "none")
|
||||
tmpStr = _descr + " " + getItemValue(_id2show) + " " + _descr1;
|
||||
else
|
||||
tmpStr = getItemValue(_id2show);
|
||||
|
||||
// oled.setScale(2);
|
||||
|
||||
oled.setScale(_shrift);
|
||||
|
||||
oled.setCursorXY(_x, _y);
|
||||
|
||||
oled.print(tmpStr);
|
||||
|
||||
oled.update();
|
||||
|
||||
_prevStrSize = tmpStr.length();
|
||||
}
|
||||
|
||||
IoTValue execute(String command, std::vector<IoTValue> ¶m) { // будет возможным использовать, когда сценарии запустятся
|
||||
|
||||
if (command == "scroll") {
|
||||
String tmpStr = "";
|
||||
oled.clear();
|
||||
uint32_t tmr = millis();
|
||||
oled.autoPrintln(false);
|
||||
int val = 128;
|
||||
for (;;) {
|
||||
// oled.clear(); // ЗАКОММЕНТИРУЙ, ЕСЛИ ВКЛЮЧЕН БУФЕР
|
||||
// oled.setScale(2);
|
||||
|
||||
oled.setScale(_shrift);
|
||||
|
||||
oled.setCursor(val, _y);
|
||||
|
||||
oled.print(tmpStr);
|
||||
oled.update();
|
||||
val--;
|
||||
if (millis() - tmr > 5000)
|
||||
; // return;
|
||||
|
||||
_isShow = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if (command == "stopscroll") {
|
||||
_isShow = true;
|
||||
// display->backlight();
|
||||
// else if (command == "noDisplay") {
|
||||
// display->noDisplay();
|
||||
// _isShow = false;
|
||||
} else if (command == "display") {
|
||||
// display.display();
|
||||
_isShow = true;
|
||||
} else if (command == "toggle") {
|
||||
if (_isShow) {
|
||||
// display->noDisplay();
|
||||
_isShow = false;
|
||||
} else {
|
||||
// display.display();
|
||||
_isShow = true;
|
||||
}
|
||||
} else if (command == "x") {
|
||||
if (param.size()) {
|
||||
_x = param[0].valD;
|
||||
}
|
||||
} else if (command == "y") {
|
||||
if (param.size()) {
|
||||
_y = param[0].valD;
|
||||
}
|
||||
} else if (command == "descr") {
|
||||
if (param.size()) {
|
||||
_descr = param[0].valS;
|
||||
}
|
||||
} else if (command == "descr1") {
|
||||
if (param.size()) {
|
||||
_descr1 = param[0].valS;
|
||||
}
|
||||
} else if (command == "id2show") {
|
||||
if (param.size()) {
|
||||
_id2show = param[0].valS;
|
||||
}
|
||||
}
|
||||
|
||||
doByInterval();
|
||||
return {};
|
||||
}
|
||||
|
||||
// печать пустой строки нужной длинны для затирания предыдущего значения на экране
|
||||
void printBlankStr(int strSize) {
|
||||
String tmpStr = "";
|
||||
for (int i = 0; i < strSize; i++) tmpStr += " ";
|
||||
|
||||
// oled.setScale(2);
|
||||
|
||||
oled.setScale(_shrift);
|
||||
|
||||
oled.setCursorXY(_x, _y);
|
||||
|
||||
oled.print(tmpStr);
|
||||
}
|
||||
|
||||
~Oled128(){};
|
||||
};
|
||||
|
||||
void *getAPI_Oled128(String subtype, String param) {
|
||||
if (subtype == F("Oled128")) {
|
||||
return new Oled128(param);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
86
src/modules/display/Oled128/modinfo.json
Normal file
86
src/modules/display/Oled128/modinfo.json
Normal file
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"menuSection": "screens",
|
||||
"configItem": [
|
||||
{
|
||||
"name": "OLED экран 128*64",
|
||||
"type": "Reading",
|
||||
"subtype": "Oled128",
|
||||
"id": "oled",
|
||||
"widget": "",
|
||||
"page": "",
|
||||
"descr": "T",
|
||||
"descr1": "C",
|
||||
"int": 1,
|
||||
"addr": "0x3C",
|
||||
"coord": "0,10",
|
||||
"id2show": "id датчика",
|
||||
"shrift": "2"
|
||||
}
|
||||
],
|
||||
"about": {
|
||||
"authorName": "Serghei Crasnicov",
|
||||
"authorContact": "https://t.me/Serghei63",
|
||||
"authorGit": "https://github.com/Serghei63",
|
||||
"specialThanks": "Ilya Belyakov @Biveraxe",
|
||||
"moduleName": "Oled128",
|
||||
"moduleVersion": "1.0",
|
||||
"moduleDesc": "Позволяет выводить на матричные Oled экраны по указанным позициям значения других элементов конфигурации.",
|
||||
"usedRam": 15,
|
||||
"propInfo": {
|
||||
"int": "Период времени в секундах обновления информации на экране по конкретному элементу.",
|
||||
"addr": "Адрес устройства на шине, обычно 0x3c.",
|
||||
"coord": "Координата позиции для вывода данных элемента конфигурации.",
|
||||
"id2show": "id элемента конфигурации.",
|
||||
"shrift": "Шрифт текста от 1 до 4 "
|
||||
},
|
||||
"funcInfo": [
|
||||
{
|
||||
"name": "x",
|
||||
"descr": "Устанавливает первую координату",
|
||||
"params": [
|
||||
"Номер строки первого символа"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "y",
|
||||
"descr": "Устанавливает вторую координату",
|
||||
"params": [
|
||||
"Номер столбца первого символа"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "descr",
|
||||
"descr": "Задает приставку слева от значения, если none значит пусто",
|
||||
"params": [
|
||||
"Строка"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "descr1",
|
||||
"descr": "Задает приставку справа от значения. Если descr none , то не выводится",
|
||||
"params": [
|
||||
"Строка"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "id2show",
|
||||
"descr": "Задает ИД элемента, значение которого хотим отображать на экране",
|
||||
"params": [
|
||||
"Имя элемента конфигурации"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"defActive": false,
|
||||
"usedLibs": {
|
||||
"esp32_4mb": [
|
||||
"gyverlibs/GyverOLED @ 1.4"
|
||||
],
|
||||
"esp32_16mb": [
|
||||
"gyverlibs/GyverOLED @ 1.4"
|
||||
],
|
||||
"esp8266_4mb": [
|
||||
"gyverlibs/GyverOLED @ 1.4"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -3,24 +3,28 @@
|
||||
|
||||
extern IoTGpio IoTgpio;
|
||||
|
||||
|
||||
class ButtonOut : public IoTItem {
|
||||
private:
|
||||
int _pin, _inv;
|
||||
int _pin;
|
||||
bool _inv;
|
||||
|
||||
public:
|
||||
ButtonOut(String parameters): IoTItem(parameters) {
|
||||
jsonRead(parameters, "pin", _pin);
|
||||
jsonRead(parameters, "inv", _inv);
|
||||
_round = 0;
|
||||
|
||||
IoTgpio.pinMode(_pin, OUTPUT);
|
||||
IoTgpio.digitalWrite(_pin, _inv?!value.valD:value.valD);
|
||||
enableDoByInt = false;
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
//value.valD = IoTgpio.analogRead(_pin);
|
||||
|
||||
int val = _inv?1:0;
|
||||
IoTgpio.digitalWrite(_pin, val);
|
||||
// SerialPrint("I", "ButtonOut","single pulse end");
|
||||
value.valD = 0;
|
||||
regEvent(0, "ButtonOut");
|
||||
enableDoByInt = false;
|
||||
//regEvent(value.valD, "ButtonOut"); //обязательный вызов хотяб один
|
||||
}
|
||||
|
||||
@@ -30,24 +34,40 @@ class ButtonOut : public IoTItem {
|
||||
// param - вектор ("массив") значений параметров переданных вместе с командой: ID.Команда("пар1", 22, 33) -> param[0].ValS = "пар1", param[1].ValD = 22
|
||||
|
||||
if (command == "change") {
|
||||
value.valD = 1 - IoTgpio.digitalRead(_pin);
|
||||
IoTgpio.digitalWrite(_pin, value.valD);
|
||||
value.valD = 1 - (int)value.valD;
|
||||
IoTgpio.digitalWrite(_pin, _inv?!value.valD:value.valD);
|
||||
regEvent(value.valD, "ButtonOut");
|
||||
}
|
||||
|
||||
else if (command == "pulse") {
|
||||
if (param[0].isDecimal && (param[0].valD != 0)) {
|
||||
value.valD = !_inv?1:0;
|
||||
enableDoByInt = true;
|
||||
// SerialPrint("I", "ButtonOut","single pulse start");
|
||||
regEvent((String)(int)!_inv?1:0, "ButtonOut");
|
||||
suspendNextDoByInt(param[0].valD);
|
||||
IoTgpio.digitalWrite(_pin, !_inv?1:0);
|
||||
}
|
||||
}
|
||||
return {}; // команда поддерживает возвращаемое значения. Т.е. по итогу выполнения команды или общения с внешней системой, можно вернуть значение в сценарий для дальнейшей обработки
|
||||
}
|
||||
|
||||
void setValue(const IoTValue& Value, bool genEvent = true) {
|
||||
value = Value;
|
||||
IoTgpio.digitalWrite(_pin, _inv?!value.valD:value.valD);
|
||||
if ((value.valD == !_inv?1:0) && (_interval != 0)) {
|
||||
value.valD = !_inv?1:0;
|
||||
enableDoByInt = true;
|
||||
// SerialPrint("I", "ButtonOut","single pulse start");
|
||||
suspendNextDoByInt(_interval);
|
||||
} else {
|
||||
enableDoByInt = false;
|
||||
}
|
||||
regEvent((String)(int)value.valD, "ButtonOut", false, genEvent);
|
||||
IoTgpio.digitalWrite(_pin, _inv?!value.valD:value.valD);
|
||||
}
|
||||
|
||||
String getValue() {
|
||||
return (String)(int)value.valD;
|
||||
}
|
||||
//=======================================================================================================
|
||||
|
||||
~ButtonOut() {};
|
||||
};
|
||||
|
||||
@@ -39,6 +39,11 @@
|
||||
"name": "change",
|
||||
"descr": "Инвертирует значение переключателя",
|
||||
"params": []
|
||||
},
|
||||
{
|
||||
"name": "pulse",
|
||||
"descr": "Генерирует одиночный импульс",
|
||||
"params": ["Длительность (ms)"]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -79,16 +79,7 @@ public:
|
||||
|
||||
case 1:
|
||||
// for doByIntervals
|
||||
if (enableDoByInt)
|
||||
{
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= _interval)
|
||||
{
|
||||
prevMillis = millis();
|
||||
this->doByInterval();
|
||||
}
|
||||
}
|
||||
IoTItem::loop();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
|
||||
void sendHttpPOST(String url, String msg)
|
||||
{
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
if (isNetworkActive())
|
||||
{
|
||||
|
||||
WiFiClient client;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"type": "Writing",
|
||||
"subtype": "IoTServo",
|
||||
"id": "servo",
|
||||
"widget": "range",
|
||||
"widget": "rangeServo",
|
||||
"page": "servo",
|
||||
"descr": "угол",
|
||||
"int": 1,
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
#include "Arduino.h"
|
||||
#include "MySensorsGate.h"
|
||||
|
||||
// временное решение
|
||||
unsigned long currentMillis;
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
|
||||
#ifdef MYSENSORS
|
||||
// callback библиотеки mysensors
|
||||
void receive(const MyMessage& message) {
|
||||
|
||||
@@ -13,7 +13,7 @@ class TelegramLT : public IoTItem {
|
||||
}
|
||||
|
||||
void sendTelegramMsg(bool often, String msg) {
|
||||
if (WiFi.status() == WL_CONNECTED && (often || !often && _prevMsg != msg)) {
|
||||
if (isNetworkActive() && (often || !often && _prevMsg != msg)) {
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
http.begin(client, "http://live-control.com/iotm/telegram.php");
|
||||
|
||||
@@ -246,6 +246,11 @@ protected:
|
||||
pv_last = pv;
|
||||
}
|
||||
|
||||
// временное решение
|
||||
unsigned long currentMillis;
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (enableDoByInt)
|
||||
|
||||
@@ -64,13 +64,7 @@ class AnalogAdc : public IoTItem {
|
||||
_avgSumm = _avgSumm + IoTgpio.analogRead(_pin);
|
||||
_avgCount++;
|
||||
}
|
||||
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= _interval) {
|
||||
prevMillis = millis();
|
||||
this->doByInterval();
|
||||
}
|
||||
IoTItem::loop();
|
||||
}
|
||||
|
||||
~AnalogAdc(){};
|
||||
|
||||
@@ -107,13 +107,7 @@ public:
|
||||
adc = IoTgpio.analogRead(_pin);
|
||||
|
||||
// Блок вызова doByInterval, так как если определили loop, то сам он не вызовится
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= _interval)
|
||||
{
|
||||
prevMillis = millis();
|
||||
this->doByInterval();
|
||||
}
|
||||
IoTItem::loop();
|
||||
}
|
||||
|
||||
~ExampleModule_A()
|
||||
|
||||
@@ -17,6 +17,7 @@ private:
|
||||
bool _isJson;
|
||||
bool _addPrefix;
|
||||
bool _debug;
|
||||
bool sendOk = false;
|
||||
|
||||
public:
|
||||
ExternalMQTT(String parameters) : IoTItem(parameters)
|
||||
@@ -26,10 +27,12 @@ public:
|
||||
jsonRead(parameters, F("red"), red);
|
||||
jsonRead(parameters, F("offline"), offline);
|
||||
_topic = jsonReadStr(parameters, "topic");
|
||||
_isJson = jsonReadBool(parameters, "isJson");
|
||||
_addPrefix = jsonReadBool(parameters, "addPrefix");
|
||||
_debug = jsonReadBool(parameters, "debug");
|
||||
jsonRead(parameters, "isJson", _isJson);
|
||||
jsonRead(parameters, "addPrefix", _addPrefix);
|
||||
jsonRead(parameters, "debug", _debug);
|
||||
dataFromNode = false;
|
||||
if (mqttIsConnect())
|
||||
sendOk = true;
|
||||
mqttSubscribeExternal(_topic, _addPrefix);
|
||||
}
|
||||
char *TimeToString(unsigned long t)
|
||||
@@ -58,6 +61,7 @@ public:
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isJson)
|
||||
{
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
@@ -106,6 +110,11 @@ public:
|
||||
{
|
||||
_minutesPassed++;
|
||||
setNewWidgetAttributes();
|
||||
if (mqttIsConnect() && !sendOk)
|
||||
{
|
||||
sendOk = true;
|
||||
mqttSubscribeExternal(_topic, _addPrefix);
|
||||
}
|
||||
}
|
||||
void onMqttWsAppConnectEvent()
|
||||
{
|
||||
|
||||
@@ -157,16 +157,17 @@ public:
|
||||
void loop()
|
||||
{
|
||||
ts_sds.update();
|
||||
if (enableDoByInt)
|
||||
{
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= _interval)
|
||||
{
|
||||
prevMillis = millis();
|
||||
this->doByInterval();
|
||||
}
|
||||
}
|
||||
IoTItem::loop();
|
||||
// if (enableDoByInt)
|
||||
// {
|
||||
// currentMillis = millis();
|
||||
// difference = currentMillis - prevMillis;
|
||||
// if (difference >= _interval)
|
||||
// {
|
||||
// prevMillis = millis();
|
||||
// this->doByInterval();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
//=======================================================================================================
|
||||
// doByInterval()
|
||||
|
||||
@@ -10,7 +10,7 @@ private:
|
||||
String scid = "";
|
||||
String shname = "";
|
||||
// bool init = false;
|
||||
int interval = 1;
|
||||
// int interval = 1;
|
||||
// long interval;
|
||||
String URL = ("http://iotmanager.org/projects/google.php?/macros/s/"); // F("https://script.google.com/macros/s/");
|
||||
String urlFinal;
|
||||
@@ -24,14 +24,17 @@ public:
|
||||
jsonRead(parameters, F("logid"), logid);
|
||||
jsonRead(parameters, F("scid"), scid);
|
||||
jsonRead(parameters, F("shname"), shname);
|
||||
jsonRead(parameters, F("int"), interval);
|
||||
interval = interval * 1000 * 60; // так как у нас в минутах
|
||||
// jsonRead(parameters, F("int"), interval);
|
||||
long interval;
|
||||
jsonRead(parameters, F("int"), interval); // в минутах
|
||||
setInterval(interval * 60);
|
||||
// interval = interval * 1000 * 60; // так как у нас в минутах
|
||||
urlFinal = URL + scid + F("/exec?") + F("sheet=") + shname;
|
||||
}
|
||||
|
||||
void doByInterval()
|
||||
{
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
if (isNetworkActive())
|
||||
{
|
||||
String value = getItemValue(logid);
|
||||
if (value != "")
|
||||
@@ -39,23 +42,23 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (enableDoByInt)
|
||||
{
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= interval)
|
||||
{
|
||||
prevMillis = millis();
|
||||
this->doByInterval();
|
||||
}
|
||||
}
|
||||
}
|
||||
// void loop()
|
||||
// {
|
||||
// if (enableDoByInt)
|
||||
// {
|
||||
// currentMillis = millis();
|
||||
// difference = currentMillis - prevMillis;
|
||||
// if (difference >= interval)
|
||||
// {
|
||||
// prevMillis = millis();
|
||||
// this->doByInterval();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
IoTValue execute(String command, std::vector<IoTValue> ¶m)
|
||||
{
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
if (isNetworkActive())
|
||||
{
|
||||
if (command == F("logGoogle"))
|
||||
{ // Логирование определенного элемента по его идентификатору в GoogleSheet
|
||||
|
||||
@@ -23,7 +23,7 @@ class Loging : public IoTItem {
|
||||
String prevDate = "";
|
||||
bool firstTimeInit = true;
|
||||
|
||||
long interval;
|
||||
// long interval;
|
||||
|
||||
public:
|
||||
Loging(String parameters) : IoTItem(parameters) {
|
||||
@@ -34,8 +34,9 @@ class Loging : public IoTItem {
|
||||
points = 300;
|
||||
SerialPrint("E", F("Loging"), "'" + id + "' user set more points than allowed, value reset to 300");
|
||||
}
|
||||
jsonRead(parameters, F("int"), interval);
|
||||
interval = interval * 1000 * 60; // приводим к милисекундам
|
||||
long interval;
|
||||
jsonRead(parameters, F("int"), interval); // в минутах
|
||||
setInterval(interval * 60);
|
||||
//jsonRead(parameters, F("keepdays"), keepdays, false);
|
||||
|
||||
// создадим экземпляр класса даты
|
||||
@@ -303,18 +304,18 @@ class Loging : public IoTItem {
|
||||
return "";
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (enableDoByInt) {
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= interval) {
|
||||
prevMillis = millis();
|
||||
if (interval != 0) {
|
||||
this->doByInterval();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// void loop() {
|
||||
// if (enableDoByInt) {
|
||||
// currentMillis = millis();
|
||||
// difference = currentMillis - prevMillis;
|
||||
// if (difference >= interval) {
|
||||
// prevMillis = millis();
|
||||
// if (interval != 0) {
|
||||
// this->doByInterval();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
void regEvent(const String &value, const String &consoleInfo, bool error = false, bool genEvent = true) {
|
||||
String userDate = getItemValue(id + "-date");
|
||||
|
||||
@@ -25,7 +25,7 @@ class LogingDaily : public IoTItem {
|
||||
String prevDate = "";
|
||||
bool firstTimeInit = true;
|
||||
|
||||
long interval;
|
||||
// long interval;
|
||||
|
||||
public:
|
||||
LogingDaily(String parameters) : IoTItem(parameters) {
|
||||
@@ -40,8 +40,9 @@ class LogingDaily : public IoTItem {
|
||||
points = 365;
|
||||
SerialPrint("E", F("LogingDaily"), "'" + id + "' user set more points than allowed, value reset to 365");
|
||||
}
|
||||
jsonRead(parameters, F("int"), interval);
|
||||
interval = interval * 1000 * 60; // приводим к милисекундам
|
||||
long interval;
|
||||
jsonRead(parameters, F("int"), interval); // в минутах
|
||||
setInterval(interval * 60);
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
@@ -225,16 +226,16 @@ class LogingDaily : public IoTItem {
|
||||
return "";
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (enableDoByInt) {
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= interval) {
|
||||
prevMillis = millis();
|
||||
this->doByInterval();
|
||||
}
|
||||
}
|
||||
}
|
||||
// void loop() {
|
||||
// if (enableDoByInt) {
|
||||
// currentMillis = millis();
|
||||
// difference = currentMillis - prevMillis;
|
||||
// if (difference >= interval) {
|
||||
// prevMillis = millis();
|
||||
// this->doByInterval();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// просто максимальное количество точек
|
||||
int calculateMaxCount() {
|
||||
|
||||
@@ -11,22 +11,23 @@ class Weather : public IoTItem
|
||||
private:
|
||||
String _location;
|
||||
String _param;
|
||||
long interval;
|
||||
// long interval;
|
||||
|
||||
public:
|
||||
Weather(String parameters) : IoTItem(parameters)
|
||||
{
|
||||
_location = jsonReadStr(parameters, "location");
|
||||
_param = jsonReadStr(parameters, "param");
|
||||
jsonRead(parameters, F("int"), interval);
|
||||
interval = interval * 1000 * 60 * 60; // интервал проверки погоды в часах
|
||||
long interval;
|
||||
jsonRead(parameters, F("int"), interval); // интервал проверки погоды в часах
|
||||
setInterval(interval * 60 * 60);
|
||||
}
|
||||
|
||||
void getWeather()
|
||||
{
|
||||
String ret;
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
if (isNetworkActive())
|
||||
{
|
||||
// char c;
|
||||
String payload;
|
||||
@@ -113,19 +114,21 @@ public:
|
||||
regEvent(value.valS, "Weather");
|
||||
}
|
||||
}
|
||||
void loop()
|
||||
{
|
||||
if (enableDoByInt)
|
||||
{
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= interval)
|
||||
{
|
||||
prevMillis = millis();
|
||||
this->doByInterval();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void loop()
|
||||
// {
|
||||
// if (enableDoByInt)
|
||||
// {
|
||||
// currentMillis = millis();
|
||||
// difference = currentMillis - prevMillis;
|
||||
// if (difference >= interval)
|
||||
// {
|
||||
// prevMillis = millis();
|
||||
// this->doByInterval();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
IoTValue execute(String command, std::vector<IoTValue> ¶m)
|
||||
{
|
||||
if (command == "get")
|
||||
|
||||
Reference in New Issue
Block a user