M81 D / S - Power-off Delay (#23396, #23455)

This commit is contained in:
John Lagonikas
2022-01-03 18:11:39 +02:00
committed by Scott Lahteine
parent b6c37960e8
commit 2690bb1bc2
9 changed files with 134 additions and 42 deletions

View File

@ -79,20 +79,39 @@ void GcodeSuite::M81() {
print_job_timer.stop();
#if HAS_FAN
#if ENABLED(PROBING_FANS_OFF)
thermalManager.fans_paused = false;
ZERO(thermalManager.saved_fan_speed);
#endif
#if BOTH(HAS_FAN, PROBING_FANS_OFF)
thermalManager.fans_paused = false;
ZERO(thermalManager.saved_fan_speed);
#endif
safe_delay(1000); // Wait 1 second before switching off
LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF ".");
bool delayed_power_off = false;
#if ENABLED(POWER_OFF_TIMER)
if (parser.seenval('D')) {
uint16_t delay = parser.value_ushort();
if (delay > 1) { // skip already observed 1s delay
delayed_power_off = true;
powerManager.setPowerOffTimer(SEC_TO_MS(delay - 1));
}
}
#endif
#if ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN)
if (parser.boolval('S')) {
delayed_power_off = true;
powerManager.setPowerOffOnCooldown(true);
}
#endif
if (delayed_power_off) return;
#if HAS_SUICIDE
suicide();
#elif ENABLED(PSU_CONTROL)
powerManager.power_off_soon();
#endif
LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF ".");
}