Skip to content

Commit

Permalink
Allow disable of POWER_TIMEOUT (MarlinFirmware#21771)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
2 people authored and lkrammes committed May 2, 2021
1 parent 10d5fad commit f28ffd3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Marlin/src/feature/power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,18 @@ 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();
if (ELAPSED(ms, nextPowerCheck)) {
nextPowerCheck = ms + 2500UL;
if (is_power_needed())
power_on();
else if (!lastPowerOn || ELAPSED(ms, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT)))
else if (!lastPowerOn || (POWER_TIMEOUT > 0 && ELAPSED(ms, lastPowerOn + SEC_TO_MS(POWER_TIMEOUT))))
power_off();
}
}
Expand Down

0 comments on commit f28ffd3

Please sign in to comment.