-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a67687
commit c3edbdf
Showing
2 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
############################################################################################################ | ||
# | ||
# Toolhead Selection | ||
# | ||
############################################################################################################# | ||
[gcode_macro _SELECT_TOOL] | ||
gcode: | ||
CALCULATE_PRINTABLE_AREA # NOTE: this will not be updated in here. | ||
{% if params.T is defined %} | ||
{% set idex_mode = '' %} | ||
{% if printer["dual_carriage"] is defined %} | ||
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %} | ||
{% if "xyz" not in printer.toolhead.homed_axes and (idex_mode == "copy" or idex_mode == "mirror") %} | ||
IDEX_SINGLE | ||
{% set idex_mode = 'reset' %} | ||
{% endif %} | ||
{% endif %} | ||
{% if idex_mode != "copy" and idex_mode != "mirror" %} | ||
{% set act_t = 1 if idex_mode == 'primary' else 0 %} | ||
{% set new_t = params.T|int %} | ||
{% set act_extruder = 'extruder%s' % ('' if new_t == 0 else new_t) %} | ||
{% if new_t != act_t or printer.toolhead.extruder != act_extruder or idex_mode == 'reset' %} | ||
|
||
M118 T{new_t} # echo | ||
M220 S100 # reset any speed override from the purge tower | ||
|
||
# parameters | ||
{% set printing = params.PRINTING|default(0)|int %} | ||
{% set z_hop = params.Z|default(0.0)|float %} | ||
{% set new_x = params.X|default(-1)|float %} | ||
{% set new_y = params.Y|default(-1)|float %} | ||
{% set swipe = params.SWIPE|default(1)|int %} | ||
{% if "xyz" not in printer.toolhead.homed_axes %} | ||
{% set swipe = 0 %} | ||
{% endif %} | ||
|
||
# swap part cooling fans | ||
{% set fan_speed = printer["fan_generic part_fan_t%s" % act_t].speed %} | ||
{% set sync_fans = printer["gcode_macro RatOS"].toolchange_sync_fans|default(0)|int %} | ||
{% if fan_speed > 0 %} | ||
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed if (new_t == 0 or sync_fans == 1) else 0} | ||
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed if (new_t == 1 or sync_fans == 1) else 0} | ||
# Update core Klipper's fan speed to the fan speed of the active toolhead | ||
# Only do this if you have a sacrificial [fan] section | ||
M106.1 S{fan_speed} | ||
{% endif %} | ||
|
||
# change toolhead | ||
_TOOLCHANGE T={new_t} X={new_x} Y={new_y} PRINTING={printing} SWIPE={swipe} Z_HOP={z_hop} | ||
|
||
# set input shaper | ||
{% set shaper_x_freq = printer["gcode_macro RatOS"].shaper_x_freq %} | ||
{% set shaper_y_freq = printer["gcode_macro RatOS"].shaper_y_freq %} | ||
{% set shaper_x_type = printer["gcode_macro RatOS"].shaper_x_type %} | ||
{% set shaper_y_type = printer["gcode_macro RatOS"].shaper_y_type %} | ||
SET_INPUT_SHAPER SHAPER_FREQ_X={(shaper_x_freq[new_t]|float)} SHAPER_FREQ_Y={(shaper_y_freq[new_t]|float)} SHAPER_TYPE_X={(shaper_x_type[new_t]|lower)} SHAPER_TYPE_Y={(shaper_y_type[new_t]|lower)} | ||
|
||
# update global toolhead state | ||
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=active VALUE={True if new_t==0 else False} | ||
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=active VALUE={True if new_t==1 else False} | ||
|
||
G90 # absolute positioning | ||
|
||
{% endif %} | ||
{% endif %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters