Procházet zdrojové kódy

Add M524 to abort SD printing (#12155)

TheSFReader před 6 roky
rodič
revize
1fb9b299d4

+ 3
- 6
Marlin/src/Marlin.cpp Zobrazit soubor

@@ -972,11 +972,8 @@ void loop() {
972 972
 
973 973
     #if ENABLED(SDSUPPORT)
974 974
       card.checkautostart();
975
-    #endif
976
-
977
-    #if ENABLED(SDSUPPORT) && (ENABLED(ULTIPANEL) || ENABLED(EXTENSIBLE_UI))
978
-      if (abort_sd_printing) {
979
-        abort_sd_printing = false;
975
+    
976
+      if (card.abort_sd_printing) {
980 977
         card.stopSDPrint(
981 978
           #if SD_RESORT
982 979
             true
@@ -992,7 +989,7 @@ void loop() {
992 989
           card.removeJobRecoveryFile();
993 990
         #endif
994 991
       }
995
-    #endif // SDSUPPORT && (ENABLED(ULTIPANEL) || ENABLED(EXTENSIBLE_UI))
992
+    #endif // SDSUPPORT
996 993
 
997 994
     if (commands_in_queue < BUFSIZE) get_available_commands();
998 995
     advance_command_queue();

+ 4
- 0
Marlin/src/gcode/gcode.cpp Zobrazit soubor

@@ -584,6 +584,10 @@ void GcodeSuite::process_parsed_command(
584 584
         case 504: M504(); break;                                  // M504: Validate EEPROM contents
585 585
       #endif
586 586
 
587
+      #if ENABLED(SDSUPPORT)
588
+        case 524: M524(); break;                                   // M524: Abort the current SD print job
589
+      #endif
590
+      
587 591
       #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
588 592
         case 540: M540(); break;                                  // M540: Set abort on endstop hit for SD printing
589 593
       #endif

+ 5
- 0
Marlin/src/gcode/gcode.h Zobrazit soubor

@@ -202,6 +202,7 @@
202 202
  * M501 - Restore parameters from EEPROM. (Requires EEPROM_SETTINGS)
203 203
  * M502 - Revert to the default "factory settings". ** Does not write them to EEPROM! **
204 204
  * M503 - Print the current settings (in memory): "M503 S<verbose>". S0 specifies compact output.
205
+ * M524 - Abort the current SD print job (started with M24)
205 206
  * M540 - Enable/disable SD card abort on endstop hit: "M540 S<state>". (Requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
206 207
  * M600 - Pause for filament change: "M600 X<pos> Y<pos> Z<raise> E<first_retract> L<later_retract>". (Requires ADVANCED_PAUSE_FEATURE)
207 208
  * M603 - Configure filament change: "M603 T<tool> U<unload_length> L<load_length>". (Requires ADVANCED_PAUSE_FEATURE)
@@ -719,6 +720,10 @@ private:
719 720
     static void M504();
720 721
   #endif
721 722
 
723
+  #if ENABLED(SDSUPPORT)
724
+    static void M524();
725
+  #endif
726
+    
722 727
   #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
723 728
     static void M540();
724 729
   #endif

Marlin/src/gcode/sdcard/M20-M30_M32-M34_M928.cpp → Marlin/src/gcode/sdcard/M20-M30_M32-M34_M524_M928.cpp Zobrazit soubor

@@ -245,6 +245,13 @@ void GcodeSuite::M32() {
245 245
 #endif // SDCARD_SORT_ALPHA && SDSORT_GCODE
246 246
 
247 247
 /**
248
+ * M524: Abort the current SD print job (started with M24)
249
+ */
250
+void GcodeSuite::M524() {
251
+  if (IS_SD_PRINTING()) card.abort_sd_printing = true;
252
+}
253
+
254
+/**
248 255
  * M928: Start SD Write
249 256
  */
250 257
 void GcodeSuite::M928() {

+ 1
- 5
Marlin/src/lcd/extensible_ui/ui_api.cpp Zobrazit soubor

@@ -37,10 +37,6 @@
37 37
 #if ENABLED(SDSUPPORT)
38 38
   #include "../../sd/cardreader.h"
39 39
   #include "../../feature/emergency_parser.h"
40
-
41
-  bool abort_sd_printing; // =false
42
-#else
43
-  constexpr bool abort_sd_printing = false;
44 40
 #endif
45 41
 
46 42
 #if ENABLED(PRINTCOUNTER)
@@ -476,7 +472,7 @@ namespace UI {
476 472
   void stopPrint() {
477 473
     #if ENABLED(SDSUPPORT)
478 474
       wait_for_heatup = wait_for_user = false;
479
-      abort_sd_printing = true;
475
+      card.abort_sd_printing = true;
480 476
       UI::onStatusChanged(PSTR(MSG_PRINT_ABORTED));
481 477
     #endif
482 478
   }

+ 1
- 3
Marlin/src/lcd/ultralcd.cpp Zobrazit soubor

@@ -895,11 +895,9 @@ void lcd_quick_feedback(const bool clear_buttons) {
895 895
       lcd_reset_status();
896 896
     }
897 897
 
898
-    bool abort_sd_printing; // =false
899
-
900 898
     void lcd_sdcard_stop() {
901 899
       wait_for_heatup = wait_for_user = false;
902
-      abort_sd_printing = true;
900
+      card.abort_sd_printing = true;
903 901
       lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
904 902
       lcd_return_to_status();
905 903
     }

+ 0
- 5
Marlin/src/lcd/ultralcd.h Zobrazit soubor

@@ -288,10 +288,5 @@
288 288
   void lcd_reselect_last_file();
289 289
 #endif
290 290
 
291
-#if (ENABLED(EXTENSIBLE_UI) || ENABLED(ULTIPANEL)) && ENABLED(SDSUPPORT)
292
-  extern bool abort_sd_printing;
293
-#else
294
-  constexpr bool abort_sd_printing = false;
295
-#endif
296 291
 
297 292
 #endif // ULTRALCD_H

+ 1
- 1
Marlin/src/sd/cardreader.cpp Zobrazit soubor

@@ -351,7 +351,7 @@ void CardReader::stopSDPrint(
351 351
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
352 352
     did_pause_print = 0;
353 353
   #endif
354
-  sdprinting = false;
354
+  sdprinting = abort_sd_printing = false;
355 355
   if (isFileOpen()) file.close();
356 356
   #if SD_RESORT
357 357
     if (re_sort) presort();

+ 1
- 1
Marlin/src/sd/cardreader.h Zobrazit soubor

@@ -149,7 +149,7 @@ public:
149 149
   FORCE_INLINE char* longest_filename() { return longFilename[0] ? longFilename : filename; }
150 150
 
151 151
 public:
152
-  bool saving, logging, sdprinting, cardOK, filenameIsDir;
152
+  bool saving, logging, sdprinting, cardOK, filenameIsDir, abort_sd_printing;
153 153
   char filename[FILENAME_LENGTH], longFilename[LONG_FILENAME_LENGTH];
154 154
   int8_t autostart_index;
155 155
 private:

Loading…
Zrušit
Uložit