Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧑‍💻 Quieter AUTO_REPORT_SD_STATUS option #27391

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Marlin/src/inc/Conditionals-4-adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 15 additions & 2 deletions Marlin/src/sd/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

#include "../inc/MarlinConfig.h"

/**
* cardreader.cpp - SD card / USB flash drive file handling interface
*/

#if HAS_MEDIA

//#define DEBUG_CARDREADER
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions Marlin/src/sd/cardreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
*/
#pragma once

/**
* cardreader.h - SD card / USB flash drive file handling interface
*/

#include "../inc/MarlinConfig.h"

#if HAS_MEDIA
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<AutoReportSD> auto_reporter;
#endif

Expand Down
Loading