From 994aa9f6923e2307d13badd26a15e6d57525955f Mon Sep 17 00:00:00 2001 From: plampix Date: Fri, 5 Jan 2024 00:09:53 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Slimmer=20null=20T=20comma?= =?UTF-8?q?nd=20(#26615)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/MarlinCore.cpp | 4 +++- Marlin/src/gcode/bedlevel/G26.cpp | 6 ++++-- Marlin/src/gcode/config/M217.cpp | 7 +++++-- Marlin/src/gcode/control/T.cpp | 6 ++++++ Marlin/src/gcode/gcode.cpp | 18 ++++++++++-------- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/inc/Conditionals_adv.h | 4 ++++ Marlin/src/module/tool_change.cpp | 4 ++++ ini/features.ini | 1 + platformio.ini | 1 - 10 files changed, 38 insertions(+), 15 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 0a97b4d132..f0bd97ac1c 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -219,7 +219,9 @@ #include "feature/fanmux.h" #endif -#include "module/tool_change.h" +#if HAS_TOOLCHANGE + #include "module/tool_change.h" +#endif #if HAS_FANCHECK #include "feature/fancheck.h" diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 30643cb84e..5c7f9e1f6d 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -501,8 +501,10 @@ void GcodeSuite::G26() { // or if the parameter parsing did not go OK, abort if (homing_needed_error()) return; - // Change the tool first, if specified - if (parser.seenval('T')) tool_change(parser.value_int()); + #if HAS_TOOLCHANGE + // Change the tool first, if specified + if (parser.seenval('T')) tool_change(parser.value_int()); + #endif g26_helper_t g26; diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 5ef06e4823..59737d3b04 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -25,7 +25,10 @@ #if HAS_MULTI_EXTRUDER #include "../gcode.h" -#include "../../module/tool_change.h" + +#if HAS_TOOLCHANGE + #include "../../module/tool_change.h" +#endif #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) #include "../../module/motion.h" // for active_extruder @@ -119,7 +122,7 @@ void GcodeSuite::M217() { #endif #endif - #if HAS_Z_AXIS + #if HAS_Z_AXIS && HAS_TOOLCHANGE if (parser.seenval('Z')) { toolchange_settings.z_raise = parser.value_linear_units(); } #endif diff --git a/Marlin/src/gcode/control/T.cpp b/Marlin/src/gcode/control/T.cpp index cbe4d26fac..3c13fe231a 100644 --- a/Marlin/src/gcode/control/T.cpp +++ b/Marlin/src/gcode/control/T.cpp @@ -20,6 +20,10 @@ * */ +#include "../../inc/MarlinConfigPre.h" + +#if HAS_TOOLCHANGE + #include "../gcode.h" #include "../../module/tool_change.h" @@ -76,3 +80,5 @@ void GcodeSuite::T(const int8_t tool_index) { #endif ); } + +#endif // HAS_TOOLCHANGE diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 5fb0594d9f..86d73dd56f 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -122,14 +122,16 @@ void GcodeSuite::say_units() { * Return -1 if the T parameter is out of range */ int8_t GcodeSuite::get_target_extruder_from_command() { - if (parser.seenval('T')) { - const int8_t e = parser.value_byte(); - if (e < EXTRUDERS) return e; - SERIAL_ECHO_START(); - SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum); - SERIAL_ECHOLNPGM(" " STR_INVALID_EXTRUDER " ", e); - return -1; - } + #if HAS_TOOLCHANGE + if (parser.seenval('T')) { + const int8_t e = parser.value_byte(); + if (e < EXTRUDERS) return e; + SERIAL_ECHO_START(); + SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum); + SERIAL_ECHOLNPGM(" " STR_INVALID_EXTRUDER " ", e); + return -1; + } + #endif return active_extruder; } diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index ae60ac7556..6be5dc642c 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -1285,7 +1285,7 @@ private: static void M710_report(const bool forReplay=true); #endif - static void T(const int8_t tool_index); + static void T(const int8_t tool_index) IF_DISABLED(HAS_TOOLCHANGE, { UNUSED(tool_index); }); }; diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 89a57f274d..191da44af7 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -803,6 +803,10 @@ #endif #endif +#if HAS_MULTI_EXTRUDER || HAS_MULTI_HOTEND || HAS_PRUSA_MMU2 || (ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1) + #define HAS_TOOLCHANGE 1 +#endif + #if ENABLED(MIXING_EXTRUDER) && (ENABLED(RETRACT_SYNC_MIXING) || ALL(FILAMENT_LOAD_UNLOAD_GCODES, FILAMENT_UNLOAD_ALL_EXTRUDERS)) #define HAS_MIXER_SYNC_CHANNEL 1 #endif diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 373dcf3142..b5cacc2f3b 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -22,6 +22,8 @@ #include "../inc/MarlinConfigPre.h" +#if HAS_TOOLCHANGE + #include "tool_change.h" #include "motion.h" @@ -1629,3 +1631,5 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { } #endif // TOOLCHANGE_MIGRATION_FEATURE + +#endif // HAS_TOOLCHANGE diff --git a/ini/features.ini b/ini/features.ini index 32fd6c2621..c4af1d0d95 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -306,6 +306,7 @@ SERVO_DETACH_GCODE = build_src_filter=+ SPI_FLASH_BACKUP = build_src_filter=+ PLATFORM_M997_SUPPORT = build_src_filter=+ +HAS_TOOLCHANGE = build_src_filter=+ FT_MOTION = build_src_filter=+ + LIN_ADVANCE = build_src_filter=+ PHOTO_GCODE = build_src_filter=+ diff --git a/platformio.ini b/platformio.ini index 5249b790f2..e6adfe2b6b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -107,7 +107,6 @@ default_src_filter = + - - + + + - + + + +