Skip to content

Commit

Permalink
adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed May 2, 2021
1 parent 1022f36 commit 65e12e7
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Marlin/src/feature/power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 65e12e7

Please sign in to comment.