diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index bd07add891b8..7f6d17f195e6 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -923,6 +923,7 @@ //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of flash) //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of flash) + //#define DISABLE_M303_AUTOTUNE // Disable the M303 PID autotune command to save ~2.7K bytes of flash. #endif // @section safety diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 10a6f3d65b72..1ca72a8acb2c 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -832,7 +832,7 @@ void GcodeSuite::process_parsed_command(bool no_ok/*=false*/) { case 302: M302(); break; // M302: Allow cold extrudes (set the minimum extrude temperature) #endif - #if HAS_PID_HEATING + #if HAS_PID_AUTOTUNE case 303: M303(); break; // M303: PID autotune #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 378a1a73f47f..1299b8aba65a 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -1014,7 +1014,7 @@ class GcodeSuite { static void M302(); #endif - #if HAS_PID_HEATING + #if HAS_PID_AUTOTUNE static void M303(); #endif diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index ffa4efb6993c..72691b55bf92 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if HAS_PID_HEATING +#if HAS_PID_AUTOTUNE #include "../gcode.h" #include "../queue.h" // for flush_tx @@ -85,4 +85,4 @@ void GcodeSuite::M303() { queue.flush_rx(); } -#endif // HAS_PID_HEATING +#endif // HAS_PID_AUTOTUNE diff --git a/Marlin/src/inc/Conditionals-5-post.h b/Marlin/src/inc/Conditionals-5-post.h index 0fa53dbf3ece..2742ba36bcb1 100644 --- a/Marlin/src/inc/Conditionals-5-post.h +++ b/Marlin/src/inc/Conditionals-5-post.h @@ -2731,6 +2731,11 @@ #define HAS_PID_HEATING 1 #endif +// PID autotune (M303 command) +#if HAS_PID_HEATING && DISABLED(DISABLE_M303_AUTOTUNE) + #define HAS_PID_AUTOTUNE 1 +#endif + // Thermal protection #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 #define WATCH_HOTENDS 1 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 694f88f3ee59..33ff23c70984 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1051,6 +1051,12 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i #endif #endif + +/* PID autotune (M303 command) */ +#if ALL(PID_AUTOTUNE_MENU, DISABLE_M303_AUTOTUNE) + #error "Can't enable PID_AUTOTUNE_MENU and DISABLE_M303_AUTOTUNE at the same time." +#endif + /** * Bed Heating Options - PID vs Limit Switching */ diff --git a/Marlin/src/lcd/dwin/proui/dwin.cpp b/Marlin/src/lcd/dwin/proui/dwin.cpp index ae94ee0025c6..a7a47c89f917 100644 --- a/Marlin/src/lcd/dwin/proui/dwin.cpp +++ b/Marlin/src/lcd/dwin/proui/dwin.cpp @@ -1695,21 +1695,23 @@ void dwinLevelingDone() { #if HAS_PID_HEATING - void dwinStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - hmiData.pidCycles = count; - switch (hid) { - #if ENABLED(PIDTEMP) - case 0 ... HOTENDS - 1: hmiData.hotendPIDT = temp; break; - #endif - #if ENABLED(PIDTEMPBED) - case H_BED: hmiData.bedPIDT = temp; break; - #endif - #if ENABLED(PIDTEMPCHAMBER) - case H_CHAMBER: hmiData.chamberPIDT = temp; break; - #endif - default: break; + #if HAS_PID_AUTOTUNE + void dwinStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + hmiData.pidCycles = count; + switch (hid) { + #if ENABLED(PIDTEMP) + case 0 ... HOTENDS - 1: hmiData.hotendPIDT = temp; break; + #endif + #if ENABLED(PIDTEMPBED) + case H_BED: hmiData.bedPIDT = temp; break; + #endif + #if ENABLED(PIDTEMPCHAMBER) + case H_CHAMBER: hmiData.chamberPIDT = temp; break; + #endif + default: break; + } } - } + #endif void dwinPIDTuning(tempcontrol_t result) { hmiValue.tempControl = result; diff --git a/Marlin/src/lcd/dwin/proui/dwin.h b/Marlin/src/lcd/dwin/proui/dwin.h index 12910a25375d..36ccd18487c4 100644 --- a/Marlin/src/lcd/dwin/proui/dwin.h +++ b/Marlin/src/lcd/dwin/proui/dwin.h @@ -398,7 +398,9 @@ void drawMaxAccelMenu(); // PID #if HAS_PID_HEATING #include "../../../module/temperature.h" - void dwinStartM303(const int count, const heater_id_t hid, const celsius_t temp); + #if HAS_PID_AUTOTUNE + void dwinStartM303(const int count, const heater_id_t hid, const celsius_t temp); + #endif void dwinPIDTuning(tempcontrol_t result); #if ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU) #if ENABLED(PIDTEMP) diff --git a/Marlin/src/lcd/dwin/proui/proui_extui.cpp b/Marlin/src/lcd/dwin/proui/proui_extui.cpp index 9f19d354ad21..b8565c3b90cc 100644 --- a/Marlin/src/lcd/dwin/proui/proui_extui.cpp +++ b/Marlin/src/lcd/dwin/proui/proui_extui.cpp @@ -213,9 +213,11 @@ namespace ExtUI { } } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - dwinStartM303(count, hid, temp); - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + dwinStartM303(count, hid, temp); + } + #endif #endif diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp index 966ff905d473..f0d7c548b0db 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp @@ -167,9 +167,11 @@ namespace ExtUI { void onPIDTuning(const pidresult_t rst) { // Called for temperature PID tuning result } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - // Called by M303 to update the UI - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + // Called by M303 to update the UI + } + #endif #endif #if ENABLED(MPC_AUTOTUNE) diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp index 26be48f2ffae..ca96d3b20eb8 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp @@ -156,9 +156,11 @@ namespace ExtUI { void onPIDTuning(const pidresult_t rst) { // Called for temperature PID tuning result } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - // Called by M303 to update the UI - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + // Called by M303 to update the UI + } + #endif #endif #if ENABLED(MPC_AUTOTUNE) diff --git a/Marlin/src/lcd/extui/anycubic_vyper/vyper_extui.cpp b/Marlin/src/lcd/extui/anycubic_vyper/vyper_extui.cpp index 53429913209e..24ee95066225 100644 --- a/Marlin/src/lcd/extui/anycubic_vyper/vyper_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_vyper/vyper_extui.cpp @@ -168,9 +168,11 @@ namespace ExtUI { void onPIDTuning(const pidresult_t rst) { // Called for temperature PID tuning result } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - // Called by M303 to update the UI - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + // Called by M303 to update the UI + } + #endif #endif #if ENABLED(MPC_AUTOTUNE) diff --git a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp index 59a4599df677..039e8e2b47a5 100644 --- a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp +++ b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp @@ -203,9 +203,11 @@ namespace ExtUI { } screen.gotoScreen(DGUS_SCREEN_MAIN); } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - // Called by M303 to update the UI - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + // Called by M303 to update the UI + } + #endif #endif #if ENABLED(MPC_AUTOTUNE) diff --git a/Marlin/src/lcd/extui/dgus_e3s1pro/dgus_e3s1pro_extui.cpp b/Marlin/src/lcd/extui/dgus_e3s1pro/dgus_e3s1pro_extui.cpp index f38931c33f43..909e43d573da 100644 --- a/Marlin/src/lcd/extui/dgus_e3s1pro/dgus_e3s1pro_extui.cpp +++ b/Marlin/src/lcd/extui/dgus_e3s1pro/dgus_e3s1pro_extui.cpp @@ -176,9 +176,11 @@ namespace ExtUI { // Called for temperature PID tuning result screen.pidTuning(rst); } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - // Called by M303 to update the UI - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + // Called by M303 to update the UI + } + #endif #endif #if ENABLED(MPC_AUTOTUNE) diff --git a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp index 2b7afa76d495..6d9119ad2dc1 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp @@ -172,9 +172,11 @@ namespace ExtUI { // Called for temperature PID tuning result screen.pidTuning(rst); } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - // Called by M303 to update the UI - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + // Called by M303 to update the UI + } + #endif #endif #if ENABLED(MPC_AUTOTUNE) diff --git a/Marlin/src/lcd/extui/example/example.cpp b/Marlin/src/lcd/extui/example/example.cpp index 177ce156d54a..36d5450d8e8c 100644 --- a/Marlin/src/lcd/extui/example/example.cpp +++ b/Marlin/src/lcd/extui/example/example.cpp @@ -170,9 +170,11 @@ namespace ExtUI { case PID_DONE: break; } } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - // Called by M303 to update the UI - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + // Called by M303 to update the UI + } + #endif #endif #if ENABLED(MPC_AUTOTUNE) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp index d2c320badb71..8373476ae528 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp @@ -208,9 +208,11 @@ namespace ExtUI { } GOTO_SCREEN(StatusScreen); } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - // Called by M303 to update the UI - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + // Called by M303 to update the UI + } + #endif #endif // HAS_PID_HEATING #if ENABLED(MPC_AUTOTUNE) diff --git a/Marlin/src/lcd/extui/ia_creality/ia_creality_extui.cpp b/Marlin/src/lcd/extui/ia_creality/ia_creality_extui.cpp index 2110117c7892..cf2a2bc3a036 100644 --- a/Marlin/src/lcd/extui/ia_creality/ia_creality_extui.cpp +++ b/Marlin/src/lcd/extui/ia_creality/ia_creality_extui.cpp @@ -419,9 +419,11 @@ void onPostprocessSettings() {} #endif onStatusChanged(F("PID Tune Finished")); } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - // Called by M303 to update the UI - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + // Called by M303 to update the UI + } + #endif #endif #if ENABLED(MPC_AUTOTUNE) diff --git a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp index 53c5fa7e74ea..49a5947c7afa 100644 --- a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp +++ b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp @@ -128,9 +128,11 @@ namespace ExtUI { } } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - // Called by M303 to update the UI - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + // Called by M303 to update the UI + } + #endif #endif diff --git a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp index 7beecfecbfb3..d2fa653356fd 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp @@ -155,9 +155,11 @@ namespace ExtUI { // Called for temperature PID tuning result nextion.panelInfo(37); } - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { - // Called by M303 to update the UI - } + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) { + // Called by M303 to update the UI + } + #endif #endif #if ENABLED(MPC_AUTOTUNE) diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 608e63285424..62ee0f4e9214 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -935,9 +935,11 @@ namespace ExtUI { thermalManager.setPID(uint8_t(tool), p, i, d); } - void startPIDTune(const celsius_t temp, extruder_t tool) { - thermalManager.PID_autotune(temp, heater_id_t(tool), 8, true); - } + #if HAS_PID_AUTOTUNE + void startPIDTune(const celsius_t temp, extruder_t tool) { + thermalManager.PID_autotune(temp, heater_id_t(tool), 8, true); + } + #endif #endif #if ENABLED(PIDTEMPBED) @@ -949,9 +951,11 @@ namespace ExtUI { thermalManager.temp_bed.pid.set(p, i, d); } - void startBedPIDTune(const celsius_t temp) { - thermalManager.PID_autotune(temp, H_BED, 4, true); - } + #if HAS_PID_AUTOTUNE + void startBedPIDTune(const celsius_t temp) { + thermalManager.PID_autotune(temp, H_BED, 4, true); + } + #endif #endif void injectCommands_P(PGM_P const gcode) { queue.inject_P(gcode); } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index f864f3d1cd92..880a153e8a5f 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -567,7 +567,9 @@ namespace ExtUI { #endif #if HAS_PID_HEATING void onPIDTuning(const pidresult_t rst); - void onStartM303(const int count, const heater_id_t hid, const celsius_t temp); + #if HAS_PID_AUTOTUNE + void onStartM303(const int count, const heater_id_t hid, const celsius_t temp); + #endif #endif #if ENABLED(MPC_AUTOTUNE) void onMPCTuning(const mpcresult_t rst); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f0ca49ef6612..8cc4283e91c8 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -772,7 +772,7 @@ void Temperature::factory_reset() { } // factory_reset -#if HAS_PID_HEATING +#if HAS_PID_AUTOTUNE inline void say_default_() { SERIAL_ECHOPGM("#define DEFAULT_"); } @@ -1031,7 +1031,7 @@ void Temperature::factory_reset() { return; } -#endif // HAS_PID_HEATING +#endif // HAS_PID_AUTOTUNE #if ENABLED(MPC_AUTOTUNE) diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index f2ef4d0f6cbf..92ce9859b2b7 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -1257,16 +1257,18 @@ class Temperature { static bool tuning_idle(const millis_t &ms); - /** - * M303 PID auto-tuning for hotends or bed - */ #if HAS_PID_HEATING #if HAS_PID_DEBUG static bool pid_debug_flag; #endif - static void PID_autotune(const celsius_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result=false); + /** + * M303 PID auto-tuning for hotends or bed + */ + #if HAS_PID_AUTOTUNE + static void PID_autotune(const celsius_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result=false); + #endif // HAS_PID_AUTOTUNE // Update the temp manager when PID values change #if ENABLED(PIDTEMP)