From ff46d7cae274375eba82a278ca70fe0da016f778 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <github@thinkyhead.com>
Date: Fri, 31 Dec 2021 01:43:25 -0600
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20"no=20T=20param"=20handlin?=
 =?UTF-8?q?g?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Marlin/src/gcode/feature/L6470/M906.cpp         | 2 +-
 Marlin/src/gcode/feature/trinamic/M569.cpp      | 2 +-
 Marlin/src/gcode/feature/trinamic/M906.cpp      | 2 +-
 Marlin/src/gcode/feature/trinamic/M911-M914.cpp | 2 +-
 Marlin/src/gcode/gcode.cpp                      | 1 +
 5 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp
index 67d11493abf..ae4a46dce60 100644
--- a/Marlin/src/gcode/feature/L6470/M906.cpp
+++ b/Marlin/src/gcode/feature/L6470/M906.cpp
@@ -285,7 +285,7 @@ void GcodeSuite::M906() {
 
       #if E_STEPPERS
         case E_AXIS: {
-          const int8_t eindex = get_target_e_stepper_from_command();
+          const int8_t eindex = get_target_e_stepper_from_command(-2);
           #if AXIS_IS_L64XX(E0)
             if (eindex < 0 || eindex == 0) L6470_SET_KVAL_HOLD(E0);
           #endif
diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp
index 3f4b0c6372a..7bfedf8c721 100644
--- a/Marlin/src/gcode/feature/trinamic/M569.cpp
+++ b/Marlin/src/gcode/feature/trinamic/M569.cpp
@@ -134,7 +134,7 @@ static void say_stealth_status() {
  */
 void GcodeSuite::M569() {
   if (parser.seen('S'))
-    set_stealth_status(parser.value_bool(), get_target_e_stepper_from_command());
+    set_stealth_status(parser.value_bool(), get_target_e_stepper_from_command(-2));
   else
     say_stealth_status();
 }
diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp
index 300b8beb097..788389ed61b 100644
--- a/Marlin/src/gcode/feature/trinamic/M906.cpp
+++ b/Marlin/src/gcode/feature/trinamic/M906.cpp
@@ -112,7 +112,7 @@ void GcodeSuite::M906() {
 
       #if E_STEPPERS
         case E_AXIS: {
-          const int8_t eindex = get_target_e_stepper_from_command();
+          const int8_t eindex = get_target_e_stepper_from_command(-2);
           #if AXIS_IS_TMC(E0)
             if (eindex < 0 || eindex == 0) TMC_SET_CURRENT(E0);
           #endif
diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp
index 32a2d25e77d..37dd9479aba 100644
--- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp
+++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp
@@ -291,7 +291,7 @@
           break;
         #if E_STEPPERS
           case E_AXIS: {
-            const int8_t eindex = get_target_e_stepper_from_command();
+            const int8_t eindex = get_target_e_stepper_from_command(-2);
             TERN_(E0_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 0) TMC_SET_PWMTHRS_E(0));
             TERN_(E1_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 1) TMC_SET_PWMTHRS_E(1));
             TERN_(E2_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 2) TMC_SET_PWMTHRS_E(2));
diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp
index d3d8f335dfa..2f031b3b74f 100644
--- a/Marlin/src/gcode/gcode.cpp
+++ b/Marlin/src/gcode/gcode.cpp
@@ -148,6 +148,7 @@ int8_t GcodeSuite::get_target_extruder_from_command() {
 int8_t GcodeSuite::get_target_e_stepper_from_command(const int8_t dval/*=-1*/) {
   const int8_t e = parser.intval('T', dval);
   if (WITHIN(e, 0, E_STEPPERS - 1)) return e;
+  if (dval == -2) return dval;
 
   SERIAL_ECHO_START();
   SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum);