mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-28 15:12:19 +03:00
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user