Abort print on media removal (#20200)
This commit is contained in:
parent
11f08804d1
commit
1040f14da4
|
@ -454,8 +454,17 @@ void CardReader::manage_media() {
|
||||||
DEBUG_ECHOLNPGM("SD: No UI Detected.");
|
DEBUG_ECHOLNPGM("SD: No UI Detected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "Release" the media by clearing the 'mounted' flag.
|
||||||
|
* Used by M22, "Release Media", manage_media.
|
||||||
|
*/
|
||||||
void CardReader::release() {
|
void CardReader::release() {
|
||||||
endFilePrint();
|
// Card removed while printing? Abort!
|
||||||
|
if (IS_SD_PRINTING())
|
||||||
|
card.flag.abort_sd_printing = true;
|
||||||
|
else
|
||||||
|
endFilePrint();
|
||||||
|
|
||||||
flag.mounted = false;
|
flag.mounted = false;
|
||||||
flag.workDirIsRoot = true;
|
flag.workDirIsRoot = true;
|
||||||
#if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES)
|
#if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES)
|
||||||
|
@ -463,6 +472,10 @@ void CardReader::release() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a G-code file and set Marlin to start processing it.
|
||||||
|
* Enqueues M23 and M24 commands to initiate a media print.
|
||||||
|
*/
|
||||||
void CardReader::openAndPrintFile(const char *name) {
|
void CardReader::openAndPrintFile(const char *name) {
|
||||||
char cmd[4 + strlen(name) + 1]; // Room for "M23 ", filename, and null
|
char cmd[4 + strlen(name) + 1]; // Room for "M23 ", filename, and null
|
||||||
extern const char M23_STR[];
|
extern const char M23_STR[];
|
||||||
|
@ -472,6 +485,12 @@ void CardReader::openAndPrintFile(const char *name) {
|
||||||
queue.enqueue_now_P(M24_STR);
|
queue.enqueue_now_P(M24_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start or resume a media print by setting the sdprinting flag.
|
||||||
|
* The file browser pre-sort is also purged to free up memory,
|
||||||
|
* since you cannot browse files during active printing.
|
||||||
|
* Used by M24 and anywhere Start / Resume applies.
|
||||||
|
*/
|
||||||
void CardReader::startFileprint() {
|
void CardReader::startFileprint() {
|
||||||
if (isMounted()) {
|
if (isMounted()) {
|
||||||
flag.sdprinting = true;
|
flag.sdprinting = true;
|
||||||
|
@ -479,6 +498,9 @@ void CardReader::startFileprint() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Run tasks upon finishing or aborting a file print.
|
||||||
|
//
|
||||||
void CardReader::endFilePrint(TERN_(SD_RESORT, const bool re_sort/*=false*/)) {
|
void CardReader::endFilePrint(TERN_(SD_RESORT, const bool re_sort/*=false*/)) {
|
||||||
TERN_(ADVANCED_PAUSE_FEATURE, did_pause_print = 0);
|
TERN_(ADVANCED_PAUSE_FEATURE, did_pause_print = 0);
|
||||||
TERN_(DWIN_CREALITY_LCD, HMI_flag.print_finish = flag.sdprinting);
|
TERN_(DWIN_CREALITY_LCD, HMI_flag.print_finish = flag.sdprinting);
|
||||||
|
|
Loading…
Reference in a new issue