From 1410e79e7f81d64a926c708adf138fbce0e372d8 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <github@thinkyhead.com>
Date: Sat, 29 Sep 2018 02:10:51 -0500
Subject: [PATCH] Ensure M109 handles autotemp

---
 Marlin/src/gcode/temperature/M104_M109.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Marlin/src/gcode/temperature/M104_M109.cpp b/Marlin/src/gcode/temperature/M104_M109.cpp
index c59cd7038e..fa0178e7d4 100644
--- a/Marlin/src/gcode/temperature/M104_M109.cpp
+++ b/Marlin/src/gcode/temperature/M104_M109.cpp
@@ -89,8 +89,9 @@ void GcodeSuite::M109() {
     if (target_extruder != active_extruder) return;
   #endif
 
-  const bool no_wait_for_cooling = parser.seenval('S');
-  if (no_wait_for_cooling || parser.seenval('R')) {
+  const bool no_wait_for_cooling = parser.seenval('S'),
+             set_temp = no_wait_for_cooling || parser.seenval('R')
+  if (set_temp) {
     const int16_t temp = parser.value_celsius();
     thermalManager.setTargetHotend(temp, target_extruder);
 
@@ -123,11 +124,11 @@ void GcodeSuite::M109() {
         #endif
     #endif
   }
-  else return;
 
   #if ENABLED(AUTOTEMP)
     planner.autotemp_M104_M109();
   #endif
 
-  (void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling);
+  if (set_temp)
+    (void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling);
 }
-- 
GitLab