From 32d7f57fe52eb1ce0b8cb513226cb0c785c1e4c7 Mon Sep 17 00:00:00 2001 From: Anson Liu Date: Tue, 22 Aug 2023 20:21:41 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20G-code=20'T'=20report=20current=20t?= =?UTF-8?q?ool=20(#26151)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/gcode/control/T.cpp | 12 ++++++++++-- Marlin/src/gcode/parser.cpp | 8 +++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Marlin/src/gcode/control/T.cpp b/Marlin/src/gcode/control/T.cpp index 5e1579ec123a..c5ebbcf50e7f 100644 --- a/Marlin/src/gcode/control/T.cpp +++ b/Marlin/src/gcode/control/T.cpp @@ -41,13 +41,21 @@ * S1 Don't move the tool in XY after change * * For PRUSA_MMU2(S) and EXTENDABLE_EMU_MMU2(S) - * T[n] Gcode to extrude at least 38.10 mm at feedrate 19.02 mm/s must follow immediately to load to extruder wheels. - * T? Gcode to extrude shouldn't have to follow. Load to extruder wheels is done automatically. + * T[n] G-code to extrude at least 38.10 mm at feedrate 19.02 mm/s must follow immediately to load to extruder wheels. + * T? G-code to extrude shouldn't have to follow. Load to extruder wheels is done automatically. * Tx Same as T?, but nozzle doesn't have to be preheated. Tc requires a preheated nozzle to finish filament load. * Tc Load to nozzle after filament was prepared by Tc and nozzle is already heated. */ void GcodeSuite::T(const int8_t tool_index) { + #if HAS_MULTI_EXTRUDER + // For 'T' with no parameter report the current tool. + if (parser.string_arg && *parser.string_arg == '*') { + SERIAL_ECHOLNPGM(STR_ACTIVE_EXTRUDER, active_extruder); + return; + } + #endif + DEBUG_SECTION(log_T, "T", DEBUGGING(LEVELING)); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("...(", tool_index, ")"); diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index ccd6b4111f10..f2835f58918a 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -189,7 +189,13 @@ void GCodeParser::parse(char *p) { #endif // Bail if there's no command code number - if (!TERN(SIGNED_CODENUM, NUMERIC_SIGNED(*p), NUMERIC(*p))) return; + if (!TERN(SIGNED_CODENUM, NUMERIC_SIGNED(*p), NUMERIC(*p))) { + if (TERN0(HAS_MULTI_EXTRUDER, letter == 'T')) { + p[0] = '*'; p[1] = '\0'; string_arg = p; // Convert 'T' alone into 'T*' + command_letter = letter; + } + return; + } // Save the command letter at this point // A '?' signifies an unknown command