From 764fc81761a539827518adee094f700889f84918 Mon Sep 17 00:00:00 2001
From: Luc Hoang Long <i.me.mine@luchoanglong.com>
Date: Mon, 6 Jul 2020 13:17:40 +0700
Subject: [PATCH] Use Material Preset 1 for PID autotune (#18446)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
---
 Marlin/src/gcode/temp/M303.cpp        | 14 +++-----------
 Marlin/src/lcd/menu/menu_advanced.cpp | 13 +++----------
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp
index 7e049436bb..31d16faff4 100644
--- a/Marlin/src/gcode/temp/M303.cpp
+++ b/Marlin/src/gcode/temp/M303.cpp
@@ -60,16 +60,8 @@ void GcodeSuite::M303() {
     }
   #endif
 
-  #if ENABLED(PIDTEMPBED)
-    #define SI H_BED
-  #else
-    #define SI H_E0
-  #endif
-  #if ENABLED(PIDTEMP)
-    #define EI HOTENDS - 1
-  #else
-    #define EI H_BED
-  #endif
+  #define SI TERN(PIDTEMPBED, H_BED, H_E0)
+  #define EI TERN(PIDTEMP, HOTENDS - 1, H_BED)
   const heater_ind_t e = (heater_ind_t)parser.intval('E');
   if (!WITHIN(e, SI, EI)) {
     SERIAL_ECHOLNPGM(STR_PID_BAD_EXTRUDER_NUM);
@@ -79,7 +71,7 @@ void GcodeSuite::M303() {
 
   const int c = parser.intval('C', 5);
   const bool u = parser.boolval('U');
-  const int16_t temp = parser.celsiusval('S', e < 0 ? 70 : 150);
+  const int16_t temp = parser.celsiusval('S', e < 0 ? PREHEAT_1_TEMP_BED : PREHEAT_1_TEMP_HOTEND);
 
   #if DISABLED(BUSY_WHILE_HEATING)
     KEEPALIVE_STATE(NOT_BUSY);
diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp
index b7f522f169..cee5e6e33f 100644
--- a/Marlin/src/lcd/menu/menu_advanced.cpp
+++ b/Marlin/src/lcd/menu/menu_advanced.cpp
@@ -169,17 +169,10 @@ void menu_cancelobject();
 #if ENABLED(PID_AUTOTUNE_MENU)
 
   #if ENABLED(PIDTEMP)
-    #ifdef PREHEAT_1_TEMP_HOTEND
-      #define PID_TUNE_TEMP PREHEAT_1_TEMP_HOTEND
-    #else
-      #define PID_TUNE_TEMP 200
-    #endif
-    int16_t autotune_temp[HOTENDS] = ARRAY_BY_HOTENDS1(PID_TUNE_TEMP);
-    #undef PID_TUNE_TEMP
+    int16_t autotune_temp[HOTENDS] = ARRAY_BY_HOTENDS1(PREHEAT_1_TEMP_HOTEND);
   #endif
-
   #if ENABLED(PIDTEMPBED)
-    int16_t autotune_temp_bed = 70;
+    int16_t autotune_temp_bed = PREHEAT_1_TEMP_BED;
   #endif
 
   #include "../../gcode/queue.h"
@@ -324,7 +317,7 @@ void menu_cancelobject();
         #ifndef BED_OVERSHOOT
           #define BED_OVERSHOOT 5
         #endif
-        EDIT_ITEM_FAST_N(int3, -1, MSG_PID_AUTOTUNE_E, &autotune_temp_bed, 70, BED_MAXTEMP - BED_OVERSHOOT, []{ _lcd_autotune(-1); });
+        EDIT_ITEM_FAST_N(int3, -1, MSG_PID_AUTOTUNE_E, &autotune_temp_bed, PREHEAT_1_TEMP_BED, BED_MAXTEMP - BED_OVERSHOOT, []{ _lcd_autotune(-1); });
       #endif
     #endif