From b0ff3a4c6da9c3806853d57f69c3f2c2d469f44b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Nov 2017 00:43:01 -0600 Subject: [PATCH] Cleanup around updatePID --- Marlin/Marlin_main.cpp | 2 -- Marlin/temperature.cpp | 16 +++++++--------- Marlin/temperature.h | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 8dbbcd919..ae15b6064 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -9428,8 +9428,6 @@ inline void gcode_M226() { if (parser.seen('I')) thermalManager.bedKi = scalePID_i(parser.value_float()); if (parser.seen('D')) thermalManager.bedKd = scalePID_d(parser.value_float()); - thermalManager.updatePID(); - SERIAL_ECHO_START(); SERIAL_ECHOPAIR(" p:", thermalManager.bedKp); SERIAL_ECHOPAIR(" i:", unscalePID_i(thermalManager.bedKi)); diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index ae4201be8..bded5c540 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -215,6 +215,12 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS], #if HAS_PID_HEATING + /** + * PID Autotuning (M303) + * + * Alternately heat and cool the nozzle, observing its behavior to + * determine the best PID values to achieve a stable temperature. + */ void Temperature::PID_autotune(const float temp, const int8_t hotend, const int8_t ncycles, const bool set_result/*=false*/) { float input = 0.0; int cycles = 0; @@ -466,7 +472,7 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS], bedKp = workKp; \ bedKi = scalePID_i(workKi); \ bedKd = scalePID_d(workKd); \ - updatePID(); }while(0) + }while(0) #define _SET_EXTRUDER_PID() do { \ PID_PARAM(Kp, hotend) = workKp; \ @@ -502,14 +508,6 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS], Temperature::Temperature() { } -void Temperature::updatePID() { - #if ENABLED(PIDTEMP) - #if ENABLED(PID_EXTRUSION_SCALING) - last_e_position = 0; - #endif - #endif -} - int Temperature::getHeaterPower(int heater) { return heater < 0 ? soft_pwm_amount_bed : soft_pwm_amount[heater]; } diff --git a/Marlin/temperature.h b/Marlin/temperature.h index 6c43c2855..70443125b 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -438,12 +438,19 @@ class Temperature { */ #if HAS_PID_HEATING static void PID_autotune(const float temp, const int8_t hotend, const int8_t ncycles, const bool set_result=false); - #endif - /** - * Update the temp manager when PID values change - */ - static void updatePID(); + /** + * Update the temp manager when PID values change + */ + #if ENABLED(PIDTEMP) + FORCE_INLINE static void updatePID() { + #if ENABLED(PID_EXTRUSION_SCALING) + last_e_position = 0; + #endif + } + #endif + + #endif #if ENABLED(BABYSTEPPING)