From eb212ae073bc0fdcb5723a34b13cf9201ce537dc Mon Sep 17 00:00:00 2001
From: Scott Lahteine <github@thinkyhead.com>
Date: Wed, 7 Mar 2018 01:57:09 -0600
Subject: [PATCH] Add suspend_auto_report flag to suppress auto-report

---
 Marlin/src/Marlin.cpp              | 23 +++++++++++++++--------
 Marlin/src/Marlin.h                |  4 ++++
 Marlin/src/inc/Conditionals_post.h |  2 ++
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp
index 89a4d47b10..d1181551bd 100644
--- a/Marlin/src/Marlin.cpp
+++ b/Marlin/src/Marlin.cpp
@@ -187,6 +187,10 @@ volatile bool wait_for_heatup = true;
   volatile bool wait_for_user = false;
 #endif
 
+#if HAS_AUTO_REPORTING
+  bool suspend_auto_report; // = false
+#endif
+
 // Inactivity shutdown
 millis_t max_inactive_time = 0,
          stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL;
@@ -519,10 +523,6 @@ void idle(
     gcode.host_keepalive();
   #endif
 
-  #if ENABLED(AUTO_REPORT_TEMPERATURES) && HAS_TEMP_SENSOR
-    thermalManager.auto_report_temperatures();
-  #endif
-
   manage_inactivity(
     #if ENABLED(ADVANCED_PAUSE_FEATURE)
       no_stepper_sleep
@@ -547,13 +547,20 @@ void idle(
     }
   #endif
 
-  #if ENABLED(AUTO_REPORT_SD_STATUS)
-    card.auto_report_sd_status();
-  #endif
-
   #ifdef HAL_IDLETASK
     HAL_idletask();
   #endif
+
+  #if HAS_AUTO_REPORTING
+    if (!suspend_auto_report) {
+      #if ENABLED(AUTO_REPORT_TEMPERATURES)
+        thermalManager.auto_report_temperatures();
+      #endif
+      #if ENABLED(AUTO_REPORT_SD_STATUS)
+        card.auto_report_sd_status();
+      #endif
+    }
+  #endif
 }
 
 /**
diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h
index bf56c79d83..f5b14a97fe 100644
--- a/Marlin/src/Marlin.h
+++ b/Marlin/src/Marlin.h
@@ -188,6 +188,10 @@ extern volatile bool wait_for_heatup;
   extern volatile bool wait_for_user;
 #endif
 
+#if HAS_AUTO_REPORTING
+  extern bool suspend_auto_report;
+#endif
+
 #if ENABLED(AUTO_BED_LEVELING_UBL)
   typedef struct { double A, B, D; } linear_fit;
   linear_fit* lsf_linear_fit(double x[], double y[], double z[], const int);
diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h
index 084f525869..beb4d178cc 100644
--- a/Marlin/src/inc/Conditionals_post.h
+++ b/Marlin/src/inc/Conditionals_post.h
@@ -821,6 +821,8 @@
   #undef AUTO_REPORT_TEMPERATURES
 #endif
 
+#define HAS_AUTO_REPORTING (ENABLED(AUTO_REPORT_TEMPERATURES) || ENABLED(AUTO_REPORT_SD_STATUS))
+
 /**
  * This setting is also used by M109 when trying to calculate
  * a ballpark safe margin to prevent wait-forever situation.
-- 
GitLab