🎨 Small tweak, ms => now

This commit is contained in:
Scott Lahteine 2021-06-26 14:28:50 -05:00
parent 003ce25acf
commit ec518e6e7b

View File

@ -105,12 +105,12 @@ bool Power::is_power_needed() {
void Power::check() {
static millis_t nextPowerCheck = 0;
millis_t ms = millis();
if (ELAPSED(ms, nextPowerCheck)) {
nextPowerCheck = ms + 2500UL;
millis_t now = millis();
if (ELAPSED(now, nextPowerCheck)) {
nextPowerCheck = now + 2500UL;
if (is_power_needed())
power_on();
else if (!lastPowerOn || (POWER_TIMEOUT > 0 && ELAPSED(ms, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT))))
else if (!lastPowerOn || (POWER_TIMEOUT > 0 && ELAPSED(now, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT))))
power_off();
}
}