1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-25 04:48:31 +00:00

🩹 Fix M80, 1s delay (#23455)

This commit is contained in:
John Lagonikas 2022-01-05 13:57:32 +02:00 committed by GitHub
parent c55b66bece
commit 1fe07bf365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -153,6 +153,7 @@ void Power::power_off() {
} }
void Power::checkAutoPowerOff() { void Power::checkAutoPowerOff() {
if (TERN1(POWER_OFF_TIMER, !power_off_time) && TERN1(POWER_OFF_WAIT_FOR_COOLDOWN, !power_off_on_cooldown)) return;
if (TERN0(POWER_OFF_WAIT_FOR_COOLDOWN, power_off_on_cooldown && is_cooling_needed())) return; if (TERN0(POWER_OFF_WAIT_FOR_COOLDOWN, power_off_on_cooldown && is_cooling_needed())) return;
if (TERN0(POWER_OFF_TIMER, power_off_time && PENDING(millis(), power_off_time))) return; if (TERN0(POWER_OFF_TIMER, power_off_time && PENDING(millis(), power_off_time))) return;
power_off(); power_off();

View File

@ -84,14 +84,19 @@ void GcodeSuite::M81() {
ZERO(thermalManager.saved_fan_speed); ZERO(thermalManager.saved_fan_speed);
#endif #endif
safe_delay(1000); // Wait 1 second before switching off
LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF "."); LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF ".");
bool delayed_power_off = false; bool delayed_power_off = false;
#if ENABLED(POWER_OFF_TIMER) #if ENABLED(POWER_OFF_TIMER)
if (parser.seenval('D')) { if (parser.seenval('D')) {
delayed_power_off = true; uint16_t delay = parser.value_ushort();
powerManager.setPowerOffTimer(SEC_TO_MS(parser.value_ushort())); if (delay > 1) { // skip already observed 1s delay
delayed_power_off = true;
powerManager.setPowerOffTimer(SEC_TO_MS(delay - 1));
}
} }
#endif #endif
@ -104,8 +109,6 @@ void GcodeSuite::M81() {
if (delayed_power_off) return; if (delayed_power_off) return;
safe_delay(1000); // Wait 1 second before switching off
#if HAS_SUICIDE #if HAS_SUICIDE
suicide(); suicide();
#elif ENABLED(PSU_CONTROL) #elif ENABLED(PSU_CONTROL)