diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index ede62ba89be2f..4a58253660e2b 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -99,6 +99,10 @@ bool Power::is_power_needed() { return false; } +#ifndef POWER_TIMEOUT + #define POWER_TIMEOUT 0 +#endif + void Power::check() { static millis_t nextPowerCheck = 0; millis_t ms = millis(); @@ -108,10 +112,8 @@ void Power::check() { power_on(); else if (!lastPowerOn) power_off(); - #ifdef POWER_TIMEOUT - else if (ELAPSED(ms, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT))) - power_off(); - #endif + else if (POWER_TIMEOUT > 0 && ELAPSED(ms, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT))) + power_off(); } } @@ -139,11 +141,7 @@ void Power::power_off() { void Power::power_off_soon() { #if POWER_OFF_DELAY - #ifdef POWER_TIMEOUT - lastPowerOn = millis() - SEC_TO_MS(POWER_TIMEOUT) + SEC_TO_MS(POWER_OFF_DELAY); - #else - lastPowerOn = millis() + SEC_TO_MS(POWER_OFF_DELAY); - #endif + lastPowerOn = millis() - SEC_TO_MS(POWER_TIMEOUT) + SEC_TO_MS(POWER_OFF_DELAY); #else power_off(); #endif