From e3f583a3be67479457f7a1d3a9c3f707a547cec6 Mon Sep 17 00:00:00 2001 From: WPBack Date: Mon, 21 Mar 2016 19:02:31 +0100 Subject: [PATCH] Fixes for PID AutoTune from menu Fixes for #3189 Setting a temp is still missing --- Marlin/Configuration.h | 2 +- Marlin/Marlin_main.cpp | 2 +- Marlin/temperature.cpp | 2 +- Marlin/temperature.h | 2 +- Marlin/ultralcd.cpp | 33 ++++++++++++--------------------- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index a0b23bc225..fff1dd5677 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -718,7 +718,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. -#define ULTIPANEL //the UltiPanel as on Thingiverse +//#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index fdef1402ea..9a21803da3 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -5142,7 +5142,7 @@ inline void gcode_M226() { inline void gcode_M303() { int e = code_seen('E') ? code_value_short() : 0; int c = code_seen('C') ? code_value_short() : 5; - bool u = code_seen('U') && code_value_short() == 1; + bool u = code_seen('U') && code_value_short() != 0; float temp = code_seen('S') ? code_value() : (e < 0 ? 70.0 : 150.0); diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 7785f43928..a0ee3e8f5f 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -199,7 +199,7 @@ static void updateTemperaturesFromRawValues(); //================================ Functions ================================ //=========================================================================== -void PID_autotune(float temp, int extruder, int ncycles, bool set_result) { +void PID_autotune(float temp, int extruder, int ncycles, bool set_result /* = false */) { float input = 0.0; int cycles = 0; bool heating = true; diff --git a/Marlin/temperature.h b/Marlin/temperature.h index 83f531bd58..06c732f656 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -141,7 +141,7 @@ int getHeaterPower(int heater); void disable_all_heaters(); void updatePID(); -void PID_autotune(float temp, int extruder, int ncycles, bool set_result); +void PID_autotune(float temp, int extruder, int ncycles, bool set_result = false); void setExtruderAutoFanState(int pin, bool state); void checkExtruderAutoFans(); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 06ae8144ba..1f76b1397b 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1189,39 +1189,30 @@ static void lcd_control_temperature_menu() { raw_Kd = unscalePID_d(PID_PARAM(Kd, eindex)); \ MENU_ITEM_EDIT(float52, MSG_PID_P ELABEL, &PID_PARAM(Kp, eindex), 1, 9990); \ MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I ELABEL, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_E ## eindex); \ - MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D ELABEL, &raw_Kd, 1, 9990, copy_and_scalePID_d_E ## eindex); \ - if (eindex == 0) { \ - MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1")); \ - } \ - else if (eindex == 1) { \ - MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1 E1")); \ - } \ - else if (eindex == 2) { \ - MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1 E2")); \ - } \ - else { \ - MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1 E3")); \ - } + MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D ELABEL, &raw_Kd, 1, 9990, copy_and_scalePID_d_E ## eindex) #if ENABLED(PID_ADD_EXTRUSION_RATE) - #define PID_MENU_ITEMS(ELABEL, eindex) \ + #define PID_MENU_ITEMS(ELABEL, eindex, AUTOTUNE_CMD) \ _PID_MENU_ITEMS(ELABEL, eindex); \ - MENU_ITEM_EDIT(float3, MSG_PID_C ELABEL, &PID_PARAM(Kc, eindex), 1, 9990) + MENU_ITEM_EDIT(float3, MSG_PID_C ELABEL, &PID_PARAM(Kc, eindex), 1, 9990); \ + MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR(AUTOTUNE_CMD)) #else - #define PID_MENU_ITEMS(ELABEL, eindex) _PID_MENU_ITEMS(ELABEL, eindex) + #define PID_MENU_ITEMS(ELABEL, eindex, AUTOTUNE_CMD) \ + _PID_MENU_ITEMS(ELABEL, eindex); \ + MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR(AUTOTUNE_CMD)) #endif #if ENABLED(PID_PARAMS_PER_EXTRUDER) && EXTRUDERS > 1 - PID_MENU_ITEMS(MSG_E1, 0); - PID_MENU_ITEMS(MSG_E2, 1); + PID_MENU_ITEMS(MSG_E1, 0, "M303 U1"); + PID_MENU_ITEMS(MSG_E2, 1, "M303 U1 E1"); #if EXTRUDERS > 2 - PID_MENU_ITEMS(MSG_E3, 2); + PID_MENU_ITEMS(MSG_E3, 2, "M303 U1 E2"); #if EXTRUDERS > 3 - PID_MENU_ITEMS(MSG_E4, 3); + PID_MENU_ITEMS(MSG_E4, 3, "M303 U1 E3"); #endif //EXTRUDERS > 3 #endif //EXTRUDERS > 2 #else //!PID_PARAMS_PER_EXTRUDER || EXTRUDERS == 1 - PID_MENU_ITEMS("", 0); + PID_MENU_ITEMS("", 0, "M303 U1"); #endif //!PID_PARAMS_PER_EXTRUDER || EXTRUDERS == 1 #endif //PIDTEMP