From 1fe07bf3652c67c2266b2d70c4562c1b94244f02 Mon Sep 17 00:00:00 2001 From: John Lagonikas <39417467+zeleps@users.noreply.github.com> Date: Wed, 5 Jan 2022 13:57:32 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20M80,=201s=20delay=20(#2345?= =?UTF-8?q?5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/power.cpp | 1 + Marlin/src/gcode/control/M80_M81.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index 480cb91a91..0e4d5452e4 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -153,6 +153,7 @@ void Power::power_off() { } 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_TIMER, power_off_time && PENDING(millis(), power_off_time))) return; power_off(); diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index dc9b09c4e1..cbb3c85f40 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -84,14 +84,19 @@ void GcodeSuite::M81() { 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')) { - delayed_power_off = true; - powerManager.setPowerOffTimer(SEC_TO_MS(parser.value_ushort())); + 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 @@ -104,8 +109,6 @@ void GcodeSuite::M81() { if (delayed_power_off) return; - safe_delay(1000); // Wait 1 second before switching off - #if HAS_SUICIDE suicide(); #elif ENABLED(PSU_CONTROL)