Nespoustime expired() pro propasnute casy, ale presto udrzujeme presnost (snad).
This commit is contained in:
parent
a4b1c9b242
commit
d02bd77806
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user