Skip to content

Commit

Permalink
improve TOOLS, allow HOTENDS without EXTRUDERS
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndere1 committed Jan 21, 2025
1 parent dac7e08 commit faecd7d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/gcode/calibrate/G425.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/control/M605.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/feature/pause/M701_M702.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 16 additions & 7 deletions Marlin/src/inc/Conditionals-1-axes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/tool_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit faecd7d

Please sign in to comment.