-
Notifications
You must be signed in to change notification settings - Fork 1
/
macros.cfg
315 lines (274 loc) · 11.8 KB
/
macros.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# This file provides examples of Klipper G-Code macros. The snippets
# in this file may be copied into the main printer.cfg file and
# customized.
[gcode_macro G29]
description: Warm Bed and Mesh
gcode:
G28
M190 S60 ; warm Bed to 60
bed_mesh_calibrate
G1 X0 Y0 Z10 F4200
#[gcode_arcs]
#resolution: 1.0
[gcode_macro G34]
description: Crash Gantry to Level
gcode:
MECHANICAL_GANTRY_CALIBRATION
[gcode_macro START_PRINT]
description: Start Print Macro
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(190)|float %}
SKEW_PROFILE LOAD=calilantern_skew_profile ; Load Skew
M140 S{BED_TEMP} ; Start Bed Heating
G90 ; Use absolute coordinates
G28 ; Home the printer
led_heating ; Warm Printer Led
M190 S{BED_TEMP} ; Wait for bed to reach temperature
led_mesh ; Bed mesh LED
BED_MESH_CALIBRATE ; Run KAMP
led_heating ; Extruder heating LED
M109 S{EXTRUDER_TEMP} ; Warm Extruder
led_printing ; Start Print LED
CLEAN_NOZZLE ; clean nozzle
LINE_PURGE ; purge nozzle
[gcode_macro END_PRINT]
description: End Print Macro
gcode:
M107
led_finish
G91 ;Relative positioning
G1 E-2 F2700 ;Retract a bit
G1 E-2 Z0.2 F2400 ;Retract and raise Z
G1 X5 Y5 F3000 ;Wipe out
G1 Z10 ;Raise Z more
G90 ;Absolute positioning
G1 X0 Y200 ;Present print
M106 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
M84 X Y E ;Disable all steppers but Z
SET_SKEW CLEAR=1
M109 S50 ;Wait for Nozzle to reach 50c
POWER_OFF_PRINTER ;Power off Prnter - Host remains on
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
##### get user parameters or use default #####
{% set macro_found = True if printer['gcode_macro _CLIENT_VARIABLE'] is defined else False %}
{% set client = printer['gcode_macro _CLIENT_VARIABLE'] %}
{% set allow_park = False if not macro_found
else False if client.park_at_cancel is not defined
else True if client.park_at_cancel|lower == 'true'
else False %}
{% set retract = 5.0 if not macro_found else client.cancel_retract|default(5.0)|abs %}
##### define park position #####
{% set park_x = "" if not macro_found
else "" if client.park_at_cancel_x is not defined
else "X=" + client.park_at_cancel_x|string if client.park_at_cancel_x is not none %}
{% set park_y = "" if not macro_found
else "" if client.park_at_cancel_y is not defined
else "Y=" + client.park_at_cancel_y|string if client.park_at_cancel_y is not none %}
{% set custom_park = True if (park_x|length > 0 or park_y|length > 0) else False %}
##### end of definitions #####
{% if (custom_park or not printer.pause_resume.is_paused) and allow_park %} _TOOLHEAD_PARK_PAUSE_CANCEL {park_x} {park_y} {% endif %}
_CLIENT_RETRACT LENGTH={retract}
TURN_OFF_HEATERS
M106 S0
# clear pause_next_layer and pause_at_layer as preparation for next print
SET_PAUSE_NEXT_LAYER ENABLE=0
SET_PAUSE_AT_LAYER ENABLE=0 LAYER=0
CANCEL_PRINT_BASE
led_fail
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
gcode:
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=last_extruder_temp VALUE="{printer[printer.toolhead.extruder].target}"
PAUSE_BASE
_TOOLHEAD_PARK_PAUSE_CANCEL {rawparams}
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
variable_last_extruder_temp: 0
gcode:
##### get user parameters or use default #####
{% set macro_found = True if printer['gcode_macro _CLIENT_VARIABLE'] is defined else False %}
{% set client = printer['gcode_macro _CLIENT_VARIABLE'] %}
{% set velocity = printer.configfile.settings.pause_resume.recover_velocity %}
{% set sp_move = velocity if not macro_found else client.speed_move|default(velocity) %}
##### end of definitions #####
M109 S{last_extruder_temp}
_CLIENT_EXTRUDE
RESUME_BASE VELOCITY={params.VELOCITY|default(sp_move)}
# Usage: SET_PAUSE_NEXT_LAYER [ENABLE=[0|1]] [MACRO=<name>]
[gcode_macro SET_PAUSE_NEXT_LAYER]
description: Enable a pause if the next layer is reached
gcode:
{% set pause_next_layer = printer['gcode_macro SET_PRINT_STATS_INFO'].pause_next_layer %}
{% set ENABLE = params.ENABLE | default(1) | int != 0 %}
{% set MACRO = params.MACRO | default(pause_next_layer.call, True) %}
SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_next_layer VALUE="{{ 'enable': ENABLE, 'call': MACRO }}"
# Usage: SET_PAUSE_AT_LAYER [ENABLE=[0|1]] [LAYER=<number>] [MACRO=<name>]
[gcode_macro SET_PAUSE_AT_LAYER]
description: Enable/disable a pause if a given layer number is reached
gcode:
{% set pause_at_layer = printer['gcode_macro SET_PRINT_STATS_INFO'].pause_at_layer %}
{% set ENABLE = params.ENABLE | int != 0 if params.ENABLE is defined
else params.LAYER is defined %}
{% set LAYER = params.LAYER | default(pause_at_layer.layer) | int %}
{% set MACRO = params.MACRO | default(pause_at_layer.call, True) %}
SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_at_layer VALUE="{{ 'enable': ENABLE, 'layer': LAYER, 'call': MACRO }}"
# Usage: SET_PRINT_STATS_INFO [TOTAL_LAYER=<total_layer_count>] [CURRENT_LAYER= <current_layer>]
[gcode_macro SET_PRINT_STATS_INFO]
rename_existing: SET_PRINT_STATS_INFO_BASE
description: Overwrite, to get pause_next_layer and pause_at_layer feature
variable_pause_next_layer: { 'enable': False, 'call': "PAUSE" }
variable_pause_at_layer : { 'enable': False, 'layer': 0, 'call': "PAUSE" }
gcode:
{% if pause_next_layer.enable %}
{action_respond_info("%s, forced by pause_next_layer" % pause_next_layer.call)}
{pause_next_layer.call} ; execute the given gcode to pause, should be either M600 or PAUSE
SET_PAUSE_NEXT_LAYER ENABLE=0
{% elif pause_at_layer.enable and params.CURRENT_LAYER is defined and params.CURRENT_LAYER|int == pause_at_layer.layer %}
{action_respond_info("%s, forced by pause_at_layer [%d]" % (pause_at_layer.call, pause_at_layer.layer))}
{pause_at_layer.call} ; execute the given gcode to pause, should be either M600 or PAUSE
SET_PAUSE_AT_LAYER ENABLE=0
{% endif %}
SET_PRINT_STATS_INFO_BASE {rawparams}
[gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL]
description: Helper: park toolhead used in PAUSE and CANCEL_PRINT
variable_extrude: 1.0
gcode:
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 25.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 25.0 %}
{% set z_park_delta = 2.0 %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - z_park_delta) %}
{% set z_safe = z_park_delta %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
M83
G1 E-{extrude} F2100
{% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %}
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000
{% if printer.gcode_move.absolute_coordinates|lower == 'false' %} G91 {% endif %}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[gcode_macro _CLIENT_RETRACT]
description: Retracts, if the extruder is hot enough
gcode:
{% set macro_found = True if printer['gcode_macro _CLIENT_VARIABLE'] is defined else False %}
{% set client = printer['gcode_macro _CLIENT_VARIABLE'] %}
{% set length = (params.LENGTH|float) if params.LENGTH is defined
else 1.0 if not macro_found
else client.retract|default(1.0) %}
{% set speed = params.SPEED if params.SPEED is defined
else 35 if not macro_found
else client.speed_retract|default(35) %}
_CLIENT_EXTRUDE LENGTH=-{length|float|abs} SPEED={speed|float|abs}
[gcode_macro _CLIENT_EXTRUDE]
description: Extrudes, if the extruder is hot enough
gcode:
{% set macro_found = True if printer['gcode_macro _CLIENT_VARIABLE'] is defined else False %}
{% set client = printer['gcode_macro _CLIENT_VARIABLE'] %}
{% set use_fw_retract = False if not macro_found
else False if client.use_fw_retract is not defined
else True if client.use_fw_retract|lower == 'true' and printer.firmware_retraction is defined
else False %}
{% set length = (params.LENGTH|float) if params.LENGTH is defined
else 1.0 if not macro_found
else client.unretract|default(1.0) %}
{% set speed = params.SPEED if params.SPEED is defined
else 35 if not macro_found
else client.speed_unretract|default(35) %}
{% set absolute_extrude = printer.gcode_move.absolute_extrude %}
{% if printer.extruder.can_extrude %}
{% if use_fw_retract %}
{% if length < 0 %}
G10
{% else %}
G11
{% endif %}
{% else %}
M83
G1 E{length} F{(speed|float|abs) * 60}
{% if absolute_extrude %}
M82
{% endif %}
{% endif %}
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
[gcode_macro start_probe]
variable_bed_temp: 0
gcode:
# Save target temperature to bed_temp variable
SET_GCODE_VARIABLE MACRO=start_probe VARIABLE=bed_temp VALUE={printer.heater_bed.target}
# Disable bed heater
M140
# Perform probe
PROBE
# Call finish_probe macro at completion of probe
finish_probe
[gcode_macro finish_probe]
gcode:
# Restore temperature
M140 S{printer["gcode_macro start_probe"].bed_temp}
[gcode_macro LOAD_FILAMENT]
description: Load 120mm of Filament
gcode:
M83 # Put the extruder into relative mode
G92 E0.0 # Reset the extruder so that it thinks it is at position zero
G1 E120 F350 # Move the extruder forward 120mm at a speed of 350mm/minute
G92 E0.0 # Reset the extruder again
M82 # Put the extruder back into absolute mode.
[gcode_macro UNLOAD_FILAMENT]
description: Unload 120mm of Filament
gcode:
M83 # Put the extruder into relative mode
G92 E0.0 # Reset the extruder so that it thinks it is at position zero
G1 E-120 F350 # Move the extruder forward 120mm at a speed of 350mm/minute
G92 E0.0 # Reset the extruder again
M82 # Put the extruder back into absolute mode.
[gcode_macro bed_screw_level]
description: Manual Level Bed Corners
gcode:
G28 ; Home All Axis
SCREWS_TILT_CALCULATE ; Level Corners
[gcode_macro MECHANICAL_GANTRY_CALIBRATION]
description: Crash Gantry to Level X-Axis (G34)
gcode:
{% set x_max = printer.toolhead.axis_maximum.x %}
{% set y_max = printer.toolhead.axis_maximum.y %}
{% set z_max = printer.toolhead.axis_maximum.z %}
{% set fast_move_z = printer.configfile.settings["printer"].max_z_velocity %}
{% set fast_move = printer.configfile.settings["printer"].max_velocity %}
G28 ; Home All Axis
G90 ; Absolute Position
G0 X{x_max / 2} Y{y_max / 2} F{fast_move * 30 } ; center print head
G0 Z{z_max -1} F{fast_move_z * 60 } ; go to the Z-max at speed max z speed
SET_KINEMATIC_POSITION Z={z_max - 15} ; Trick printer into beleiving the X-gantry is 10mm lower
G1 Z{z_max} F{6 * 15} ; try to move 10mm up slowly
G4 P200 ; Wait
G1 Z{z_max -6} F{6 * 60} ; move 4mm down
G4 P200 ; same as the first one
G1 Z{z_max -30} F{6 * 60} ; move to 30mm below z-max to allow homing movement
G4 P200 ; same as the first one
G28 ; we MUST home again.