Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 84 additions & 3 deletions macros/indx-tc-macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ variable_accel_mult: 0.7
variable_speed_mult: 0.7
variable_toolhead_state: 0 # 0=Locked, 2=Open
variable_rotation_dist_overridden: 0
variable_exit_pickup: False
variable_valid_restore: True
variable_restore_x: 50

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no setter exists for either of restore_x or restore_y

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed from original file, genuine mistake that has now been added. Thanks

variable_restore_y: 50
gcode:

[delayed_gcode INIT_STATE]
Expand Down Expand Up @@ -213,14 +217,84 @@ gcode: _SET_MODE M=sport A=1.0 S=1.0 C=1
[gcode_macro _TC_G0]
gcode:
{% set v = printer["gcode_macro _TOOLCHANGE_VARS"] %}
{% set tp = printer["gcode_macro TOOL_POSITIONS"] %}
{% set final_f = (printer.configfile.settings.printer.max_velocity * 60 * v.speed_mult) %}
G0 {% if 'X' in params %}X{params.X} {% endif %}{% if 'Y' in params %}Y{params.Y} {% endif %}{% if 'Z' in params %}Z{params.Z} {% endif %}F{params.F|default(final_f)|int}

{% if (not tp.park_on_ooze_pad and not tp.restore_pos) or not v.exit_pickup %}
G0 {% if 'X' in params %}X{params.X} {% endif %}{% if 'Y' in params %}Y{params.Y} {% endif %}{% if 'Z' in params %}Z{params.Z} {% endif %}F{params.F|default(final_f)|int}

{% else %}
G0 {% if 'X' in params %}X{params.X} {% endif %}{% if 'Y' in params %}Y{params.Y} {% endif %} F{params.F|default(final_f)|int}
M400

{% if 'Z' in params %}
{% if v.exit_pickup %}
{% if printer.print_stats.state in ["printing", "paused"] %}
# On exit_pickup when printing the toolhead moves to an ooze pad or filament scraper loaction to heat the tool.
{% if tp.park_on_ooze_pad %}
G0 X{tp.pad_x|float}
M400
G0 Y{tp.pad_y|float} F{params.F|default(final_f)|int}

# On exit_pickup when printing the toolhead moves back to exact loaction where the tool change was issued.
# When used with "Tool change on wipe tower" this makes sure the nozzle waits & heats on the tower to catch any oozing as there are no guards yet.
{% elif tp.restore_pos %}
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE_VARS VARIABLE=valid_restore VALUE=True
_TC_XY_RESTORE_CHECK
M400
_TC_XYZ_RESTORE Z={params.Z}
{% endif %}

SET_GCODE_VARIABLE MACRO=_TOOLCHANGE_VARS VARIABLE=exit_pickup VALUE=False

{% else %}
G0 Z{params.Z} F{params.F|default(final_f)|int}
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE_VARS VARIABLE=exit_pickup VALUE=False
{% endif %}
{% endif %}
{% endif %}
{% endif %}

[gcode_macro _TC_XY_RESTORE_CHECK]
gcode:
{% set tp = printer["gcode_macro TOOL_POSITIONS"] %}
{% set v = printer["gcode_macro _TOOLCHANGE_VARS"] %}
{% set act = printer.save_variables.variables.active_tool|default(-1)|int %}

{% for i in range(tp.tools|length) %}
{% set p_x = "t" ~ i ~ "_x"|string %}
{% set p_y = tp.clearance_y|float %}

{% if tp.dock_dir == -1 %}
{% if (v.restore_x == tp[p_x] and v.restore_y|float == p_y) or (i == act and v.restore_y|float < p_y) %}
RESPOND TYPE=COMMAND MSG="Restore coordinates create a non-valid exit point. Skipping restore...."
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE_VARS VARIABLE=valid_restore VALUE=False
{% endif %}

{% else %}
{% if (v.restore_x == tp[p_x] and v.restore_y|float == p_y) or (i == act and v.restore_y|float > p_y) %}
RESPOND TYPE=COMMAND MSG="Restore coordinates create a non-valid exit point. Skipping restore...."
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE_VARS VARIABLE=valid_restore VALUE=False
{% endif %}
{% endif %}
{% endfor %}

[gcode_macro _TC_XYZ_RESTORE]
gcode:
{% set v = printer["gcode_macro _TOOLCHANGE_VARS"] %}
{% set final_f = (printer.configfile.settings.printer.max_velocity * 60 * v.speed_mult) %}

{% if v.valid_restore %}
G0 X{v.restore_x|float} Y{v.restore_y|float} F{params.F|default(final_f)|int}
M400
G0 Z{params.Z|float} F{params.F|default(final_f)|int}
{% endif %}

[gcode_macro _LINEAR_EXIT]
gcode:
{% set tp = printer["gcode_macro TOOL_POSITIONS"] %}
{% set c = printer["gcode_macro _INDX_CONSTANTS"] %}
{% set restore_z = params.RESTORE_Z|default("")|string %}
{% set restore_z = params.RESTORE_Z|default(0)|float %}

{% set clearance_y = tp.clearance_y %}

Expand All @@ -236,7 +310,8 @@ gcode:
# nozzle across the part.
G90
_TC_G0 Y={"%.3f"|format(clearance_y)}
{% if restore_z != "" %}
{% if restore_z > 0 %}
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE_VARS VARIABLE=exit_pickup VALUE=True
M400
_TC_G0 Z={restore_z}
{% endif %}
Expand Down Expand Up @@ -350,6 +425,7 @@ gcode:
# drags the nozzle across the print at both ends of the change.
{% set zhop = tp.z_hop|float %}
{% set restore_z = "%.3f"|format(printer.gcode_move.gcode_position.z) %}
_RESTORE_GRABBER

# 6. Physical tool swap
{% if act != -1 %}
Expand Down Expand Up @@ -510,6 +586,11 @@ gcode:
# 6. HELPER MACROS
#####################################################################

[gcode_macro _RESTORE_GRABBER]
gcode:
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE_VARS VARIABLE=restore_x VALUE={"%.3f"|format(printer.gcode_move.gcode_position.x)}
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE_VARS VARIABLE=restore_y VALUE={"%.3f"|format(printer.gcode_move.gcode_position.y)}

[gcode_macro _RECORD_TOOLCHANGE]
description: Inner — saves active_tool and increments the toolchange counter after every successful pickup
gcode:
Expand Down
21 changes: 21 additions & 0 deletions macros/indx.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,27 @@ variable_t2_dock_y: -26
variable_t3_x: 102.0
variable_t3_dock_y: -26

# ── Tool change behaviour when printing ───────────────────────────────────────
# park_on_ooze_pad = if you have an ooze pad or filament scraper on your X/Y axes
# The nozzle will go to this location after a tool change to heat up.

# pad_x = Location on X axis.
# pad_Y = Location on Y axis.

# restore_pos = goes to the last location before the tool change to heat up
# best used with your slicer's "Tool Change on Wipe Tower" setting.

# NOTE: park_on_ooze_pad overrides the restore_pos setting! Also if both are set False
# the standard Bondtech tool change process is carried out.

# NOTE: Don't set pad_x or pad_y where they'll hit the edge of the printer's travel
# on either axis as you could end up with layer shifts &/or possible machine damage.

variable_park_on_ooze_pad: False
variable_pad_x: 10.00
variable_pad_y: 26.00
variable_restore_pos: True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't agree with claim that these features are off by default

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claim is not all features are off by default, but reverts to default exit behaviour when they are turned off.


# ── Assembled at startup from the variables above — do not edit ──────────────
variable_tools: []

Expand Down