From 30d0da469899a911e744095236eb1aff6ed0941b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 13 Aug 2023 17:37:05 +0000 Subject: [PATCH] Close SD file in print_stop instead of UnconditionalStop() Change in memory: Flash: -6 bytes SRAM: 0 bytes --- Firmware/Marlin_main.cpp | 6 ------ Firmware/ultralcd.cpp | 6 +++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index b9f6ea304..f7590f976 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9685,12 +9685,6 @@ void UnconditionalStop() cmdqueue_reset(); cmdqueue_serial_disabled = false; - // Reset the sd status - if (card.sdprinting) { - card.sdprinting = false; - card.closefile(); - } - st_reset_timer(); CRITICAL_SECTION_END; } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 9162a4cc4..85f76c6a7 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5646,7 +5646,11 @@ void print_stop(bool interactive) // called by the main loop one iteration later. UnconditionalStop(); - if (!card.sdprinting) { + if (card.sdprinting) { + // Reset the sd status + card.sdprinting = false; + card.closefile(); + } else { SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_CANCEL); // for Octoprint }