Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filament retract and unretract user variables for use in base and helper macros #642

Merged
merged 8 commits into from
Jan 8, 2025
5 changes: 3 additions & 2 deletions macros/base/cancel_print.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ gcode:
{% set filament_sensor_enabled = printer["gcode_macro _USER_VARIABLES"].filament_sensor_enabled %}
{% set filter_default_time = printer["gcode_macro _USER_VARIABLES"].filter_default_time_on_end_print|default(600)|int %}
{% set hotend_fan_tach_enabled = printer["gcode_macro _USER_VARIABLES"].hotend_fan_tach_enabled %}

{% set retract_length = printer["gcode_macro _USER_VARIABLES"].retract_length|default(20)|float %}

PARK

{% if klippain_mmu_enabled and mmu_unload_on_cancel_print %}
Expand All @@ -25,7 +26,7 @@ gcode:
{% elif printer.extruder.can_extrude %}
# Pull back the filament a little bit
G92 E0
G1 E-10 F2100
G1 E-{retract_length} F2100
{% endif %}

{% if turn_off_heaters_in_end_print %}
Expand Down
3 changes: 2 additions & 1 deletion macros/base/end_print.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gcode:
{% set filter_default_time = printer["gcode_macro _USER_VARIABLES"].filter_default_time_on_end_print|default(600)|int %}
{% set filament_sensor_enabled = printer["gcode_macro _USER_VARIABLES"].filament_sensor_enabled %}
{% set hotend_fan_tach_enabled = printer["gcode_macro _USER_VARIABLES"].hotend_fan_tach_enabled %}
{% set retract_length = printer["gcode_macro _USER_VARIABLES"].retract_length|default(20)|float %}

PARK

Expand All @@ -25,7 +26,7 @@ gcode:
{% elif printer.extruder.can_extrude %}
# pull back the filament a little bit
G92 E0
G1 E-10 F2100
G1 E-{retract_length} F2100
{% endif %}

{% if turn_off_heaters_in_end_print %}
Expand Down
5 changes: 3 additions & 2 deletions macros/helpers/nozzle_cleaning.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ gcode:
{% set OOZE_TIME = params.OOZE_TIME|default(printer["gcode_macro _USER_VARIABLES"].purge_ooze_time)|int %}
{% set TEMP = params.TEMP|default(printer["gcode_macro _USER_VARIABLES"].print_default_extruder_temp)|float %}
{% set Z_DROP = params.Z_DROP|default(1)|int %}
{% set RETRACT = params.RETRACT|default(printer["gcode_macro _USER_VARIABLES"].retract_length)|default(20)|float %}

{% set purge_and_brush_enabled = printer["gcode_macro _USER_VARIABLES"].purge_and_brush_enabled %}
{% set purgeclean_servo_enabled = printer["gcode_macro _USER_VARIABLES"].purgeclean_servo_enabled %}
Expand Down Expand Up @@ -119,8 +120,8 @@ gcode:

# Retract
G92 E0
G1 E-1.7 F2100
G1 E-18.3 F150
G1 E-{RETRACT*0.1} F2100
G1 E-({RETRACT}-{RETRACT*0.1}) F150
G92 E0

# Wait some time to let the nozzle ooze before cleaning
Expand Down
3 changes: 2 additions & 1 deletion macros/helpers/prime_line.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ gcode:
{% set prime_line_height = params.LINE_HEIGHT|default(printer["gcode_macro _USER_VARIABLES"].prime_line_height)|default(0.6)|float %}
{% set prime_line_adaptive = params.ADAPTIVE_MODE|default(1)|int %}
{% set prime_line_margin = params.LINE_MARGIN|default(printer["gcode_macro _USER_VARIABLES"].prime_line_margin)|default(5.0)|float %} # Used only in adaptive mode
{% set prime_line_unretract_length = printer["gcode_macro _USER_VARIABLES"].unretract_length|default(23)|float %}
{% set prime_line_wipe = printer["gcode_macro _USER_VARIABLES"].prime_line_wipe|default(False) %}
{% set prime_line_wipe_length = prime_line_length * 0.8 %}

Expand Down Expand Up @@ -112,7 +113,7 @@ gcode:

# Add pressure in the nozzle
G92 E0
G1 E18 F300
G1 E{prime_line_unretract_length} F300

# Prime line
G92 E0
Expand Down
7 changes: 7 additions & 0 deletions user_templates/variables.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ variable_prime_line_height: 0.6 # mm, used for actual cross section computation
variable_prime_line_margin: 5 # distance of purge line from fl_size rectangle
variable_prime_line_wipe: False # enable a wipe of the nozzle after completing the prime line

## Length of filament to retract to disengage it from the heatbreak.
## This is to reduce final print oozing, but also to prevent heatcreep, clogging, and allow cold filament change between prints.
## Unretract is the length of filament to prime and pressurize the nozzle prior to printing.
## This is recommended to be 10-20% more than the retract value.
variable_retract_length: 20
variable_unretract_length: 23

## Park position used when pause, end_print, etc...
variable_park_position_xy: -1, -1
variable_park_lift_z: 50
Expand Down