From bed8abe5b6df751d7dafc6f0f8d8dff7338625ce Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Sun, 3 Apr 2022 01:27:05 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20PID=20edit=20menu=20for=20?= =?UTF-8?q?Bed,=20Chamber=20(#23987)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu_advanced.cpp | 43 ++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index eb979a4319..184ff8cf8e 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -39,7 +39,7 @@ #include "../../module/probe.h" #endif -#if ENABLED(PIDTEMP) +#if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER) #include "../../module/temperature.h" #endif @@ -190,7 +190,12 @@ void menu_backlash(); #if ENABLED(PIDTEMPCHAMBER) case H_CHAMBER: tune_temp = autotune_temp_chamber; break; #endif - default: tune_temp = autotune_temp[hid]; break; + default: + #if ENABLED(PIDTEMP) + tune_temp = autotune_temp[hid]; break; + #else + return; + #endif } sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), hid, tune_temp); queue.inject(cmd); @@ -206,14 +211,36 @@ void menu_backlash(); // Helpers for editing PID Ki & Kd values // grab the PID value out of the temp variable; scale it; then update the PID driver void copy_and_scalePID_i(int16_t e) { - UNUSED(e); - PID_PARAM(Ki, e) = scalePID_i(raw_Ki); - thermalManager.updatePID(); + switch (e) { + #if ENABLED(PIDTEMPBED) + case H_BED: thermalManager.temp_bed.pid.Ki = scalePID_i(raw_Ki); break; + #endif + #if ENABLED(PIDTEMPCHAMBER) + case H_CHAMBER: thermalManager.temp_chamber.pid.Ki = scalePID_i(raw_Ki); break; + #endif + default: + #if ENABLED(PIDTEMP) + PID_PARAM(Ki, e) = scalePID_i(raw_Ki); + thermalManager.updatePID(); + #endif + break; + } } void copy_and_scalePID_d(int16_t e) { - UNUSED(e); - PID_PARAM(Kd, e) = scalePID_d(raw_Kd); - thermalManager.updatePID(); + switch (e) { + #if ENABLED(PIDTEMPBED) + case H_BED: thermalManager.temp_bed.pid.Kd = scalePID_d(raw_Kd); break; + #endif + #if ENABLED(PIDTEMPCHAMBER) + case H_CHAMBER: thermalManager.temp_chamber.pid.Kd = scalePID_d(raw_Kd); break; + #endif + default: + #if ENABLED(PIDTEMP) + PID_PARAM(Kd, e) = scalePID_d(raw_Kd); + thermalManager.updatePID(); + #endif + break; + } } #define _DEFINE_PIDTEMP_BASE_FUNCS(N) \