From ee26fd0e0559d7f2d86b11b5552eaf9c9ff3174c Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Mon, 25 Oct 2021 22:29:40 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Default=20T0=20for=20M569,=20M90?= =?UTF-8?q?6,=20M913=20(#23020)?= 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 | 9 +++++---- Marlin/src/gcode/gcode.h | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp index 2ab13f5b5d..bab355fe38 100644 --- a/Marlin/src/gcode/feature/L6470/M906.cpp +++ b/Marlin/src/gcode/feature/L6470/M906.cpp @@ -280,7 +280,7 @@ void GcodeSuite::M906() { #if E_STEPPERS case E_AXIS: { - const int8_t target_e_stepper = get_target_e_stepper_from_command(); + const int8_t target_e_stepper = get_target_e_stepper_from_command(0); if (target_e_stepper < 0) return; switch (target_e_stepper) { #if AXIS_IS_L64XX(E0) diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index 5cadd2d45e..05730eabfd 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -133,7 +133,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(0)); else say_stealth_status(); } diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index 48db266c72..c3e12a4f92 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -104,7 +104,7 @@ void GcodeSuite::M906() { #if E_STEPPERS case E_AXIS: { - const int8_t target_e_stepper = get_target_e_stepper_from_command(); + const int8_t target_e_stepper = get_target_e_stepper_from_command(0); if (target_e_stepper < 0) return; switch (target_e_stepper) { #if AXIS_IS_TMC(E0) diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 58702c603f..f15343484a 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -268,7 +268,7 @@ break; #if E_STEPPERS case E_AXIS: { - const int8_t target_e_stepper = get_target_e_stepper_from_command(); + const int8_t target_e_stepper = get_target_e_stepper_from_command(0); if (target_e_stepper < 0) return; switch (target_e_stepper) { TERN_(E0_HAS_STEALTHCHOP, case 0: TMC_SET_PWMTHRS_E(0); break;) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 888dbe7027..126ceadb3b 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -137,11 +137,12 @@ int8_t GcodeSuite::get_target_extruder_from_command() { } /** - * Get the target e stepper from the T parameter - * Return -1 if the T parameter is out of range or unspecified + * Get the target E stepper from the 'T' parameter. + * If there is no 'T' parameter then dval will be substituted. + * Returns -1 if the resulting E stepper index is out of range. */ -int8_t GcodeSuite::get_target_e_stepper_from_command() { - const int8_t e = parser.intval('T', -1); +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; SERIAL_ECHO_START(); diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 4a3c865a4f..2173c5cab1 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -390,7 +390,7 @@ public: static void say_units(); static int8_t get_target_extruder_from_command(); - static int8_t get_target_e_stepper_from_command(); + static int8_t get_target_e_stepper_from_command(const int8_t dval=-1); static void get_destination_from_command(); static void process_parsed_command(const bool no_ok=false);