From 7709261ea9f73d60006b5ab1ae488086908d0e79 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <github@thinkyhead.com>
Date: Wed, 4 Mar 2020 12:50:43 -0600
Subject: [PATCH] Move shared code to wait_for_bed_heating

---
 Marlin/src/module/motion.cpp      | 12 ++----------
 Marlin/src/module/probe.cpp       | 12 +-----------
 Marlin/src/module/probe.h         |  3 ---
 Marlin/src/module/temperature.cpp |  9 +++++++++
 Marlin/src/module/temperature.h   |  2 ++
 5 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp
index 1ce225cae5..2e7a574b39 100644
--- a/Marlin/src/module/motion.cpp
+++ b/Marlin/src/module/motion.cpp
@@ -1312,16 +1312,8 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
 
   #if HOMING_Z_WITH_PROBE && HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
     // Wait for bed to heat back up between probing points
-    if (axis == Z_AXIS && distance < 0 && thermalManager.isHeatingBed()) {
-      serialprintPGM(probe.msg_wait_for_bed_heating);
-      #if HAS_DISPLAY
-        LCD_MESSAGEPGM(MSG_BED_HEATING);
-      #endif
-      thermalManager.wait_for_bed();
-      #if HAS_DISPLAY
-        ui.reset_status();
-      #endif
-    }
+    if (axis == Z_AXIS && distance < 0)
+      thermalManager.wait_for_bed_heating();
   #endif
 
   // Only do some things when moving towards an endstop
diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp
index 67c1655374..63008170bd 100644
--- a/Marlin/src/module/probe.cpp
+++ b/Marlin/src/module/probe.cpp
@@ -455,10 +455,6 @@ bool Probe::set_deployed(const bool deploy) {
  * @return true to indicate an error
  */
 
-#if HAS_BED_PROBE && HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
-  const char Probe::msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n";
-#endif
-
 /**
  * @brief Move down until the probe triggers or the low limit is reached
  *
@@ -473,13 +469,7 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
   if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::probe_down_to_z", current_position);
 
   #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
-    // Wait for bed to heat back up between probing points
-    if (thermalManager.isHeatingBed()) {
-      serialprintPGM(msg_wait_for_bed_heating);
-      LCD_MESSAGEPGM(MSG_BED_HEATING);
-      thermalManager.wait_for_bed();
-      ui.reset_status();
-    }
+    thermalManager.wait_for_bed_heating();
   #endif
 
   #if ENABLED(BLTOUCH) && DISABLED(BLTOUCH_HS_MODE)
diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h
index c457fad480..4632c7c929 100644
--- a/Marlin/src/module/probe.h
+++ b/Marlin/src/module/probe.h
@@ -87,9 +87,6 @@ public:
     static inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true) {
       return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative, sanity_check);
     }
-    #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
-      static const char msg_wait_for_bed_heating[25];
-    #endif
 
   #else
 
diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp
index 73a91049da..75f25f7f7e 100644
--- a/Marlin/src/module/temperature.cpp
+++ b/Marlin/src/module/temperature.cpp
@@ -3361,6 +3361,15 @@ void Temperature::tick() {
       return wait_for_heatup;
     }
 
+    void Temperature::wait_for_bed_heating() {
+      if (isHeatingBed()) {
+        SERIAL_ECHOLNPGM("Wait for bed heating...");
+        LCD_MESSAGEPGM(MSG_BED_HEATING);
+        wait_for_bed();
+        ui.reset_status();
+      }
+    }
+
   #endif // HAS_HEATED_BED
 
   #if HAS_HEATED_CHAMBER
diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h
index 66d6bd56e1..655de8d6f3 100644
--- a/Marlin/src/module/temperature.h
+++ b/Marlin/src/module/temperature.h
@@ -701,6 +701,8 @@ class Temperature {
         #endif
       );
 
+      static void wait_for_bed_heating();
+
     #endif // HAS_HEATED_BED
 
     #if HAS_TEMP_PROBE
-- 
GitLab