From 913de024a991b41038858cf65b88165fcfb43f2b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 6 Mar 2020 13:55:00 -0600 Subject: [PATCH] Change PID dummy value to NAN Fixes #17078 --- Marlin/src/module/configuration_store.cpp | 10 +++++----- Marlin/src/module/temperature.h | 8 +++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index 3f44963ac3..9d1bbaab21 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -851,8 +851,8 @@ void MarlinSettings::postprocess() { HOTEND_LOOP() { PIDCF_t pidcf = { #if DISABLED(PIDTEMP) - DUMMY_PID_VALUE, DUMMY_PID_VALUE, DUMMY_PID_VALUE, - DUMMY_PID_VALUE, DUMMY_PID_VALUE + NAN, NAN, NAN, + NAN, NAN #else PID_PARAM(Kp, e), unscalePID_i(PID_PARAM(Ki, e)), @@ -881,7 +881,7 @@ void MarlinSettings::postprocess() { const PID_t bed_pid = { #if DISABLED(PIDTEMPBED) - DUMMY_PID_VALUE, DUMMY_PID_VALUE, DUMMY_PID_VALUE + NAN, NAN, NAN #else // Store the unscaled PID values thermalManager.temp_bed.pid.Kp, @@ -1725,7 +1725,7 @@ void MarlinSettings::postprocess() { PIDCF_t pidcf; EEPROM_READ(pidcf); #if ENABLED(PIDTEMP) - if (!validating && pidcf.Kp != DUMMY_PID_VALUE) { + if (!validating && !isnan(pidcf.Kp)) { // Scale PID values since EEPROM values are unscaled PID_PARAM(Kp, e) = pidcf.Kp; PID_PARAM(Ki, e) = scalePID_i(pidcf.Ki); @@ -1761,7 +1761,7 @@ void MarlinSettings::postprocess() { PID_t pid; EEPROM_READ(pid); #if ENABLED(PIDTEMPBED) - if (!validating && pid.Kp != DUMMY_PID_VALUE) { + if (!validating && !isnan(pid.Kp)) { // Scale PID values since EEPROM values are unscaled thermalManager.temp_bed.pid.Kp = pid.Kp; thermalManager.temp_bed.pid.Ki = scalePID_i(pid.Ki); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 655de8d6f3..24e0054496 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -74,8 +74,6 @@ hotend_pid_t; typedef IF<(LPQ_MAX_LEN > 255), uint16_t, uint8_t>::type lpq_ptr_t; #endif -#define DUMMY_PID_VALUE 3000.0f - #if ENABLED(PIDTEMP) #define _PID_Kp(H) Temperature::temp_hotend[H].pid.Kp #define _PID_Ki(H) Temperature::temp_hotend[H].pid.Ki @@ -92,9 +90,9 @@ hotend_pid_t; #define _PID_Kf(H) 0 #endif #else - #define _PID_Kp(H) DUMMY_PID_VALUE - #define _PID_Ki(H) DUMMY_PID_VALUE - #define _PID_Kd(H) DUMMY_PID_VALUE + #define _PID_Kp(H) NAN + #define _PID_Ki(H) NAN + #define _PID_Kd(H) NAN #define _PID_Kc(H) 1 #endif