Skip to content

Commit 994aa9f

Browse files
plampixthinkyhead
andauthored
⚡️ Slimmer null T command (#26615)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent 6e67ad5 commit 994aa9f

File tree

10 files changed

+38
-15
lines changed

10 files changed

+38
-15
lines changed

Marlin/src/MarlinCore.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@
219219
#include "feature/fanmux.h"
220220
#endif
221221

222-
#include "module/tool_change.h"
222+
#if HAS_TOOLCHANGE
223+
#include "module/tool_change.h"
224+
#endif
223225

224226
#if HAS_FANCHECK
225227
#include "feature/fancheck.h"

Marlin/src/gcode/bedlevel/G26.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,10 @@ void GcodeSuite::G26() {
501501
// or if the parameter parsing did not go OK, abort
502502
if (homing_needed_error()) return;
503503

504-
// Change the tool first, if specified
505-
if (parser.seenval('T')) tool_change(parser.value_int());
504+
#if HAS_TOOLCHANGE
505+
// Change the tool first, if specified
506+
if (parser.seenval('T')) tool_change(parser.value_int());
507+
#endif
506508

507509
g26_helper_t g26;
508510

Marlin/src/gcode/config/M217.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
#if HAS_MULTI_EXTRUDER
2626

2727
#include "../gcode.h"
28-
#include "../../module/tool_change.h"
28+
29+
#if HAS_TOOLCHANGE
30+
#include "../../module/tool_change.h"
31+
#endif
2932

3033
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
3134
#include "../../module/motion.h" // for active_extruder
@@ -119,7 +122,7 @@ void GcodeSuite::M217() {
119122
#endif
120123
#endif
121124

122-
#if HAS_Z_AXIS
125+
#if HAS_Z_AXIS && HAS_TOOLCHANGE
123126
if (parser.seenval('Z')) { toolchange_settings.z_raise = parser.value_linear_units(); }
124127
#endif
125128

Marlin/src/gcode/control/T.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
*
2121
*/
2222

23+
#include "../../inc/MarlinConfigPre.h"
24+
25+
#if HAS_TOOLCHANGE
26+
2327
#include "../gcode.h"
2428
#include "../../module/tool_change.h"
2529

@@ -76,3 +80,5 @@ void GcodeSuite::T(const int8_t tool_index) {
7680
#endif
7781
);
7882
}
83+
84+
#endif // HAS_TOOLCHANGE

Marlin/src/gcode/gcode.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,16 @@ void GcodeSuite::say_units() {
122122
* Return -1 if the T parameter is out of range
123123
*/
124124
int8_t GcodeSuite::get_target_extruder_from_command() {
125-
if (parser.seenval('T')) {
126-
const int8_t e = parser.value_byte();
127-
if (e < EXTRUDERS) return e;
128-
SERIAL_ECHO_START();
129-
SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum);
130-
SERIAL_ECHOLNPGM(" " STR_INVALID_EXTRUDER " ", e);
131-
return -1;
132-
}
125+
#if HAS_TOOLCHANGE
126+
if (parser.seenval('T')) {
127+
const int8_t e = parser.value_byte();
128+
if (e < EXTRUDERS) return e;
129+
SERIAL_ECHO_START();
130+
SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum);
131+
SERIAL_ECHOLNPGM(" " STR_INVALID_EXTRUDER " ", e);
132+
return -1;
133+
}
134+
#endif
133135
return active_extruder;
134136
}
135137

Marlin/src/gcode/gcode.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ class GcodeSuite {
12851285
static void M710_report(const bool forReplay=true);
12861286
#endif
12871287

1288-
static void T(const int8_t tool_index);
1288+
static void T(const int8_t tool_index) IF_DISABLED(HAS_TOOLCHANGE, { UNUSED(tool_index); });
12891289

12901290
};
12911291

Marlin/src/inc/Conditionals_adv.h

+4
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,10 @@
803803
#endif
804804
#endif
805805

806+
#if HAS_MULTI_EXTRUDER || HAS_MULTI_HOTEND || HAS_PRUSA_MMU2 || (ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1)
807+
#define HAS_TOOLCHANGE 1
808+
#endif
809+
806810
#if ENABLED(MIXING_EXTRUDER) && (ENABLED(RETRACT_SYNC_MIXING) || ALL(FILAMENT_LOAD_UNLOAD_GCODES, FILAMENT_UNLOAD_ALL_EXTRUDERS))
807811
#define HAS_MIXER_SYNC_CHANNEL 1
808812
#endif

Marlin/src/module/tool_change.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#include "../inc/MarlinConfigPre.h"
2424

25+
#if HAS_TOOLCHANGE
26+
2527
#include "tool_change.h"
2628

2729
#include "motion.h"
@@ -1629,3 +1631,5 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
16291631
}
16301632

16311633
#endif // TOOLCHANGE_MIGRATION_FEATURE
1634+
1635+
#endif // HAS_TOOLCHANGE

ini/features.ini

+1
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ SERVO_DETACH_GCODE = build_src_filter=+<src/gcode/control/M2
306306
HAS_DUPLICATION_MODE = build_src_filter=+<src/gcode/control/M605.cpp>
307307
SPI_FLASH_BACKUP = build_src_filter=+<src/gcode/control/M993_M994.cpp>
308308
PLATFORM_M997_SUPPORT = build_src_filter=+<src/gcode/control/M997.cpp>
309+
HAS_TOOLCHANGE = build_src_filter=+<src/gcode/control/T.cpp>
309310
FT_MOTION = build_src_filter=+<src/module/ft_motion.cpp> +<src/gcode/feature/ft_motion>
310311
LIN_ADVANCE = build_src_filter=+<src/gcode/feature/advance>
311312
PHOTO_GCODE = build_src_filter=+<src/gcode/feature/camera>

platformio.ini

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ default_src_filter = +<src/*> -<src/config> -<src/tests>
107107
+<src/gcode/control/M111.cpp>
108108
+<src/gcode/control/M120_M121.cpp>
109109
+<src/gcode/control/M999.cpp>
110-
+<src/gcode/control/T.cpp>
111110
+<src/gcode/geometry/G92.cpp>
112111
+<src/gcode/host/M110.cpp>
113112
+<src/gcode/host/M114.cpp>

0 commit comments

Comments
 (0)