|
@@ -50,6 +50,9 @@ Power powerManager;
|
50
|
50
|
millis_t Power::lastPowerOn;
|
51
|
51
|
|
52
|
52
|
bool Power::is_power_needed() {
|
|
53
|
+
|
|
54
|
+ if (printJobOngoing() || printingIsPaused()) return true;
|
|
55
|
+
|
53
|
56
|
#if ENABLED(AUTO_POWER_FANS)
|
54
|
57
|
FANS_LOOP(i) if (thermalManager.fan_speed[i]) return true;
|
55
|
58
|
#endif
|
|
@@ -110,9 +113,17 @@ bool Power::is_power_needed() {
|
110
|
113
|
#define POWER_TIMEOUT 0
|
111
|
114
|
#endif
|
112
|
115
|
|
113
|
|
-void Power::check() {
|
|
116
|
+void Power::check(const bool pause) {
|
|
117
|
+ static bool _pause = false;
|
114
|
118
|
static millis_t nextPowerCheck = 0;
|
115
|
|
- millis_t now = millis();
|
|
119
|
+ const millis_t now = millis();
|
|
120
|
+ #if POWER_TIMEOUT > 0
|
|
121
|
+ if (pause != _pause) {
|
|
122
|
+ lastPowerOn = now + !now;
|
|
123
|
+ _pause = pause;
|
|
124
|
+ }
|
|
125
|
+ if (pause) return;
|
|
126
|
+ #endif
|
116
|
127
|
if (ELAPSED(now, nextPowerCheck)) {
|
117
|
128
|
nextPowerCheck = now + 2500UL;
|
118
|
129
|
if (is_power_needed())
|
|
@@ -123,7 +134,8 @@ void Power::check() {
|
123
|
134
|
}
|
124
|
135
|
|
125
|
136
|
void Power::power_on() {
|
126
|
|
- lastPowerOn = millis();
|
|
137
|
+ const millis_t now = millis();
|
|
138
|
+ lastPowerOn = now + !now;
|
127
|
139
|
if (!powersupply_on) {
|
128
|
140
|
PSU_PIN_ON();
|
129
|
141
|
safe_delay(PSU_POWERUP_DELAY);
|
|
@@ -152,6 +164,7 @@ void Power::power_off() {
|
152
|
164
|
void Power::power_off_soon() {
|
153
|
165
|
#if POWER_OFF_DELAY
|
154
|
166
|
lastPowerOn = millis() - SEC_TO_MS(POWER_TIMEOUT) + SEC_TO_MS(POWER_OFF_DELAY);
|
|
167
|
+ //if (!lastPowerOn) ++lastPowerOn;
|
155
|
168
|
#else
|
156
|
169
|
power_off();
|
157
|
170
|
#endif
|