Browse Source

🩹 Fix M80, 1s delay (#23455)

John Lagonikas 3 years ago
parent
commit
1fe07bf365
No account linked to committer's email address
2 changed files with 8 additions and 4 deletions
  1. 1
    0
      Marlin/src/feature/power.cpp
  2. 7
    4
      Marlin/src/gcode/control/M80_M81.cpp

+ 1
- 0
Marlin/src/feature/power.cpp View File

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

+ 7
- 4
Marlin/src/gcode/control/M80_M81.cpp View File

@@ -84,14 +84,19 @@ void GcodeSuite::M81() {
84 84
     ZERO(thermalManager.saved_fan_speed);
85 85
   #endif
86 86
 
87
+  safe_delay(1000); // Wait 1 second before switching off
88
+
87 89
   LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF ".");
88 90
 
89 91
   bool delayed_power_off = false;
90 92
 
91 93
   #if ENABLED(POWER_OFF_TIMER)
92 94
     if (parser.seenval('D')) {
93
-      delayed_power_off = true;
94
-      powerManager.setPowerOffTimer(SEC_TO_MS(parser.value_ushort()));
95
+      uint16_t delay = parser.value_ushort();
96
+      if (delay > 1) { // skip already observed 1s delay
97
+        delayed_power_off = true;
98
+        powerManager.setPowerOffTimer(SEC_TO_MS(delay - 1));
99
+      }
95 100
     }
96 101
   #endif
97 102
 
@@ -104,8 +109,6 @@ void GcodeSuite::M81() {
104 109
 
105 110
   if (delayed_power_off) return;
106 111
 
107
-  safe_delay(1000); // Wait 1 second before switching off
108
-
109 112
   #if HAS_SUICIDE
110 113
     suicide();
111 114
   #elif ENABLED(PSU_CONTROL)

Loading…
Cancel
Save