Fix auto#.g file handling, add NO_SD_AUTOSTART (#20071)

This commit is contained in:
Scott Lahteine
2020-12-07 05:53:15 -06:00
parent 1932e70e72
commit 37dd0fd2d6
9 changed files with 78 additions and 56 deletions

View File

@ -27,6 +27,10 @@
#include "../gcode.h"
#include "../../module/printcounter.h"
#if DISABLED(NO_SD_AUTOSTART)
#include "../../sd/cardreader.h"
#endif
#ifdef SD_FINISHED_RELEASECOMMAND
#include "../queue.h"
#endif
@ -60,6 +64,11 @@
* M1001: Execute actions for SD print completion
*/
void GcodeSuite::M1001() {
// If there's another auto#.g file to run...
if (TERN(NO_SD_AUTOSTART, false, card.autofile_check())) return;
// Purge the recovery file...
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
// Report total print time
const bool long_print = print_job_timer.duration() > 60;
@ -71,9 +80,6 @@ void GcodeSuite::M1001() {
// Set the progress bar "done" state
TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress_done());
// Purge the recovery file
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
// Announce SD file completion
{
PORT_REDIRECT(SERIAL_BOTH);
@ -93,7 +99,7 @@ void GcodeSuite::M1001() {
// Inject SD_FINISHED_RELEASECOMMAND, if any
#ifdef SD_FINISHED_RELEASECOMMAND
queue.inject_P(PSTR(SD_FINISHED_RELEASECOMMAND));
gcode.process_subcommands_now_P(PSTR(SD_FINISHED_RELEASECOMMAND));
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished());