|
@ -46,6 +46,9 @@ Power powerManager; |
|
|
millis_t Power::lastPowerOn; |
|
|
millis_t Power::lastPowerOn; |
|
|
|
|
|
|
|
|
bool Power::is_power_needed() { |
|
|
bool Power::is_power_needed() { |
|
|
|
|
|
|
|
|
|
|
|
if (printJobOngoing() || printingIsPaused()) return true; |
|
|
|
|
|
|
|
|
#if ENABLED(AUTO_POWER_FANS) |
|
|
#if ENABLED(AUTO_POWER_FANS) |
|
|
FANS_LOOP(i) if (thermalManager.fan_speed[i]) return true; |
|
|
FANS_LOOP(i) if (thermalManager.fan_speed[i]) return true; |
|
|
#endif |
|
|
#endif |
|
@ -106,9 +109,17 @@ bool Power::is_power_needed() { |
|
|
#define POWER_TIMEOUT 0 |
|
|
#define POWER_TIMEOUT 0 |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
void Power::check() { |
|
|
void Power::check(const bool pause) { |
|
|
|
|
|
static bool _pause = false; |
|
|
static millis_t nextPowerCheck = 0; |
|
|
static millis_t nextPowerCheck = 0; |
|
|
millis_t now = millis(); |
|
|
const millis_t now = millis(); |
|
|
|
|
|
#if POWER_TIMEOUT > 0 |
|
|
|
|
|
if (pause != _pause) { |
|
|
|
|
|
lastPowerOn = now + !now; |
|
|
|
|
|
_pause = pause; |
|
|
|
|
|
} |
|
|
|
|
|
if (pause) return; |
|
|
|
|
|
#endif |
|
|
if (ELAPSED(now, nextPowerCheck)) { |
|
|
if (ELAPSED(now, nextPowerCheck)) { |
|
|
nextPowerCheck = now + 2500UL; |
|
|
nextPowerCheck = now + 2500UL; |
|
|
if (is_power_needed()) |
|
|
if (is_power_needed()) |
|
@ -119,7 +130,8 @@ void Power::check() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Power::power_on() { |
|
|
void Power::power_on() { |
|
|
lastPowerOn = millis(); |
|
|
const millis_t now = millis(); |
|
|
|
|
|
lastPowerOn = now + !now; |
|
|
if (!powersupply_on) { |
|
|
if (!powersupply_on) { |
|
|
PSU_PIN_ON(); |
|
|
PSU_PIN_ON(); |
|
|
safe_delay(PSU_POWERUP_DELAY); |
|
|
safe_delay(PSU_POWERUP_DELAY); |
|
@ -143,6 +155,7 @@ void Power::power_off() { |
|
|
void Power::power_off_soon() { |
|
|
void Power::power_off_soon() { |
|
|
#if POWER_OFF_DELAY |
|
|
#if POWER_OFF_DELAY |
|
|
lastPowerOn = millis() - SEC_TO_MS(POWER_TIMEOUT) + SEC_TO_MS(POWER_OFF_DELAY); |
|
|
lastPowerOn = millis() - SEC_TO_MS(POWER_TIMEOUT) + SEC_TO_MS(POWER_OFF_DELAY); |
|
|
|
|
|
//if (!lastPowerOn) ++lastPowerOn;
|
|
|
#else |
|
|
#else |
|
|
power_off(); |
|
|
power_off(); |
|
|
#endif |
|
|
#endif |
|
|