From bbf5b486c3be8b4de9ec4d6a294f7a3ea529ba1b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 17 Jun 2016 18:27:14 -0700 Subject: [PATCH] Add an SD Card stop function, use in ultralcd --- Marlin/cardreader.cpp | 7 +++++++ Marlin/cardreader.h | 1 + Marlin/ultralcd.cpp | 11 +++++------ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index 2fead53823..3910bee4ee 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -282,6 +282,13 @@ void CardReader::pauseSDPrint() { if (sdprinting) sdprinting = false; } +void CardReader::stopSDPrint() { + if (sdprinting) { + sdprinting = false; + file.close(); + } +} + void CardReader::openLogFile(char* name) { logging = true; openFile(name, false); diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h index a18b718b56..78280fc8d1 100644 --- a/Marlin/cardreader.h +++ b/Marlin/cardreader.h @@ -48,6 +48,7 @@ public: void openAndPrintFile(const char *name); void startFileprint(); void pauseSDPrint(); + void stopSDPrint(); void getStatus(); void printingHasFinished(); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 5372626849..6f5990acad 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -496,17 +496,16 @@ static void lcd_status_screen() { } static void lcd_sdcard_stop() { - stepper.quick_stop(); - #if DISABLED(DELTA) && DISABLED(SCARA) - set_current_position_from_planner(); - #endif // !DELTA && !SCARA + card.stopSDPrint(); clear_command_queue(); - card.sdprinting = false; - card.closefile(); + stepper.quick_stop(); print_job_timer.stop(); thermalManager.autotempShutdown(); cancel_heatup = true; lcd_setstatus(MSG_PRINT_ABORTED, true); + #if DISABLED(DELTA) && DISABLED(SCARA) + set_current_position_from_planner(); + #endif // !DELTA && !SCARA } #endif //SDSUPPORT