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
+
1
8
[gcode_macro END_PRINT]
2
9
description: Stop the print and filter the atmosphere for 10min before shuting down
3
10
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 %}
7
11
{% set light_intensity_end_print = printer[" gcode_macro _USER_VARIABLES" ].light_intensity_end_print %}
8
12
{% 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 %}
10
13
{% set filter_enabled = printer[" gcode_macro _USER_VARIABLES" ].filter_enabled %}
11
14
{% set light_enabled = printer[" gcode_macro _USER_VARIABLES" ].light_enabled %}
12
15
{% set neopixel_leds_enabled = printer[" gcode_macro _USER_VARIABLES" ].neopixel_leds_enabled %}
13
16
{% set bed_mesh_enabled = printer[" gcode_macro _USER_VARIABLES" ].bed_mesh_enabled %}
14
17
{% set filter_default_time = printer[" gcode_macro _USER_VARIABLES" ].filter_default_time_on_end_print|default(600)|int %}
15
18
{% set filament_sensor_enabled = printer[" gcode_macro _USER_VARIABLES" ].filament_sensor_enabled %}
19
+
20
+ PARK
21
+
16
22
{% set hotend_fan_tach_enabled = printer[" gcode_macro _USER_VARIABLES" ].hotend_fan_tach_enabled %}
17
23
18
24
PARK
@@ -54,10 +60,35 @@ gcode:
54
60
BED_MESH_CLEAR
55
61
{% endif %}
56
62
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 %}
61
92
62
93
# If a filter is connected, and used during the print, continue filtering the air
63
94
# for a couple of min before stopping everything
@@ -72,6 +103,7 @@ gcode:
72
103
{% if light_enabled %}
73
104
LIGHT_ON S ={light_intensity_end_print}
74
105
{% endif %}
106
+
75
107
{% if neopixel_leds_enabled %}
76
108
STATUS_LEDS COLOR =" DONE_PRINTING"
77
109
{% endif %}
@@ -86,6 +118,95 @@ gcode:
86
118
{% if filament_sensor_enabled %}
87
119
SET_FILAMENT_SENSOR SENSOR =" runout_sensor" ENABLE =1
88
120
{% endif %}
89
-
121
+
90
122
SET_PAUSE_NEXT_LAYER ENABLE =0
91
123
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 %}
0 commit comments