Nespoustime expired() pro propasnute casy, ale presto udrzujeme presnost (snad).

This commit is contained in:
Pavel Brychta 2024-12-18 17:23:04 +01:00
parent a4b1c9b242
commit d02bd77806

View File

@ -26,9 +26,13 @@ bool Interval::expired()
} }
} else if (2 == _mode) { } else if (2 == _mode) {
// periodic mode // periodic mode
if ((millis() - _timefrom) >= _timeout) { const uint32_t now = millis();
const uint32_t diff = now - _timefrom;
if (diff >= _timeout) {
const uint32_t times = diff / _timeout;
_timefrom += _timeout * times; // more precise periodic timing
result = true; result = true;
_timefrom += _timeout; // more precise periodic timing
} }
} else { } else {
// compatibility mode // compatibility mode