Skip to content

Commit

Permalink
Merge branch 'bugfix-2.1.x' into pr/27399
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 3, 2024
2 parents 1380ae0 + 2e8a7cc commit 5f3aac2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
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

0 comments on commit 5f3aac2

Please sign in to comment.