🚸 Retain power during Pause (#22227)

This commit is contained in:
Cytown 2021-06-30 01:58:11 +08:00 committed by Scott Lahteine
parent 0a655c84bf
commit 61c48b8513
5 changed files with 28 additions and 8 deletions

View file

@ -617,7 +617,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down
TERN_(AUTO_POWER_CONTROL, powerManager.check());
TERN_(AUTO_POWER_CONTROL, powerManager.check(!ui.on_status_screen() || printJobOngoing() || printingIsPaused()));
TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.check());

View file

@ -91,7 +91,11 @@ extern bool wait_for_heatup;
#define PSU_OFF_SOON() powerManager.power_off_soon()
#else
#define PSU_ON() PSU_PIN_ON()
#if ENABLED(PS_OFF_SOUND)
#define PSU_OFF() do{ BUZZ(1000, 659); PSU_PIN_OFF(); }while(0)
#else
#define PSU_OFF() PSU_PIN_OFF()
#endif
#define PSU_OFF_SOON PSU_OFF
#endif
#endif

View file

@ -50,6 +50,9 @@ Power powerManager;
millis_t Power::lastPowerOn;
bool Power::is_power_needed() {
if (printJobOngoing() || printingIsPaused()) return true;
#if ENABLED(AUTO_POWER_FANS)
FANS_LOOP(i) if (thermalManager.fan_speed[i]) return true;
#endif
@ -110,9 +113,17 @@ bool Power::is_power_needed() {
#define POWER_TIMEOUT 0
#endif
void Power::check() {
void Power::check(const bool pause) {
static bool _pause = false;
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)) {
nextPowerCheck = now + 2500UL;
if (is_power_needed())
@ -123,7 +134,8 @@ void Power::check() {
}
void Power::power_on() {
lastPowerOn = millis();
const millis_t now = millis();
lastPowerOn = now + !now;
if (!powersupply_on) {
PSU_PIN_ON();
safe_delay(PSU_POWERUP_DELAY);
@ -152,6 +164,7 @@ void Power::power_off() {
void Power::power_off_soon() {
#if POWER_OFF_DELAY
lastPowerOn = millis() - SEC_TO_MS(POWER_TIMEOUT) + SEC_TO_MS(POWER_OFF_DELAY);
//if (!lastPowerOn) ++lastPowerOn;
#else
power_off();
#endif

View file

@ -29,7 +29,7 @@
class Power {
public:
static void check();
static void check(const bool pause);
static void power_on();
static void power_off();
static void power_off_soon();

View file

@ -529,10 +529,13 @@ public:
static void draw_select_screen_prompt(PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);
#elif HAS_WIRED_LCD
#else
static constexpr bool on_status_screen() { return true; }
#if HAS_WIRED_LCD
FORCE_INLINE static void run_current_screen() { status_screen(); }
#endif
#endif