Merge pull request #17 from Mit4el/ver4dev

обновление с основы
This commit is contained in:
Mit4el
2023-10-03 22:56:25 +03:00
committed by GitHub
37 changed files with 747 additions and 813 deletions

View File

@@ -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(){};

View File

@@ -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()

View File

@@ -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()
{

View File

@@ -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()