Browse Source

Abort SD printing more safely (#10407)

Allow the current command to complete when aborting an SD print, otherwise some commands (G28, G29, etc.) will cause trouble.
Scott Lahteine 6 years ago
parent
commit
6c7a17dba6
No account linked to committer's email address
3 changed files with 29 additions and 13 deletions
  1. 20
    0
      Marlin/src/Marlin.cpp
  2. 3
    13
      Marlin/src/lcd/ultralcd.cpp
  3. 6
    0
      Marlin/src/lcd/ultralcd.h

+ 20
- 0
Marlin/src/Marlin.cpp View File

@@ -898,6 +898,26 @@ void loop() {
898 898
   #endif
899 899
 
900 900
   for (;;) {
901
+
902
+    #if ENABLED(SDSUPPORT) && ENABLED(ULTIPANEL)
903
+      if (abort_sd_printing) {
904
+        abort_sd_printing = false;
905
+        card.stopSDPrint(
906
+          #if SD_RESORT
907
+            true
908
+          #endif
909
+        );
910
+        clear_command_queue();
911
+        quickstop_stepper();
912
+        print_job_timer.stop();
913
+        thermalManager.disable_all_heaters();
914
+        #if FAN_COUNT > 0
915
+          for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
916
+        #endif
917
+        wait_for_heatup = false;
918
+      }
919
+    #endif // SDSUPPORT && ULTIPANEL
920
+
901 921
     if (commands_in_queue < BUFSIZE) get_available_commands();
902 922
     advance_command_queue();
903 923
     endstops.report_state();

+ 3
- 13
Marlin/src/lcd/ultralcd.cpp View File

@@ -836,20 +836,10 @@ void kill_screen(const char* lcd_msg) {
836 836
       lcd_reset_status();
837 837
     }
838 838
 
839
+    bool abort_sd_printing; // =false
840
+
839 841
     void lcd_sdcard_stop() {
840
-      card.stopSDPrint(
841
-        #if SD_RESORT
842
-          true
843
-        #endif
844
-      );
845
-      clear_command_queue();
846
-      quickstop_stepper();
847
-      print_job_timer.stop();
848
-      thermalManager.disable_all_heaters();
849
-      #if FAN_COUNT > 0
850
-        for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
851
-      #endif
852
-      wait_for_heatup = false;
842
+      abort_sd_printing = true;
853 843
       lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
854 844
       lcd_return_to_status();
855 845
     }

+ 6
- 0
Marlin/src/lcd/ultralcd.h View File

@@ -261,4 +261,10 @@ void lcd_reset_status();
261 261
   void lcd_reselect_last_file();
262 262
 #endif
263 263
 
264
+#if ENABLED(ULTIPANEL) && ENABLED(SDSUPPORT)
265
+  extern bool abort_sd_printing;
266
+#else
267
+  constexpr bool abort_sd_printing = false;
268
+#endif
269
+
264 270
 #endif // ULTRALCD_H

Loading…
Cancel
Save