1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-29 23:07:42 +00:00

🧑‍💻 Quieter AUTO_REPORT_SD_STATUS option (#27391)

This commit is contained in:
Scott Lahteine 2024-09-03 01:08:49 -05:00 committed by GitHub
parent 8c15a093fd
commit 56e2b60e6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 4 deletions

View File

@ -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

View File

@ -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);

View File

@ -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 @@ public:
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 @@ public:
//
// 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<AutoReportSD> auto_reporter;
#endif