소스 검색

Abort print on media removal (#20200)

Victor Oliveira 4 년 전
부모
커밋
08c5557026
No account linked to committer's email address
1개의 변경된 파일23개의 추가작업 그리고 1개의 파일을 삭제
  1. 23
    1
      Marlin/src/sd/cardreader.cpp

+ 23
- 1
Marlin/src/sd/cardreader.cpp 파일 보기

@@ -454,8 +454,17 @@ void CardReader::manage_media() {
454 454
     DEBUG_ECHOLNPGM("SD: No UI Detected.");
455 455
 }
456 456
 
457
+/**
458
+ * "Release" the media by clearing the 'mounted' flag.
459
+ * Used by M22, "Release Media", manage_media.
460
+ */
457 461
 void CardReader::release() {
458
-  endFilePrint();
462
+  // Card removed while printing? Abort!
463
+  if (IS_SD_PRINTING())
464
+    card.flag.abort_sd_printing = true;
465
+  else
466
+    endFilePrint();
467
+
459 468
   flag.mounted = false;
460 469
   flag.workDirIsRoot = true;
461 470
   #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES)
@@ -463,6 +472,10 @@ void CardReader::release() {
463 472
   #endif
464 473
 }
465 474
 
475
+/**
476
+ * Open a G-code file and set Marlin to start processing it.
477
+ * Enqueues M23 and M24 commands to initiate a media print.
478
+ */
466 479
 void CardReader::openAndPrintFile(const char *name) {
467 480
   char cmd[4 + strlen(name) + 1]; // Room for "M23 ", filename, and null
468 481
   extern const char M23_STR[];
@@ -472,6 +485,12 @@ void CardReader::openAndPrintFile(const char *name) {
472 485
   queue.enqueue_now_P(M24_STR);
473 486
 }
474 487
 
488
+/**
489
+ * Start or resume a media print by setting the sdprinting flag.
490
+ * The file browser pre-sort is also purged to free up memory,
491
+ * since you cannot browse files during active printing.
492
+ * Used by M24 and anywhere Start / Resume applies.
493
+ */
475 494
 void CardReader::startFileprint() {
476 495
   if (isMounted()) {
477 496
     flag.sdprinting = true;
@@ -479,6 +498,9 @@ void CardReader::startFileprint() {
479 498
   }
480 499
 }
481 500
 
501
+//
502
+// Run tasks upon finishing or aborting a file print.
503
+//
482 504
 void CardReader::endFilePrint(TERN_(SD_RESORT, const bool re_sort/*=false*/)) {
483 505
   TERN_(ADVANCED_PAUSE_FEATURE, did_pause_print = 0);
484 506
   TERN_(DWIN_CREALITY_LCD, HMI_flag.print_finish = flag.sdprinting);

Loading…
취소
저장