mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 14:42:18 +03:00
pulse() в ButtonOut, +прочие корректировки
This commit is contained in:
@@ -7,9 +7,7 @@
|
||||
|
||||
IoTItem::IoTItem(const String& parameters) {
|
||||
jsonRead(parameters, F("int"), _interval, false);
|
||||
if (_interval == 0) enableDoByInt = false; // выключаем использование периодического выполнения в модуле
|
||||
if (_interval > 0) _interval = _interval * 1000; // если int положителен, то считаем, что получены секунды
|
||||
if (_interval < 0) _interval = _interval * -1; // если int отрицательный, то миллисекунды
|
||||
setInterval(_interval);
|
||||
jsonRead(parameters, F("subtype"), _subtype, false);
|
||||
jsonRead(parameters, F("id"), _id);
|
||||
if (!jsonRead(parameters, F("multiply"), _multiply, false)) _multiply = 1;
|
||||
@@ -38,12 +36,16 @@ IoTItem::IoTItem(const String& parameters) {
|
||||
setValue(valAsStr, false);
|
||||
}
|
||||
|
||||
void IoTItem::suspendNextDoByInt(unsigned long _delay) { // 0 - force
|
||||
nextMillis = millis() + _delay;
|
||||
}
|
||||
|
||||
void IoTItem::loop() {
|
||||
if (enableDoByInt) {
|
||||
currentMillis = millis();
|
||||
difference = currentMillis - prevMillis;
|
||||
if (difference >= _interval) {
|
||||
prevMillis = millis();
|
||||
unsigned long currentMillis = millis(); // _interval должен быть < 2147483647 мс (24 суток)
|
||||
if (nextMillis - currentMillis > 2147483647UL /*ULONG_MAX/2*/ ) {
|
||||
nextMillis = currentMillis + _interval;
|
||||
// SerialPrint(F("i"), _id, "this->doByInterval");
|
||||
this->doByInterval();
|
||||
}
|
||||
}
|
||||
@@ -201,7 +203,13 @@ bool IoTItem::isStrInID(const String& str) {
|
||||
}
|
||||
|
||||
void IoTItem::setInterval(long interval) {
|
||||
_interval = interval;
|
||||
if (interval == 0) enableDoByInt = false; // выключаем использование периодического выполнения в модуле
|
||||
else {
|
||||
enableDoByInt = true;
|
||||
if (interval > 0) _interval = interval * 1000; // если int положителен, то считаем, что получены секунды
|
||||
else if (interval < 0) _interval = interval * -1; // если int отрицательный, то миллисекунды
|
||||
}
|
||||
// SerialPrint(F("i"), F("IoTItem"), "setInterval: " + _interval.toString);
|
||||
}
|
||||
|
||||
IoTGpio* IoTItem::getGpioDriver() {
|
||||
|
||||
Reference in New Issue
Block a user