From faecd7d0d5910bd3629936cf9663214bcfefce73 Mon Sep 17 00:00:00 2001 From: DerAndere <26200979+DerAndere1@users.noreply.github.com> Date: Tue, 21 Jan 2025 21:44:22 +0100 Subject: [PATCH] improve TOOLS, allow HOTENDS without EXTRUDERS --- Marlin/src/gcode/calibrate/G425.cpp | 2 +- Marlin/src/gcode/control/M605.cpp | 2 +- Marlin/src/gcode/feature/pause/M701_M702.cpp | 2 +- Marlin/src/inc/Conditionals-1-axes.h | 23 ++++++++++++++------ Marlin/src/module/motion.cpp | 2 +- Marlin/src/module/tool_change.cpp | 4 ++-- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 80a90681ce34..afd4e7e97893 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -824,7 +824,7 @@ inline void calibrate_all() { // Cycle the toolheads so the servos settle into their "natural" positions #if HAS_TOOLCHANGE for (int8_t t = 0; t < TOOLS; t++) - set_nozzle(m, e); + set_nozzle(m, t); #endif // Do a slow and precise calibration of the toolheads diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index 784e29512bc5..ef55ddf648b2 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -142,7 +142,7 @@ "\nDEFAULT_DUPLICATION_X_OFFSET=", DEFAULT_DUPLICATION_X_OFFSET ); - for (int8_t i = 0; i < TOOLS; i++) + for (int8_t e = 0; e < TOOLS; e++) { DEBUG_ECHOPGM_P(SP_T_STR, e); LOOP_NUM_AXES(a) DEBUG_ECHOPGM(" hotend_offset[", e, "].", C(AXIS_CHAR(a) | 0x20), "=", hotend_offset[e][a]); DEBUG_EOL(); diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index 8bf4756c2467..36229269c260 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -205,7 +205,7 @@ void GcodeSuite::M702() { #elif HAS_PRUSA_MMU2 mmu2.unload(); #else - #if ALL(HAS_MULTI_EXTRUDER, FILAMENT_UNLOAD_ALL_EXTRUDERS) || ALL(HAS_MULTI_TOOLS, FILAMENT_UNLOAD_ALL_EXTRUDERS) + #if ALL(HAS_MULTI_TOOLS, FILAMENT_UNLOAD_ALL_EXTRUDERS) if (!parser.seenval('T')) { HOTEND_LOOP() { if (e != active_extruder) tool_change(e); diff --git a/Marlin/src/inc/Conditionals-1-axes.h b/Marlin/src/inc/Conditionals-1-axes.h index d2de33c617a7..8ae191a200ba 100644 --- a/Marlin/src/inc/Conditionals-1-axes.h +++ b/Marlin/src/inc/Conditionals-1-axes.h @@ -53,6 +53,11 @@ #else #undef EXTRUDERS #define EXTRUDERS 0 + #undef SINGLENOZZLE + #undef SWITCHING_EXTRUDER + #undef MECHANICAL_SWITCHING_EXTRUDER + #undef SWITCHING_NOZZLE + #undef MECHANICAL_SWITCHING_NOZZLE #undef DISABLE_E #undef PREVENT_LENGTHY_EXTRUDE #undef FILAMENT_RUNOUT_SENSOR @@ -68,12 +73,8 @@ #undef TEMP_SENSOR_5 #undef TEMP_SENSOR_6 #undef TEMP_SENSOR_7 - #undef SINGLENOZZLE - #undef SWITCHING_EXTRUDER - #undef MECHANICAL_SWITCHING_EXTRUDER - #undef SWITCHING_NOZZLE - #undef MECHANICAL_SWITCHING_NOZZLE #undef HOTEND_IDLE_TIMEOUT + #undef HOTEND_OVERSHOOT #endif #endif @@ -223,8 +224,16 @@ * * TOOLS - Number of Selectable Tools */ -#if !defined(TOOLS) - #define TOOLS HOTENDS + +#ifndef TOOLS + #if (HOTENDS >= EXTRUDERS) + #define TOOLS HOTENDS + #else + #define TOOLS EXTRUDERS + #endif +#endif +#if TOOLS > 1 + #define HAS_MULTI_TOOLS 1 #else #if TOOLS > 0 #define HAS_TOOL_LENGTH_COMPENSATION 1 diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 90d49d3c63f0..ce8277be0890 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -132,7 +132,7 @@ xyze_pos_t destination; // {0} // Extruder offsets #if HAS_HOTEND_OFFSET - xyz_pos_t hotend_offset[TOOLS]; // Initialized by settings.load() + xyz_pos_t hotend_offset[TOOLS]; // Initialized by settings.load void reset_hotend_offsets() { constexpr float tmp[XYZ][TOOLS] = { HOTEND_OFFSET_X, HOTEND_OFFSET_Y, HOTEND_OFFSET_Z }; static_assert( diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index e64bf5e36677..14c431023a90 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -904,7 +904,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #endif // ELECTROMAGNETIC_SWITCHING_TOOLHEAD -#if HAS_EXTRUDERS || HAS_TOOL_LENGTH_COMPENSATION +#if HAS_MULTI_TOOLS inline void invalid_extruder_error(const uint8_t e) { SERIAL_ECHO_START(); SERIAL_CHAR('T'); SERIAL_ECHO(e); @@ -1239,7 +1239,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { return invalid_extruder_error(new_tool); #endif - if (new_tool >= TERN(HAS_TOOL_LENGTH_COMPENSATION, TOOLS, EXTRUDERS)) + if (new_tool >= TOOLS) return invalid_extruder_error(new_tool); if (!no_move && homing_needed()) {