Добавляем насроку для таймера для включения режима сохранения значения счетчика

This commit is contained in:
2022-03-27 10:47:21 +03:00
parent fe7b1f6a39
commit 0451aca0d5
2 changed files with 5 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ class Timer : public IoTItem {
bool _unfin = false;
bool _ticker = false;
bool _repeat = false;
bool _needSave = false;
public:
Timer(String parameters): IoTItem(parameters) {
@@ -19,12 +20,13 @@ class Timer : public IoTItem {
jsonRead(parameters, "repeat", _repeat);
if (_repeat) _repeat = valDtmp; // если в параметрах просят повторить, то запоминаем настроечное значение отчета
_unfin = !value.valD;
jsonRead(parameters, "needSave", _needSave); // нужно сохранять счетчик в постоянную память
}
void doByInterval() {
if (!_unfin && value.valD) {
value.valD--;
needSave = true;
if (_needSave) needSave = true;
if (value.valD == 0) {
regEvent(value.valD, "Time's up");
if (_repeat) value.valD = _repeat;

View File

@@ -12,6 +12,7 @@
"int": 1,
"countDown": 15,
"ticker": 0,
"repeat": 0
"repeat": 0,
"needSave": 0
}
]