diff --git a/Marlin/src/inc/Conditionals-4-adv.h b/Marlin/src/inc/Conditionals-4-adv.h index 31c430a30d4fd..1401dab570314 100644 --- a/Marlin/src/inc/Conditionals-4-adv.h +++ b/Marlin/src/inc/Conditionals-4-adv.h @@ -1465,3 +1465,13 @@ #if !HAS_ROTATIONAL_AXES #undef MANUAL_MOVE_DISTANCE_DEG #endif + +// Only report "Not SD printing" when the state changes +// To get legacy behavior define AUTO_REPORT_SD_STATUS 2 +#ifdef AUTO_REPORT_SD_STATUS + #if ENABLED(AUTO_REPORT_SD_STATUS) // Not blank, 1, or true + #define QUIETER_AUTO_REPORT_SD_STATUS + #endif + #undef AUTO_REPORT_SD_STATUS + #define AUTO_REPORT_SD_STATUS +#endif diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 286cbfe88b2e2..56daa369fca67 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -22,6 +22,10 @@ #include "../inc/MarlinConfig.h" +/** + * cardreader.cpp - SD card / USB flash drive file handling interface + */ + #if HAS_MEDIA //#define DEBUG_CARDREADER @@ -827,8 +831,17 @@ void CardReader::removeFile(const char * const name) { #endif } -void CardReader::report_status() { - if (isPrinting() || isPaused()) { +void CardReader::report_status(TERN_(QUIETER_AUTO_REPORT_SD_STATUS, const bool isauto/*=false*/)) { + const bool has_job = isStillPrinting() || isPaused(); + + #if ENABLED(QUIETER_AUTO_REPORT_SD_STATUS) + static uint32_t old_sdpos = 0; + if (!has_job) old_sdpos = 0; + if (isauto && sdpos == old_sdpos) return; + if (has_job) old_sdpos = sdpos; + #endif + + if (has_job) { SERIAL_ECHOPGM(STR_SD_PRINTING_BYTE, sdpos); SERIAL_CHAR('/'); SERIAL_ECHOLN(filesize); diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 86fb6edef67c5..1d2ba3ae6f1a0 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -21,6 +21,10 @@ */ #pragma once +/** + * cardreader.h - SD card / USB flash drive file handling interface + */ + #include "../inc/MarlinConfig.h" #if HAS_MEDIA @@ -162,7 +166,7 @@ class CardReader { static void selectFileByName(const char * const match); // (working directory only) // Print job - static void report_status(); + static void report_status(TERN_(QUIETER_AUTO_REPORT_SD_STATUS, const bool isauto=false)); static void getAbsFilenameInCWD(char *dst); static void printSelectedFilename(); static void openAndPrintFile(const char *name); // (working directory or full path) @@ -249,7 +253,7 @@ class CardReader { // // SD Auto Reporting // - struct AutoReportSD { static void report() { report_status(); } }; + struct AutoReportSD { static void report() { report_status(TERN_(QUIETER_AUTO_REPORT_SD_STATUS, true)); } }; static AutoReporter auto_reporter; #endif