Update xdrv_29_deepsleep.ino

This commit is contained in:
stefanbode 2022-05-04 19:07:22 +02:00 committed by GitHub
parent cdce233f43
commit c022e35388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -112,10 +112,10 @@ void DeepSleepPrepare(void)
// if more then 10% timeslip = 0 == non valid wakeup; maybe manual
timeslip = (timeslip < -(int32_t)Settings->deepsleep) ? 0 : (timeslip > (int32_t)Settings->deepsleep) ? 0 : 1;
if (timeslip) {
RtcSettings.deepsleep_slip = (Settings->deepsleep + RtcSettings.nextwakeup - LocalTime()) * RtcSettings.deepsleep_slip / tmax((Settings->deepsleep - (millis() / 1000)),5);
RtcSettings.nextwakeup += Settings->deepsleep;
RtcSettings.deepsleep_slip = (RtcSettings.nextwakeup - LocalTime()) * RtcSettings.deepsleep_slip / tmax((Settings->deepsleep - (millis() / 1000)),5);
// Avoid crazy numbers. Again maximum 10% deviation.
RtcSettings.deepsleep_slip = tmin(tmax(RtcSettings.deepsleep_slip, 9000), 11000);
RtcSettings.nextwakeup += Settings->deepsleep;
}
// It may happen that wakeup in just <5 seconds in future