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
   }
153
   }
154
 
154
 
155
   void Power::checkAutoPowerOff() {
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
     if (TERN0(POWER_OFF_WAIT_FOR_COOLDOWN, power_off_on_cooldown && is_cooling_needed())) return;
157
     if (TERN0(POWER_OFF_WAIT_FOR_COOLDOWN, power_off_on_cooldown && is_cooling_needed())) return;
157
     if (TERN0(POWER_OFF_TIMER, power_off_time && PENDING(millis(), power_off_time))) return;
158
     if (TERN0(POWER_OFF_TIMER, power_off_time && PENDING(millis(), power_off_time))) return;
158
     power_off();
159
     power_off();

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

84
     ZERO(thermalManager.saved_fan_speed);
84
     ZERO(thermalManager.saved_fan_speed);
85
   #endif
85
   #endif
86
 
86
 
87
+  safe_delay(1000); // Wait 1 second before switching off
88
+
87
   LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF ".");
89
   LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF ".");
88
 
90
 
89
   bool delayed_power_off = false;
91
   bool delayed_power_off = false;
90
 
92
 
91
   #if ENABLED(POWER_OFF_TIMER)
93
   #if ENABLED(POWER_OFF_TIMER)
92
     if (parser.seenval('D')) {
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
   #endif
101
   #endif
97
 
102
 
104
 
109
 
105
   if (delayed_power_off) return;
110
   if (delayed_power_off) return;
106
 
111
 
107
-  safe_delay(1000); // Wait 1 second before switching off
108
-
109
   #if HAS_SUICIDE
112
   #if HAS_SUICIDE
110
     suicide();
113
     suicide();
111
   #elif ENABLED(PSU_CONTROL)
114
   #elif ENABLED(PSU_CONTROL)

Loading…
Cancel
Save