Skip to content

Commit

Permalink
⚡️ Slimmer null T command (MarlinFirmware#26615)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
plampix and thinkyhead authored Jan 4, 2024
1 parent 6e67ad5 commit 994aa9f
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 15 deletions.
4 changes: 3 additions & 1 deletion Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions Marlin/src/gcode/bedlevel/G26.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 5 additions & 2 deletions Marlin/src/gcode/config/M217.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/gcode/control/T.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
*
*/

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

#if HAS_TOOLCHANGE

#include "../gcode.h"
#include "../../module/tool_change.h"

Expand Down Expand Up @@ -76,3 +80,5 @@ void GcodeSuite::T(const int8_t tool_index) {
#endif
);
}

#endif // HAS_TOOLCHANGE
18 changes: 10 additions & 8 deletions Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ class GcodeSuite {
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); });

};

Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/module/tool_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

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

#if HAS_TOOLCHANGE

#include "tool_change.h"

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

#endif // TOOLCHANGE_MIGRATION_FEATURE

#endif // HAS_TOOLCHANGE
1 change: 1 addition & 0 deletions ini/features.ini
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ SERVO_DETACH_GCODE = build_src_filter=+<src/gcode/control/M2
HAS_DUPLICATION_MODE = build_src_filter=+<src/gcode/control/M605.cpp>
SPI_FLASH_BACKUP = build_src_filter=+<src/gcode/control/M993_M994.cpp>
PLATFORM_M997_SUPPORT = build_src_filter=+<src/gcode/control/M997.cpp>
HAS_TOOLCHANGE = build_src_filter=+<src/gcode/control/T.cpp>
FT_MOTION = build_src_filter=+<src/module/ft_motion.cpp> +<src/gcode/feature/ft_motion>
LIN_ADVANCE = build_src_filter=+<src/gcode/feature/advance>
PHOTO_GCODE = build_src_filter=+<src/gcode/feature/camera>
Expand Down
1 change: 0 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ default_src_filter = +<src/*> -<src/config> -<src/tests>
+<src/gcode/control/M111.cpp>
+<src/gcode/control/M120_M121.cpp>
+<src/gcode/control/M999.cpp>
+<src/gcode/control/T.cpp>
+<src/gcode/geometry/G92.cpp>
+<src/gcode/host/M110.cpp>
+<src/gcode/host/M114.cpp>
Expand Down

0 comments on commit 994aa9f

Please sign in to comment.