-
Notifications
You must be signed in to change notification settings - Fork 3
/
printer-macros.cfg
552 lines (513 loc) · 15 KB
/
printer-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
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
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
###########################################################################
###########################################################################
[exclude_object]
[menu __main __octoprint]
type: disabled
########### MAINSAIL #
[gcode_shell_command telegram]
command: sh /home/pi/moonraker-telegram/scripts/telegram.sh "this is a message from your printer"
timeout: 2.
verbose: false
###########################################################################
###########################################################################
[temperature_sensor rpi]
sensor_type: temperature_host
########################
#
# MACROS
#
########################
########################
# #
# TOUCH'MI #
# #
########################
[gcode_macro _MOVE_Z_UP]
variable_upz: 0
gcode:
{% if upz == 0 %}
SET_KINEMATIC_POSITION Z=0
G90
G1 Z{printer["gcode_macro _VARS_PRINTER"].touchmi_z_height|int} F300
SET_GCODE_VARIABLE MACRO=_MOVE_Z_UP VARIABLE=upz VALUE=1
{% endif %}
[gcode_macro G28]
rename_existing: G999928
gcode:
G90
{% set do_x = 0 %}
{% set do_y = 0 %}
{% set do_z = 0 %}
{% if params.Y is defined %}
_MOVE_Z_UP
_HOME_Y
{% else %}
{% set do_y = 1 %}
{% endif %}
{% if params.X is defined %}
_MOVE_Z_UP
_HOME_X
{% else %}
{% set do_x = 1 %}
{% endif %}
{% if params.Z is defined %}
G999928 Z0
{% else %}
{% set do_z = 1 %}
{% endif %}
{% if do_x == 1 and do_y == 1 and do_z == 1 %}
_MOVE_Z_UP
HOME_ALL
{% endif %}
G90
[gcode_macro _HOME_X]
gcode:
G90
#SET_TMC_CURRENT STEPPER=stepper_x CURRENT=0.400 HOLDCURRENT=0.400
#SET_TMC_CURRENT STEPPER=stepper_y CURRENT=0.400 HOLDCURRENT=0.400
G4 P2000
G999928 X0
G4 P2000
#SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config["tmc2209 stepper_x"]["run_current"]} HOLDCURRENT={printer.configfile.config["tmc2209 stepper_x"]["hold_current"]}
#SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config["tmc2209 stepper_y"]["run_current"]} HOLDCURRENT={printer.configfile.config["tmc2209 stepper_y"]["hold_current"]}
G4 P1000
G91
{% if printer.configfile.config["stepper_x"]["position_endstop"]|int < 30 %}
G1 X30 F2000
{% else %}
G1 X-30 F2000
{% endif %}
[gcode_macro _HOME_Y]
gcode:
G90
#SET_TMC_CURRENT STEPPER=stepper_x CURRENT=0.400 HOLDCURRENT=0.400
#SET_TMC_CURRENT STEPPER=stepper_y CURRENT=0.400 HOLDCURRENT=0.400
G4 P2000
G999928 Y0
G4 P2000
#SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config["tmc2209 stepper_x"]["run_current"]} HOLDCURRENT={printer.configfile.config["tmc2209 stepper_x"]["hold_current"]}
#SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config["tmc2209 stepper_y"]["run_current"]} HOLDCURRENT={printer.configfile.config["tmc2209 stepper_y"]["hold_current"]}
G4 P1000
G91
{% if printer.configfile.config["stepper_y"]["position_endstop"]|int < 30 %}
G1 Y30 F2000
{% else %}
G1 Y-30 F2000
{% endif %}
[homing_override]
set_position_z: 0
axes: z
gcode:
G90
{% if not 'xy' in printer.toolhead.homed_axes %}
_HOME_X
_HOME_Y
{% endif %}
G90
G1 Z{printer["gcode_macro _VARS_PRINTER"].touchmi_z_height|int} F300
_DEPLOY_TOUCHMI
_GO_TO_CENTER
G999928 Z0
G1 Z{printer["gcode_macro _VARS_PRINTER"].touchmi_z_height|int} F300
[gcode_macro _GO_TO_CENTER]
gcode:
G1 X{printer["gcode_macro _VARS_PRINTER"].touchmi_x_center_pos|int} Y{printer["gcode_macro _VARS_PRINTER"].touchmi_y_center_pos|int} F3600
[gcode_macro _DEPLOY_TOUCHMI]
gcode:
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_LEVELING
{% endif %}
{% if printer["gcode_macro _RETRACT_TOUCHMI"].touchmi_retracted|int == 1 %}
SET_GCODE_VARIABLE MACRO=_RETRACT_TOUCHMI VARIABLE=touchmi_retracted VALUE=0
{% if not 'xy' in printer.toolhead.homed_axes %}
_HOME_X
_HOME_Y
{% endif %}
G90
G1 X{printer["gcode_macro _VARS_PRINTER"].touchmi_x_pos|int - 30} F3600
G1 Y{printer["gcode_macro _VARS_PRINTER"].touchmi_y_pos|int} F3600
G1 X{printer["gcode_macro _VARS_PRINTER"].touchmi_x_pos|int} F3600
G4 P1000
G1 X{printer["gcode_macro _VARS_PRINTER"].touchmi_x_pos|int - 30} F3600
M400
{% endif %}
[gcode_macro _RETRACT_TOUCHMI]
variable_touchmi_retracted: 1
gcode:
SET_GCODE_VARIABLE MACRO=_RETRACT_TOUCHMI VARIABLE=touchmi_retracted VALUE=1
G90
G1 Z0 F300
G1 Z10 F300
[gcode_macro SCREWS_TILT_CALCULATE]
rename_existing: BASE_SCREWS_TILT_CALCULATE
gcode:
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_CALIBRATING_Z
{% endif %}
{% if not 'xyz' in printer.toolhead.homed_axes %}
HOME_ALL
{% endif %}
_DEPLOY_TOUCHMI
BASE_SCREWS_TILT_CALCULATE
_RETRACT_TOUCHMI
[gcode_macro _MZ_TILT_ADJUST]
gcode:
{% if printer["gcode_macro _VARS_PRINTER"].enable_z_tilt|int == 1 %}
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_CALIBRATING_Z
{% endif %}
{% if not 'xyz' in printer.toolhead.homed_axes %}
HOME_ALL
{% endif %}
_DEPLOY_TOUCHMI
Z_TILT_ADJUST
G999928 Z0
{% endif %}
[gcode_macro BED_MESH_CALIBRATE]
rename_existing: BASE_MESH_CALIBRATE
gcode:
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_MESHING
{% endif %}
{% if not 'xyz' in printer.toolhead.homed_axes %}
HOME_ALL
{% endif %}
_MZ_TILT_ADJUST
BASE_MESH_CALIBRATE
_RETRACT_TOUCHMI
[gcode_macro G29]
gcode:
{% if not 'xyz' in printer.toolhead.homed_axes %}
HOME_ALL
{% endif %}
_DEPLOY_TOUCHMI
_GO_TO_CENTER
BED_MESH_CALIBRATE
_RETRACT_TOUCHMI
[gcode_macro HOME_ALL]
gcode:
SET_GCODE_VARIABLE MACRO=_RETRACT_TOUCHMI VARIABLE=touchmi_retracted VALUE=1
_HOME_X
_HOME_Y
_DEPLOY_TOUCHMI
G999928 Z0
_MZ_TILT_ADJUST
_RETRACT_TOUCHMI
########################
#
# START END MACROS
#
########################
# Replace the slicer's custom start and end g-code scripts with
# START_PRINT and END_PRINT.
[delayed_gcode _PARK_PURGE]
initial_duration: 0.1
gcode:
{% if printer["gcode_macro _VARS_PRINTER"].enable_servo|int ==1 %}
_PARK_PURGE
{% endif %}
[delayed_gcode _SB_LEDS_OFF]
initial_duration: 0.1
gcode:
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_OFF
{% endif %}
[gcode_macro START_PRINT]
gcode:
{% set BED_TEMP = params.BED_TEMP|default(0)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(0)|float %}
{% set LOAD = params.LOAD|default(-1)|int %}
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_BUSY
{% endif %}
{% if printer["gcode_macro _VARS_PRINTER"].enable_servo|int ==1 %}
_PARK_PURGE
{% endif %}
# metric values
G21
# Use absolute coordinates
G90
# set extruder to absolute mode
M82
# start with the fan off
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_HEATING
{% endif %}
M107
# Start bed heating
M140 S{BED_TEMP}
# Wait for bed to reach temperature
M190 S{BED_TEMP}
# Reset the G-Code Z offset (adjust Z offset if needed)
SET_GCODE_OFFSET Z=0.0
# clear pause
CLEAR_PAUSE
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_HOMING
{% endif %}
# Home the printer
HOME_ALL
# Load mesh
BED_MESH_PROFILE LOAD=default
# Move the nozzle near the bed
G1 Z15 F3000
# Set and wait for nozzle to reach temperature
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_HEATING
{% endif %}
M109 S{EXTRUDER_TEMP}
# Load filament into MMU
{% if printer["gcode_macro _VARS_PRINTER"].enable_mmu|int == 1 %}
_RESET_MMU_ERROR
_MMU_WRITE_STAT MSG="STATUS:START:-1"
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_HOMING
{% endif %}
HOME_MMU
M109 S{EXTRUDER_TEMP}
_GO_TO_PARKING
# zero the extruded length
G92 E0
{% if LOAD|int != -1 %}
{% if printer["gcode_macro _VARS_PRINTER"].enable_servo|int == 1 %}
_DEPLOY_PURGE
{% endif %}
{% if LOAD|int == 0 %}
T0
{% endif %}
{% if LOAD|int == 1 %}
T1
{% endif %}
{% if LOAD|int == 2 %}
T2
{% endif %}
{% if LOAD|int == 3 %}
T3
{% endif %}
{% if LOAD|int == 4 %}
T4
{% endif %}
M400
G92 E0
{% if printer["gcode_macro _VARS_PRINTER"].enable_servo|int == 1 %}
_RETRACT_PURGE
{% endif %}
{% endif %}
_GO_TO_PARKING_OUT
{% endif %}
# _clean nozzle
_clean
# zero the extruded length
G92 E0
# start printing
G1 F9000
M117 ->> Printing <--
_bip
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_PRINTING
{% endif %}
_START_PRINT
[gcode_macro _START_PRINT]
gcode:
{% if printer["gcode_macro _VAR_MMU2S"].enable_filametrix_pause_at_start %}
RESPOND PREFIX=tgnotify MSG="Printer is paused, remove Filametrix before Homing"
PAUSE
{% endif %}
[gcode_macro END_PRINT]
gcode:
# Turn off bed, extruder, and fan
M140 S0
M104 S0
M106 S0
# Move nozzle away from print while retracting
G91
# retract the filament a bit before lifting the nozzle to release some of the pressure
G1 E-1 F300
# move Z up a bit and retract filament even more
G1 Z+5 E-2 F9000
G90
{% if printer["gcode_macro _VARS_PRINTER"].enable_mmu|int == 1 %}
M702
_GO_TO_PARKING_OUT
{% endif %}
G90
# the bed to move to the front
G1 X{printer["gcode_macro _VARS_PRINTER"].end_x_pos|int} Y{printer["gcode_macro _VARS_PRINTER"].end_y_pos|int} F9000
# Disable steppers
M84
# extruder fan off
M107
_bip
{% if printer["gcode_macro _VARS_PRINTER"].enable_mmu|int == 1 %}
DISPLAY_MMU_ERROR
{% endif %}
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_READY
{% endif %}
_MMU_WRITE_STAT MSG="STATUS:END:-1"
_MMU_GENERATE_STAT
########################
#
# MISC MACROS
#
########################
[gcode_macro _bip]
gcode:
SET_PIN PIN=beeper VALUE=1
G4 P1000 ; wait 1 s
SET_PIN PIN=beeper VALUE=0
[gcode_macro _clean]
gcode:
{% if printer["gcode_macro _VARS_PRINTER"].enable_clean_nozzle|int ==1 %}
{% if printer["gcode_macro _VAR_MMU2S"].enable_stealthburner_leds %}
_STATUS_CLEANING
{% endif %}
G90
G1 Z10
G1 X{printer["gcode_macro _VARS_PRINTER"].clean_x_pos|int} Y{printer["gcode_macro _VARS_PRINTER"].clean_y_pos|int} F3000
G1 Z-1
G91
G1 X7
G1 X-7 Y-19
G1 X7
G1 X-7 Y19
G1 X7 Y-35
G1 X-7
G1 X7 Y35
G1 X-7 Y-19
G90
G1 Z10
{% endif %}
#############################
#
# LOAD/UNLOAD/PAUSE macros
#
#############################
[pause_resume]
[gcode_macro PAUSE_PRINT]
gcode:
{% set X = params.X|default(10)|int %}
{% set Y = params.Y|default(10)|int %}
{% set Z = params.Z|default(10)|int %}
SAVE_GCODE_STATE NAME=PAUSE_state
PAUSE
G91
G1 E-1 F2000
G1 Z{Z}
G90
G1 X{X} Y{Y} F3000
G91
_bip
G4 P200
_bip
G4 P200
_bip
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
[gcode_macro M600]
gcode:
{% set Z = params.Z|default(10)|int %}
SAVE_GCODE_STATE NAME=M600_state
PAUSE
G91
G1 E-1 F2000
G1 Z{Z}
G90
G1 X{printer["gcode_macro _VARS_PRINTER"].change_filament_x_pos|int} Y{printer["gcode_macro _VARS_PRINTER"].change_filament_y_pos|int} F3000
_EJECT_FILAMENT
_bip
G4 P200
_bip
G4 P200
_bip
G4 P10000
_INSERT_FILAMENT
; prime nozzle
G1 E-0.8 F4500
G1 E0.8 F4500
G1 E0.8 F4500
RESTORE_GCODE_STATE NAME=M600_state MOVE=1
[gcode_macro _EJECT_FILAMENT]
gcode:
{% set LENGTH_MAX = params.LENGTH_MAX|default(100)|int %}
G91
M83
_bip
G1 E+1 F4500
G1 E+10 F540
G1 E-20 F3000
G4 P3000
{% for i in range(printer["gcode_macro _VARS_PRINTER"].change_length_slow|int//LENGTH_MAX|int) %}
G1 E-{LENGTH_MAX} F200
{% endfor %}
G1 E-{printer["gcode_macro _VARS_PRINTER"].change_length_slow|int%LENGTH_MAX|int} F200
{% for i in range(printer["gcode_macro _VARS_PRINTER"].change_length_fast|int//LENGTH_MAX|int) %}
G1 E-{LENGTH_MAX} F3600
{% endfor %}
G1 E-{printer["gcode_macro _VARS_PRINTER"].change_length_fast|int%LENGTH_MAX|int} F3600
_bip
G4 P200
_bip
G4 P200
_bip
M82
G90
[gcode_macro CHANGE_EJECT]
gcode:
{% set TEMP = params.TEMP|default(235)|float %}
G28
G90
G1 X{printer["gcode_macro _VARS_PRINTER"].change_filament_x_pos|int} Y{printer["gcode_macro _VARS_PRINTER"].change_filament_y_pos|int} Z20 F3000
M109 S{TEMP} T0
_EJECT_FILAMENT
M104 S0 T0
[gcode_macro _INSERT_FILAMENT]
gcode:
{% set LENGTH_MAX = params.LENGTH_MAX|default(100)|int %}
G91
M83
{% for i in range(printer["gcode_macro _VARS_PRINTER"].change_length_fast|int//LENGTH_MAX|int) %}
G1 E{LENGTH_MAX} F3600
{% endfor %}
G1 E{printer["gcode_macro _VARS_PRINTER"].change_length_fast|int%LENGTH_MAX|int} F3600
_bip
{% for i in range(printer["gcode_macro _VARS_PRINTER"].change_length_slow|int//LENGTH_MAX|int) %}
G1 E{LENGTH_MAX} F200
{% endfor %}
G1 E{printer["gcode_macro _VARS_PRINTER"].change_length_slow|int%LENGTH_MAX|int} F200
G4 P1000
G1 E+1 F600
_bip
M82
G90
[gcode_macro CHANGE_INSERT]
gcode:
{% set TEMP = params.TEMP|default(235)|float %}
G28
G90
G1 X{printer["gcode_macro _VARS_PRINTER"].change_filament_x_pos|int} Y{printer["gcode_macro _VARS_PRINTER"].change_filament_y_pos|int} Z20 F3000
M109 S{TEMP} T0
_INSERT_FILAMENT
M104 S0 T0
##################################
##################################
#
# TUNNING MACROS
#
##################################
##################################
[gcode_macro SPEED_TEST]
gcode:
{% set SPEED = params.SPEED|default(2000)|int %}
_HOME_X
_HOME_Y
G90
{% for i in range(3) %}
G1 X20 Y20 F{SPEED|int}
G1 X{printer.configfile.config["stepper_x"]["position_max"]|int -20} Y20 F{SPEED|int}
G1 X{printer.configfile.config["stepper_x"]["position_max"]|int -20} Y{printer.configfile.config["stepper_y"]["position_max"]|int -20} F{SPEED|int}
G1 X20 Y{printer.configfile.config["stepper_y"]["position_max"]|int -20} F{SPEED|int}
G1 X20 Y20 F{SPEED|int}
G1 X{printer.configfile.config["stepper_x"]["position_max"]|int -20} Y{printer.configfile.config["stepper_y"]["position_max"]|int -20} F{SPEED|int}
G1 X20 Y{printer.configfile.config["stepper_y"]["position_max"]|int -20} F{SPEED|int}
G1 X{printer.configfile.config["stepper_x"]["position_max"]|int -20} Y20 F{SPEED|int}
{% endfor %}