-
Notifications
You must be signed in to change notification settings - Fork 0
/
Macro.cfg
449 lines (383 loc) · 17.8 KB
/
Macro.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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
#####################################################################
# Macros
#####################################################################
[gcode_macro _WAIT]
gcode:
{% set TIME = params.TIME|default(0)|int %}
G4 P{TIME*1000}
[gcode_macro G32]
gcode:
SAVE_GCODE_STATE NAME=STATE_G32
G90
G28
QUAD_GANTRY_LEVEL
G28
## Uncomment for for your size printer:
#--------------------------------------------------------------------
## Uncomment for 250mm build
#G0 X125 Y125 Z30 F3600
## Uncomment for 300 build
G0 X150 Y150 Z30 F3600
## Uncomment for 350mm build
#G0 X175 Y175 Z30 F3600
#--------------------------------------------------------------------
RESTORE_GCODE_STATE NAME=STATE_G32
#Genereted with https://config.gab-3d.com/
#
# https://config.gab-3d.com/share/cd1e8fe9-0192-4d4e-ad94-631be241e6e0
[gcode_macro PRINT_END]
gcode:
SET_FAN_SPEED FAN=exhaust_fan SPEED=1
M400 ;Clear buffer
G90 ;Set to absolute positioning
_MOVE_AWAY ;Move away from print
PARK_CENTER_REAR
G92 E0 ;Reset extruder
G1 E-2 F1800 ;Retract filament
CLEAN_NOZZLE
#M109 S200
#G1 E-1 F1800 ;Retract filament
TURN_OFF_HEATERS ;Turn off heaters
#G92 E0
_WAIT TIME=20
G1 E-1 F1800
CLEAN_NOZZLE
#TURN_OFF_HEATERS ;Turn off heaters
#_WAIT TIME=10
PARK_CENTER_REAR ;Park central rear
M84 ;Disable motors
_WAIT TIME=300
SET_FAN_SPEED FAN=exhaust_fan SPEED=0
[gcode_macro PRINT_START]
gcode:
{% set BED = params.BED_TEMP|int %}
{% set EXTRUDER = params.EXTRUDER_TEMP|int %}
{% set MATERIAL = params.MATERIAL|string %}
SET_MATERIAL MATERIAL={MATERIAL}
_CHOME ;Home all axes fi not already homed
# Heating nozzle to 150 degrees. This helps with getting a correct Z-home
SET_DISPLAY_TEXT MSG="Hotend: 150c" # Displays info
M109 S150 # Heats the nozzle to 150c
CLEAN_NOZZLE
#PARK_CENTER_REAR
#M109 S230
#G1 E-30 F1800
#CLEAN_NOZZLE
#M109 S200
#CLEAN_NOZZLE
_CQGL ;Quad Gantry Level if not already done
G0 Z30 ;Move Up
PARK_CENTER_REAR ;Park central rear
M190 S{BED} ;Set bed temperature and wait
_WAIT TIME=180 ;Wait x seconds
BED_MESH_CLEAR ;Clear Bed Mesh
BED_MESH_CALIBRATE ;Adaptive Mesh [Auto]
G28 Z ;Home Z axis
M109 S{EXTRUDER} ;Set extruder temperature and wait
G1 E-1 F1800
_WAIT TIME=5
CLEAN_NOZZLE
#G1 E-1 F1800
_ADAPTIVE_PURGE ;Adaptive Purge
##############################
######### NEVERMORE ##########
##############################
#[gcode_macro Nevermore_on]
#gcode:
# SET_FAN_SPEED FAN=nevermore_fan SPEED=1
#[gcode_macro Nevermore_off]
#gcode:
# SET_FAN_SPEED FAN=nevermore_fan SPEED=0
[gcode_macro _MOVE_AWAY]
gcode:
{% set th = printer.toolhead %}
{% set x_safe = th.position.x + 20 * (1 if th.axis_maximum.x - th.position.x > 20 else -1) %}
{% set y_safe = th.position.y + 20 * (1 if th.axis_maximum.y - th.position.y > 20 else -1) %}
{% set z_safe = [th.position.z + 30, th.axis_maximum.z]|min %}
G90 ; absolute positioning
G0 X{x_safe} Y{y_safe} Z{z_safe} F20000 ; move nozzle to remove stringing
[gcode_macro PARK_CENTER_REAR]
gcode:
{% if printer["gcode_macro status_busy"] != null %}
status_busy
{% endif %}
{% set th = printer.toolhead %}
{% set x_safe = th.position.x + 20 * (1 if th.axis_maximum.x - th.position.x > 20 else -1) %}
{% set y_safe = th.position.y + 20 * (1 if th.axis_maximum.y - th.position.y > 20 else -1) %}
G0 X{th.axis_maximum.x//2} Y{th.axis_maximum.y - 2} F3600
{% if printer["gcode_macro status_ready"] != null %}
status_ready
{% endif %}
[gcode_macro _CHOME]
gcode:
{% if printer["gcode_macro status_homing"] != null %}
status_homing
{% endif %}
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
{% if printer["gcode_macro status_ready"] != null %}
status_ready
{% endif %}
[gcode_macro _CQGL]
gcode:
{% if printer.quad_gantry_level.applied == False %}
{% if "xyz" not in printer.toolhead.homed_axes %}
G28 ; home if not already homed
{% endif %}
{% if printer["gcode_macro status_leveling"] != null %}
status_leveling
{% endif %}
QUAD_GANTRY_LEVEL
G28 Z
{% endif %}
{% if printer["gcode_macro status_ready"] != null %}
status_ready
{% endif %}
[gcode_macro BED_MESH_CALIBRATE]
rename_existing: _BED_MESH_CALIBRATE
#Insane Version 1.1 - 03-Feb-2023
#Based on https://github.com/kyleisah/Klipper-Adaptive-Meshing-Purging
variable_buffer: 2
gcode:
# Get bed_mesh config (probe count, mesh_min and mesh_max for x and y
{% set bedMeshConfig = printer['configfile'].config["bed_mesh"] %}
{% set bed_mesh_min = bedMeshConfig.mesh_min %}
{% set bed_mesh_max = bedMeshConfig.mesh_max %}
{% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %}
{% set x_min = all_points | map(attribute=0) | min | default(bed_mesh_min[0]) %}
{% set y_min = all_points | map(attribute=1) | min | default(bed_mesh_min[1]) %}
{% set x_max = all_points | map(attribute=0) | max | default(bed_mesh_max[0]) %}
{% set y_max = all_points | map(attribute=1) | max | default(bed_mesh_max[1]) %}
{% if printer["bed_mesh"].profile_name == '' %}
{ action_respond_info("No existing bed mesh found.") }
{% set last_area_end_x=-1 %}
{% endif %}
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
{% set klicky_available = printer['gcode_macro _Probe_Variables'] != null %}
{% set probeConfig = printer['configfile'].config["probe"] %}
{% if probeConfig %}
{% set OffsetX = probeConfig.x_offset|default(0)|float %}
{% set OffsetY = probeConfig.y_offset|default(0)|float %}
{% endif %}
{% set print_min_x = x_min|float %}
{% set print_min_y = y_min|float %}
{% set print_max_x = x_max|float %}
{% set print_max_y = y_max|float %}
{% set mesh_min_x = bed_mesh_min.split(",")[0]|float %}
{% set mesh_min_y = bed_mesh_min.split(",")[1]|float %}
{% set mesh_max_x = bed_mesh_max.split(",")[0]|float %}
{% set mesh_max_y = bed_mesh_max.split(",")[1]|float %}
{% if (print_min_x < mesh_min_x) or (print_max_x > mesh_max_x) or (print_min_y < mesh_min_y) or (print_max_y > mesh_max_y) %}
{% set print_min_x = mesh_min_x %}
{% set print_min_y = mesh_min_y %}
{% set print_max_x = mesh_max_x %}
{% set print_max_y = mesh_max_y %}
{% endif %}
{% if klicky_available %}
_CheckProbe action=query
Attach_Probe
{% elif euclid_available %}
DEPLOY_PROBE
{% endif %}
{% if (print_min_x < print_max_x) and (print_min_y < print_max_y) %}
{% set minimum_probe_count = 3 %}
{% set medium_probe_count = 5 %}
{% set probe_count = bedMeshConfig.probe_count.split(",") %}
{% set probe_count_x = probe_count[0]|int %}
{% if probe_count.__len__() > 1 %}
{% set probe_count_y = probe_count[1]|int %}
{% else %}
{% set probe_count_y = probe_count_x|int %}
{% endif %}
{% set relative_reference_index = bedMeshConfig.relative_reference_index %}
# If print area X is smaller than 75% of the bed size, change to to 5 probe counts for X instead of the default
{% if print_max_x - print_min_x < (mesh_max_x - mesh_min_x) * 0.75 %}
{% set probe_count_x = medium_probe_count %}
{% endif %}
# If print area Y is smaller than 75% of the bed size, change to to 5 probe counts for Y instead of the default
{% if print_max_y - print_min_y < (mesh_max_y - mesh_min_y) * 0.75 %}
{% set probe_count_y = medium_probe_count %}
{% endif %}
# If print area X is smaller than 50% of the bed size, change to to 3 probe counts for X instead of the default
{% if print_max_x - print_min_x < (mesh_max_x - mesh_min_x) * 0.50 %}
{% set probe_count_x = minimum_probe_count %}
{% endif %}
# If print area Y is smaller than 50% of the bed size, change to to 3 probe counts for Y instead of the default
{% if print_max_y - print_min_y < (mesh_max_y - mesh_min_y) * 0.50 %}
{% set probe_count_y = minimum_probe_count %}
{% endif %}
{% if print_min_x - buffer >= mesh_min_x %}
{% set mesh_min_x = print_min_x - buffer %}
{% endif %}
{% if print_min_y - buffer >= mesh_min_y %}
{% set mesh_min_y = print_min_y - buffer %}
{% endif %}
{% if print_max_x + buffer <= mesh_max_x %}
{% set mesh_max_x = print_max_x + buffer %}
{% endif %}
{% if print_max_y + buffer <= mesh_max_y %}
{% set mesh_max_y = print_max_y + buffer %}
{% endif %}
{ action_respond_info("mesh_min: %s,%s" % (mesh_min_x, mesh_min_y)) }
{ action_respond_info("mesh_max: %s,%s" % (mesh_max_x, mesh_max_y)) }
{ action_respond_info("probe_count: %s,%s" % (probe_count_x,probe_count_y)) }
{% if printer["gcode_macro status_meshing"] != null %}
status_meshing
{% endif %}
{% if relative_reference_index == 0 or relative_reference_index == null %}
_BED_MESH_CALIBRATE mesh_min={mesh_min_x},{mesh_min_y} mesh_max={mesh_max_x},{mesh_max_y} probe_count={probe_count_x},{probe_count_y}
{% else %}
{% set relative_reference_index = ((probe_count_x * probe_count_y - 1) / 2)|int %}
{ action_respond_info("relative_reference_index: %s" % relative_reference_index) }
_BED_MESH_CALIBRATE mesh_min={mesh_min_x},{mesh_min_y} mesh_max={mesh_max_x},{mesh_max_y} probe_count={probe_count_x},{probe_count_y} relative_reference_index={relative_reference_index}
{% endif %}
{% else %}
{% if printer["gcode_macro status_meshing"] != null %}
status_meshing
{% endif %}
_BED_MESH_CALIBRATE
{% endif %}
{% if klicky_available %}
Dock_Probe
{% elif euclid_available %}
STOW_PROBE
{% endif %}
{% if printer["gcode_macro status_ready"] != null %}
status_ready
{% endif %}
# # # Klipper Adaptive Purging - VoronDesign Logo # # #
# credits: https://github.com/kyleisah/Klipper-Adaptive-Meshing-Purging/blob/main/Configuration/Adaptive_Purge.cfg
# credits: Insane Version 1.1 - 03-Feb-2023
[gcode_macro _ADAPTIVE_PURGE]
description: A purge macro that adapts to be near your actual printed objects
variable_adaptive_enable: True # Change to False if you'd like the purge to be in the same spot every print
variable_z_height: 0.4 # Height above the bed to purge
variable_tip_distance: 10 # Distance between filament tip and nozzle before purge (this will require some tuning)
variable_purge_amount: 40 # Amount of filament to purge
variable_flow_rate: 10 # Desired flow rate in mm3/s
variable_x_default: 5 # X location to purge, overwritten if adaptive is True
variable_y_default: 5 # Y location to purge, overwritten if adaptive is True
variable_size: 10 # Size of the logo
variable_distance_to_object_x: 5 # Distance in x to the print area
variable_distance_to_object_y: 5 # Distance in y to the print area
gcode:
{% if adaptive_enable == True %}
{% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %}
{% set x_origin = (all_points | map(attribute=0) | min | default(x_default + distance_to_object_x + size)) - distance_to_object_x - size %}
{% set y_origin = (all_points | map(attribute=1) | min | default(y_default + distance_to_object_y + size)) - distance_to_object_y - size %}
{% set x_origin = ([x_origin, 0] | max) %}
{% set y_origin = ([y_origin, 0] | max) %}
{% if x_origin < x_default %}
set x_origin = x_default | float
{% endif %}
{% if y_origin < y_default %}
set y_origin = y_default | float
{% endif %}
{% else %}
{% set x_origin = x_default | float %}
{% set y_origin = y_default | float %}
{% endif %}
{% set purge_move_speed = 2.31 * size * flow_rate / (purge_amount * 2.405) %}
{% set prepurge_speed = flow_rate / 2.405 %}
{% set travel_speed = printer.toolhead.max_velocity %}
{ action_respond_info( "x: " + x_origin|string + " y: " + y_origin|string + " purge_move_speed: " + purge_move_speed|string + " prepurge_speed: " + prepurge_speed|string ) }
G92 E0
G0 F{travel_speed*5} # Set travel speed
G90 # Absolute positioning
G0 X{x_origin} Y{y_origin+size/2} # Move to purge position
G0 Z{z_height} # Move to purge Z height
M83 # Relative extrusion mode
G1 E{tip_distance} F{prepurge_speed*60} # Move tip of filament to nozzle
G1 X{x_origin+size*0.289} Y{y_origin+size} E{purge_amount/4} F{purge_move_speed*60} # Purge first line of logo
G1 E-.5 F2100 # Retract
G0 Z{z_height*2} # Z hop
G0 X{x_origin+size*0.789} Y{y_origin+size} # Move to second purge line origin
G0 Z{z_height} # Move to purge Z height
G1 E.5 F2100 # Recover
G1 X{x_origin+size*0.211} Y{y_origin} E{purge_amount/2} F{purge_move_speed*60} # Purge second line of logo
G1 E-.5 F2100 # Retract
G0 Z{z_height*2} # Z hop
G0 X{x_origin+size*0.711} Y{y_origin} # Move to third purge line origin
G0 Z{z_height} # Move to purge Z height
G1 E.5 F2100 # Recover
G1 X{x_origin+size} Y{y_origin+size/2} E{purge_amount/4} F{purge_move_speed*60} # Purge third line of logo
G1 E-.5 F2100 # Retract
G92 E0 # Reset extruder distance
M82 # Absolute extrusion mode
G0 Z{z_height*2} # Z hop
{% if printer["gcode_macro status_printing"] != null %}
status_printing
{% endif %}
[gcode_macro LOAD_FILAMENT]
gcode:
{% set speed = params.SPEED|default(300) %}
{% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity %}
SAVE_GCODE_STATE NAME=load_state
BEEP#M300 # beep
G91
G92 E0
#G1 E50 F{max_velocity} # fast-load
G1 E25 F{speed} # purge
BEEP
BEEP
RESTORE_GCODE_STATE NAME=load_state
[gcode_macro UNLOAD_FILAMENT]
gcode:
{% set speed = params.SPEED|default(300) %}
{% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity %}
SAVE_GCODE_STATE NAME=unload_state
G91
BEEP # beep
G92 E0
G1 E25 F{speed} # purge
G1 E-50 F{max_velocity} # fast-unload
BEEP
BEEP
RESTORE_GCODE_STATE NAME=unload_state
[gcode_macro SET_MATERIAL]
gcode:
{% set MATERIAL = params.MATERIAL|default('PLA')|string %}
{% if MATERIAL == 'PLA' %}
SET_FAN_SPEED FAN=exhaust_fan SPEED=1
# Load bed mesh
#BED_MESH_PROFILE LOAD="pla_mesh"
# Set pressure_advance settings
#SET_PRESSURE_ADVANCE ADVANCE=0.035 SMOOTH_TIME=0.040
# Set z_offset settings
#SET_GCODE_OFFSET Z=0
{% elif MATERIAL == 'ABS' %}
SET_FAN_SPEED FAN=exhaust_fan SPEED=0
#BED_MESH_PROFILE LOAD="pla_mesh"
#SET_PRESSURE_ADVANCE ADVANCE=0.035 SMOOTH_TIME=0.040
#SET_GCODE_OFFSET Z=0
{% elif MATERIAL == 'ASA' %}
SET_FAN_SPEED FAN=exhaust_fan SPEED=0
{% elif MATERIAL == 'PETG' %}
SET_FAN_SPEED FAN=exhaust_fan SPEED=1
{%else %}
#BED_MESH_PROFILE LOAD="default"
#SET_PRESSURE_ADVANCE ADVANCE=0.035 SMOOTH_TIME=0.040
#SET_GCODE_OFFSET Z=0
{% endif %}
[gcode_shell_command backup_cfg]
command: /usr/bin/bash /home/pi/printer_data/config/autocommit.sh
timeout: 30
verbose: True
[gcode_macro BACKUP_CFG]
description: Backs up config directory GitHub
gcode:
RUN_SHELL_COMMAND CMD=backup_cfg
[gcode_macro BEEP]
gcode:
# Parameters
{% set i = params.I|default(1)|int %} ; Iterations (number of times to beep).
{% set dur = params.DUR|default(100)|int %} ; Duration/wait of each beep in ms. Default 100ms.
{% for iteration in range(i|int) %}
SET_PIN PIN=beeper VALUE=1
G4 P{dur}
SET_PIN PIN=beeper VALUE=0
G4 P{dur}
{% endfor %}