Skip to content

Commit 4d83f0f

Browse files
committed
Merge branch 'develop' into Benoit_tests
2 parents 384af24 + dc01ae0 commit 4d83f0f

File tree

5 files changed

+181
-16
lines changed

5 files changed

+181
-16
lines changed

macros/base/end_print.cfg

+130-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1+
## The END_PRINT sequence is modular and fully customizable. A default END_PRINT sequence is auto-populated.
2+
## Available actions: "retract_filament", "turn_off_heaters", "turn_off_fans", "turn_off_motors"
3+
##
4+
[gcode_macro _USER_VARIABLES]
5+
variable_endprint_actions: "retract_filament", "turn_off_heaters", "turn_off_fans", "turn_off_motors", "reset_limits"
6+
gcode: # do not remove this line
7+
18
[gcode_macro END_PRINT]
29
description: Stop the print and filter the atmosphere for 10min before shuting down
310
gcode:
4-
{% set disable_motors_in_end_print = printer["gcode_macro _USER_VARIABLES"].disable_motors_in_end_print %}
5-
{% set turn_off_heaters_in_end_print = printer["gcode_macro _USER_VARIABLES"].turn_off_heaters_in_end_print %}
6-
{% set safe_extruder_temp = printer["gcode_macro _USER_VARIABLES"].safe_extruder_temp|float %}
711
{% set light_intensity_end_print = printer["gcode_macro _USER_VARIABLES"].light_intensity_end_print %}
812
{% set klippain_mmu_enabled = printer["gcode_macro _USER_VARIABLES"].klippain_mmu_enabled %}
9-
{% set mmu_unload = params.MMU_UNLOAD_AT_END|default(printer["gcode_macro _USER_VARIABLES"].mmu_unload_on_end_print)|default(0)|int %}
1013
{% set filter_enabled = printer["gcode_macro _USER_VARIABLES"].filter_enabled %}
1114
{% set light_enabled = printer["gcode_macro _USER_VARIABLES"].light_enabled %}
1215
{% set neopixel_leds_enabled = printer["gcode_macro _USER_VARIABLES"].neopixel_leds_enabled %}
1316
{% set bed_mesh_enabled = printer["gcode_macro _USER_VARIABLES"].bed_mesh_enabled %}
1417
{% set filter_default_time = printer["gcode_macro _USER_VARIABLES"].filter_default_time_on_end_print|default(600)|int %}
1518
{% set filament_sensor_enabled = printer["gcode_macro _USER_VARIABLES"].filament_sensor_enabled %}
19+
20+
PARK
21+
1622
{% set hotend_fan_tach_enabled = printer["gcode_macro _USER_VARIABLES"].hotend_fan_tach_enabled %}
1723

1824
PARK
@@ -54,10 +60,35 @@ gcode:
5460
BED_MESH_CLEAR
5561
{% endif %}
5662

57-
{% if disable_motors_in_end_print %}
58-
M84
59-
{% endif %}
60-
63+
# Here is the core of the END_PRINT were we get the endprint_actions variable
64+
# to do the procedure in the correct order or a custom user override.
65+
#
66+
# Custom actions can be called by defining a gcode macro as in the following example
67+
# and adding `custom1` to the endprint_actions override config.
68+
# [gcode_macro _END_PRINT_ACTION_CUSTOM1]
69+
# gcode:
70+
# ## Your custom code here
71+
#
72+
{% set ep_actions = printer["gcode_macro _USER_VARIABLES"].endprint_actions %}
73+
{% for action in ep_actions %}
74+
{% if action == "retract_filament" %}
75+
_MODULE_RETRACT_FILAMENT
76+
{% elif action == "turn_off_heaters" %}
77+
_MODULE_TURN_OFF_HEATERS
78+
{% elif action == "turn_off_fans" %}
79+
_MODULE_TURN_OFF_FANS
80+
{% elif action == "turn_off_motors" %}
81+
_MODULE_TURN_OFF_MOTORS
82+
{% elif action == "reset_limits" %}
83+
_MODULE_RESET_LIMITS
84+
{% else %}
85+
{% if "_END_PRINT_ACTION_%s" % (action|upper) in printer.gcode.commands %}
86+
_END_PRINT_ACTION_{action|upper} {rawparams}
87+
{% else %}
88+
{ action_raise_error("Unknown module %s called in END_PRINT! Please verify your endprint_actions variable override!" % (action)) }
89+
{% endif %}
90+
{% endif %}
91+
{% endfor %}
6192

6293
# If a filter is connected, and used during the print, continue filtering the air
6394
# for a couple of min before stopping everything
@@ -72,6 +103,7 @@ gcode:
72103
{% if light_enabled %}
73104
LIGHT_ON S={light_intensity_end_print}
74105
{% endif %}
106+
75107
{% if neopixel_leds_enabled %}
76108
STATUS_LEDS COLOR="DONE_PRINTING"
77109
{% endif %}
@@ -86,6 +118,95 @@ gcode:
86118
{% if filament_sensor_enabled %}
87119
SET_FILAMENT_SENSOR SENSOR="runout_sensor" ENABLE=1
88120
{% endif %}
89-
121+
90122
SET_PAUSE_NEXT_LAYER ENABLE=0
91123
SET_PAUSE_AT_LAYER ENABLE=0 LAYER=0
124+
125+
126+
[gcode_macro _MODULE_RETRACT_FILAMENT]
127+
gcode:
128+
# ----- RETRACT FILAMENT -------------------------------------
129+
# Retract filament for easier swaps at the end of a print job
130+
{% set klippain_mmu_enabled = printer["gcode_macro _USER_VARIABLES"].klippain_mmu_enabled %}
131+
{% set mmu_unload = params.MMU_UNLOAD_AT_END|default(printer["gcode_macro _USER_VARIABLES"].mmu_unload_on_end_print)|default(0)|int %}
132+
133+
{% if klippain_mmu_enabled %}
134+
{% if printer.mmu.enabled and mmu_unload %}
135+
# unload filament and park into MMU. Or just unload filament out of extruder if using bypass.
136+
MMU_UNLOAD
137+
{% endif %}
138+
{% elif printer.extruder.can_extrude %}
139+
# pull back the filament a little bit
140+
G92 E0
141+
G1 E-10 F2100
142+
{% endif %}
143+
144+
[gcode_macro _MODULE_TURN_OFF_HEATERS]
145+
gcode:
146+
# ----- TURN OFF HEATERS -------------------------------------
147+
# Turn off all heaters at the end of a print job
148+
{% set turn_off_heaters_in_end_print = printer["gcode_macro _USER_VARIABLES"].turn_off_heaters_in_end_print %}
149+
{% set safe_extruder_temp = printer["gcode_macro _USER_VARIABLES"].safe_extruder_temp|float %}
150+
151+
{% if turn_off_heaters_in_end_print %}
152+
TURN_OFF_HEATERS
153+
{% else %}
154+
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={safe_extruder_temp}
155+
{% endif %}
156+
157+
158+
[gcode_macro _MODULE_TURN_OFF_FANS]
159+
gcode:
160+
# ----- TURN OFF FANS -------------------------------------
161+
# Turn off fans and fan monitoring at the end of a print job
162+
{% set hotend_fan_tach_enabled = printer["gcode_macro _USER_VARIABLES"].hotend_fan_tach_enabled %}
163+
164+
{% if hotend_fan_tach_enabled %}
165+
UPDATE_DELAYED_GCODE ID=_BACKGROUND_HOTEND_TACHO_CHECK DURATION=0
166+
{% endif %}
167+
168+
M107
169+
170+
171+
[gcode_macro _MODULE_TURN_OFF_MOTORS]
172+
gcode:
173+
# ----- TURN OFF MOTORS -------------------------------------
174+
# Disable the motors at the end of a print job
175+
{% set disable_motors_in_end_print = printer["gcode_macro _USER_VARIABLES"].disable_motors_in_end_print %}
176+
177+
{% if disable_motors_in_end_print %}
178+
M84
179+
{% endif %}
180+
181+
182+
[gcode_macro _MODULE_RESET_LIMITS]
183+
gcode:
184+
# ----- RESET LIMITS ---------------------------------
185+
# Reset velocity limits, extrusion and speed factor (if configured)
186+
{% set reset_velocity_limits = printer["gcode_macro _USER_VARIABLES"].reset_velocity_limits_in_end_print %}
187+
{% set reset_extrude_factor = printer["gcode_macro _USER_VARIABLES"].reset_extrude_factor_in_end_print %}
188+
{% set reset_speed_factor = printer["gcode_macro _USER_VARIABLES"].reset_speed_factor_in_end_print %}
189+
190+
{% if reset_speed_factor %}
191+
M220 S100
192+
{% endif %}
193+
194+
{% if reset_extrude_factor %}
195+
M221 S100
196+
{% endif %}
197+
198+
{% if reset_velocity_limits %}
199+
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity}
200+
SET_VELOCITY_LIMIT ACCEL={printer.configfile.settings.printer.max_accel}
201+
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={printer.configfile.settings.printer.square_corner_velocity}
202+
203+
# Legacy Klipper versions
204+
{% if printer.configfile.settings.printer.max_accel_to_decel is defined %}
205+
SET_VELOCITY_LIMIT ACCEL_TO_DECEL={printer.configfile.settings.printer.max_accel_to_decel}
206+
{% endif %}
207+
208+
# Modern Klipper versions
209+
{% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %}
210+
SET_VELOCITY_LIMIT MINIMUM_CRUISE_RATIO={printer.configfile.settings.printer.minimum_cruise_ratio}
211+
{% endif %}
212+
{% endif %}

macros/base/pause_resume.cfg

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ gcode:
3737
[gcode_macro RESUME]
3838
rename_existing: BASE_RESUME
3939
description: Resume the print after an optional unretract
40+
variable_extruder_target_temp: 0
4041
gcode:
4142
{% set St = printer["gcode_macro _USER_VARIABLES"].travel_speed %}
4243
{% set light_enabled = printer["gcode_macro _USER_VARIABLES"].light_enabled %}
4344
{% set light_intensity_printing = printer["gcode_macro _USER_VARIABLES"].light_intensity_printing %}
4445
{% set klippain_mmu_enabled = printer["gcode_macro _USER_VARIABLES"].klippain_mmu_enabled %}
4546
{% set idle_timeout_on_pause = printer["gcode_macro _USER_VARIABLES"].idle_timeout_on_pause|default(0)|int %}
47+
{% set turn_off_extruder = printer["gcode_macro _USER_VARIABLES"].turn_off_extruder_on_pause %}
4648

4749
{% if not printer.pause_resume.is_paused %}
4850
RESPOND MSG="Print is not paused. Resume ignored"
@@ -66,8 +68,8 @@ gcode:
6668
LIGHT_ON S={light_intensity_printing}
6769
{% endif %}
6870

69-
{% if idle_timeout_on_pause > 0%}
70-
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout}
71+
{% if turn_off_extruder and extruder_target_temp > 0 %}
72+
M109 S{extruder_target_temp|int}
7173
{% endif %}
7274

7375
BASE_RESUME

macros/base/start_print.cfg

+13-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,14 @@ gcode:
150150

151151
# Here is the core of the START_PRINT were we get the startprint_actions variable
152152
# to do the procedure in the correct order for the configured probe (or user custom override)
153-
{% set sp_actions = printer["gcode_macro _USER_VARIABLES"].startprint_actions_array %}
153+
#
154+
# Custom actions can be called by defining a gcode macro as in the following example and
155+
# adding `custom1` to the startprint_actions override config.
156+
# [gcode_macro _START_PRINT_ACTION_CUSTOM1]
157+
# gcode:
158+
# ## Your custom code here
159+
#
160+
{% set sp_actions = printer["gcode_macro _USER_VARIABLES"].startprint_actions %}
154161
{% for action in sp_actions %}
155162
{% if action.module %}
156163
_MODULE_{action.module}
@@ -162,7 +169,11 @@ gcode:
162169
{action.command} {action.parameters|default('')}
163170
{% endif %}
164171
{% else %}
165-
{ action_raise_error("Unknown module called in START_PRINT! Please verify your startprint_actions variable override!") }
172+
{% if "_START_PRINT_ACTION_%s" % (action|upper) in printer.gcode.commands %}
173+
_START_PRINT_ACTION_{action|upper} {rawparams}
174+
{% else %}
175+
{ action_raise_error("Unknown module %s called in START_PRINT! Please verify your startprint_actions variable override!" % (action)) }
176+
{% endif %}
166177
{% endif %}
167178
{% endfor %}
168179

user_templates/overrides.cfg

+23-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@
1919
# ------------------------------------------------------------------------------------------
2020

2121

22+
#-------------------------#
23+
# START_PRINT SEQUENCE #
24+
#-------------------------#
25+
26+
## The START_PRINT sequence is modular and fully customizable. A default START_PRINT sequence is auto-populated based on
27+
## your probe choice (TAP, Dockable, Inductive), but if for some reasons you still want to modify it, please uncomment the following 3
28+
## lines to define a new `variable_startprint_actions`. You can use any number of action or even duplicate some actions if needed.
29+
## Available actions: "bed_soak", "extruder_preheating", "chamber_soak", "extruder_heating", "tilt_calib", "z_offset", "bedmesh", "purge", "clean", "primeline"
30+
##
31+
# [gcode_macro _USER_VARIABLES]
32+
# variable_startprint_actions: "action1", "action2", ...
33+
# gcode: # do not remove this line
34+
35+
## The END_PRINT sequence is modular and fully customizable. A default END_PRINT sequence is auto-populated, but if for
36+
## some reasons you still want to modify it, please uncomment the following 3 lines to define a new `variable_endprint_actions`.
37+
## You can use any number of action or even duplicate some actions if needed.
38+
## Available actions: "retract_filament", "turn_off_heaters", "turn_off_fans", "turn_off_motors"
39+
##
40+
# [gcode_macro _USER_VARIABLES]
41+
# variable_endprint_actions: "action1", "action2", ...
42+
# gcode: # do not remove this line
43+
2244
#-------------------------#
2345
# EXTRUDER/BED PIDs #
2446
#-------------------------#
@@ -60,4 +82,4 @@
6082
# [probe]
6183
# x_offset: -1.85
6284
# y_offset: 29.3
63-
# z_offset: 12.6
85+
# z_offset: 12.6

user_templates/variables.cfg

+11-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,17 @@ variable_disable_motors_in_end_print: False
9797
## Automatically turn-off heaters in the END_PRINT macro
9898
variable_turn_off_heaters_in_end_print: True
9999

100-
## Set idle timeout duration when a print job is paused. 0 means no change
101-
variable_idle_timeout_on_pause: 0
100+
## Automatically turn-off the extruder/hotend when a print job is paused
101+
variable_turn_off_extruder_on_pause: False
102+
103+
## Automatically reset velocity limits to configured values in the END_PRINT macro
104+
variable_reset_velocity_limits_in_end_print: True
105+
106+
## Automatically reset extrude factor to 100% in the END_PRINT macro
107+
variable_reset_extrude_factor_in_end_print: True
108+
109+
## Automatically reset speed factor to 100% in the END_PRINT macro
110+
variable_reset_speed_factor_in_end_print: True
102111

103112

104113
#########################################################

0 commit comments

Comments
 (0)