-
Notifications
You must be signed in to change notification settings - Fork 1
/
macros.cfg
618 lines (476 loc) · 16.9 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
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
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
##############################################################################
## Print Macros ##
##############################################################################
[gcode_macro PRINT_START_PLA]
gcode:
{% set target_extruder = params.EXTRUDER|int %}
{% set target_bed = params.BED|int %}
{% set x_wait = printer.toolhead.axis_maximum.x|float / 2 %}
{% set y_wait = printer.toolhead.axis_maximum.y|float / 2 %}
M140 S{target_bed} # Set the bed temperature for the first layer
M104 S160 # Preheat the extruder to 120°C
M190 S{target_bed} # Wait for the bed to reach the initial layer temperature
M109 S160 ; wait for extruder temperature to reach 160C
status_homing
G28
BED_MESH_CLEAR ; clear the previous bed mesh
BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1 ; perform adaptive bed mesh calibration
G0 X0 Y0 Z20 F5000 # Go to primeline
M107 # Turn off part cooling fan
M109 S{target_extruder} # Wait for extruder temperature
M190 S{target_bed} # Wait for bed temperature
M83 #set extruder to relative mode
G0 Z5 F1200
G0 X{first_layer_print_min[0]} Y{max(0, first_layer_print_min[1] - 2)} F12000
G0 Z0.2 F600
G1 E3 F1800
G0 Z0.3 F600
G1 X{min(first_layer_print_min[0] + 30,print_bed_max[0])} E6 F600
SFS_on
[gcode_macro print_start_PLA2]
gcode:
{% set target_extruder = params.EXTRUDER|int %}
{% set target_bed = params.BED|int %}
{% set x_wait = printer.toolhead.axis_maximum.x|float / 2 %}
{% set y_wait = printer.toolhead.axis_maximum.y|float / 2 %}
G28 ; home all axes
M104 S160 ; set extruder temperature to 160C
M190 S[first_layer_bed_temperature] ; set bed temperature and wait for it to reach target
M109 S160 ; wait for extruder temperature to reach 160C
BED_MESH_CLEAR ; clear the previous bed mesh
BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1; perform adaptive bed mesh calibration
G0 X0 Y0 Z50 F6000 ; move the nozzle to just above the bed
M109 S[first_layer_temperature] ; wait for extruder temperature to reach target
SET_TEMPERATURE_FAN_TARGET temperature_fan="chamber_fan" target=35 ; set chamber exhaust fan target temperature to 35C
M83 ; set extruder to relative mode
G0 Z5 F1200 ; lower the nozzle to just above the bed
G0 X0 Y0 F12000 ; move the nozzle to the start of the print
G0 Z0.2 F600 ; lower the nozzle to the start height
G1 E3 F1800 ; prime the nozzle
G0 Z0.3 F600 ; raise the nozzle slightly to avoid scratching the bed
G1 X30 E6 F600 ; draw a purge line
SFS_on
[gcode_macro print_start_ABS]
gcode:
G28 ; home all axes
M141 S60 ; set chamber temperature to 60C
TEMPERATURE_WAIT SENSOR="temperature_sensor chamber_heater" MINIMUM={params.CHAMBER_TEMP} ; Wait for chamber temp
M190 S[first_layer_bed_temperature] ; set bed temperature and wait for it to reach target
M191 S60 ; wait for chamber temperature to reach 60C
G4 S600 ; wait for 10 minutes
M104 S160 ; set extruder temperature to 160C
M109 S160 ; wait for extruder temperature to reach 160C
BED_MESH_CLEAR ; clear the previous bed mesh
BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1 ; perform adaptive bed mesh calibration
G0 X0 Y0 Z50 F6000 ; move the nozzle to just above the bed
M109 S[first_layer_temperature] ; wait for extruder temperature to reach target
SET_TEMPERATURE_FAN_TARGET temperature_fan="chamber_fan" target=70 ; set chamber exhaust fan target temperature to 65c
M83 ; set extruder to relative mode
G0 Z5 F1200 ; lower the nozzle to just above the bed
G0 X0 Y0 F12000 ; move the nozzle to the start of the print
G0 Z0.2 F600 ; lower the nozzle to the start height
G1 E3 F1800 ; prime the nozzle
G0 Z0.3 F600 ; raise the nozzle slightly to avoid scratching the bed
G1 X30 E6 F600 ; draw a purge line
[gcode_macro PRINT_END]
gcode:
SFS_off
M106 P2 S0
M106 P0 S0
M106 P3 S0 #Switch off the activated carbon fan
M104 S0
M140 S0
M141 S0
M220 S100
M221 S100
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value
CLEAR_PAUSE
BED_MESH_CLEAR
BED_MESH_PROFILE LOAD=default
G31
SET_FILAMENT_SENSOR SENSOR=fila ENABLE=0
M84
BEEP I=2 DUR=500
########################################
# CHamber heater/exhaust #
#########################################
[gcode_macro list_sensors]
gcode:
{ action_respond_info(printer.heaters.available_heaters | join(', ')) }
{ action_respond_info(printer.heaters.available_sensors | join(', ')) }
[gcode_macro M141]
gcode:
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={params.S|default(0)}
#################################################
# Waiting time until the chamber is heated #
#################################################
[gcode_macro M191]
gcode:
{% set s = params.S|float %}
{% if s == 0 %}
# If target temperature is 0, do nothing
M117 Chamber heating cancelled
{% else %}
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET=65
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={s}
M140 S110 # uncomment the previous line if you want to use heat bed to assist chamber heating
TEMPERATURE_WAIT SENSOR="heater_generic chamber_heater" MINIMUM={s-1} MAXIMUM={s+1}
M117 Chamber at target temperature
{% endif %}
########################################
# Pressure advance/square corner #
#########################################
[gcode_macro M900_Pressure_advance] #Qidi Gcode for PA
gcode:
gcode:
{% if params.K is defined %}
SET_PRESSURE_ADVANCE ADVANCE={params.K}
{% endif %}
{% if params.T is defined %}
SET_PRESSURE_ADVANCE SMOOTH_TIME={params.T}
{% endif %}
[gcode_macro M205_Square_corner_velocity]
gcode:
{% if 'X' in params %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.X}
{% elif 'Y' in params %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.Y}
{% endif %}
[gcode_macro M84]
rename_existing:M84.1
gcode:
SET_STEPPER_ENABLE STEPPER=stepper_x enable=0
SET_STEPPER_ENABLE STEPPER=stepper_y enable=0
SET_STEPPER_ENABLE STEPPER=stepper_z enable=0
SET_STEPPER_ENABLE STEPPER=extruder enable=0
##################################
# Firmware retraction #
##################################
[firmware_retraction]
retract_length: 1 ; length of filament (in mm) at G10/G11
unretract_extra_length: 0 ; length of additional filament (in mm) at G11
retract_speed: 30
unretract_speed: 30
##################################
# To disable X/Y motor bed adjust & screws tilt adjust###
###################################
[gcode_macro disable_X_Y_bed_screw_adjust]
description: disable X/Y motors to adjust screws on bed for flatness
gcode:
SET_STEPPER_ENABLE STEPPER=extruder ENABLE=0
SET_STEPPER_ENABLE STEPPER=stepper_x ENABLE=0
SET_STEPPER_ENABLE STEPPER=stepper_y ENABLE=0
[gcode_macro M84]
rename_existing:M84.1
gcode:
SET_STEPPER_ENABLE STEPPER=stepper_x enable=0
SET_STEPPER_ENABLE STEPPER=stepper_y enable=0
SET_STEPPER_ENABLE STEPPER=stepper_z enable=0
SET_STEPPER_ENABLE STEPPER=extruder enable=0
[screws_tilt_adjust]
horizontal_move_z: 4
screw_thread: CCW-M4
speed: 300
screw1: 30,5
screw1_name: front left
screw2: 285,5
screw2_name: front right
screw3: 285,270
screw3_name: rear right
screw4: 30,270
screw4_name: rear left
[gcode_macro SCREWS_TILT]
description: Executes the homing of all axes and starts Screws Tilt Calculate
gcode:
_CG28
SCREWS_TILT_CALCULATE
##################################
########PID TUNE################
###############################
# PID tune bed to 65C
[gcode_macro PID_BED_65]
description: Start Bed PID
gcode:
{% if printer.idle_timeout.state == "Printing" %}
RESPOND TYPE=error MSG="This macro cannot be used while printing!"
{% else %}
G28
M106
G1 Z50 F1500
RESPOND MSG="Bed PID in progress..."
PID_CALIBRATE HEATER=heater_bed TARGET={params.TEMP|default(65)}
G28
G1 Z50
SAVE_CONFIG
{% endif %}
# PID tune hotend to 220C
[gcode_macro PID_HOTEND_220]
description: Start Hotend PID
gcode:
{% if printer.idle_timeout.state == "Printing" %}
RESPOND TYPE=error MSG="This macro cannot be used while printing!"
{% else %}
G28
M106
G1 Z50 F1500
RESPOND MSG="Hotend PID in progress..."
PID_CALIBRATE HEATER=extruder TARGET={params.TEMP|default(220)}
G28
G1 Z50
SAVE_CONFIG
{% endif %}
#############################
# Load/Unload Pause/resume #
#############################
[gcode_macro UNLOAD_FILAMENT]
description: Filament unloading
gcode:
{% if printer.idle_timeout.state == "Printing" and not printer.pause_resume.is_paused %}
RESPOND TYPE=error MSG="This macro cannot be used while printing!"
{% else %}
SAVE_GCODE_STATE NAME=unload_state
{% if printer.extruder.temperature < 200 %}
RESPOND MSG="Heating..."
M109 S210
{% endif %}
RESPOND MSG="Unloading filament..."
G91
G1 E5 F300
G0 E-10 F300
G0 E-50 F800
RESTORE_GCODE_STATE NAME=unload_state
{% endif %}
[gcode_macro LOAD_FILAMENT]
description: Filament loading
gcode:
{% if printer.idle_timeout.state == "Printing" and not printer.pause_resume.is_paused %}
RESPOND TYPE=error MSG="This macro cannot be used while printing!"
{% else %}
SAVE_GCODE_STATE NAME=load_state
{% if printer.extruder.temperature < 200 %}
RESPOND MSG="Heating..."
M109 S210
{% endif %}
RESPOND MSG="Loading filament..."
G91
G0 E50 F800
G0 E30 F300
M400
RESTORE_GCODE_STATE NAME=load_state
{% endif %}
[gcode_macro M600]
gcode:
{% set X = params.X|default(printer.configfile.config["stepper_x"]["position_endstop"]|string)|int %}
{% set Y = params.Y|default(printer.configfile.config["stepper_y"]["position_endstop"]|string)|int %}
{% set Z = params.Z|default(10)|int %}
{% set E = params.E|default(-20)|int %}
{% set tool = params.tool|default(0)|int %}
SAVE_GCODE_STATE NAME=M600_state
PAUSE
G91
G1 E-5 F4000
G1 Z{Z}
G90
G1 X{X} Y{Y} F3000 ;park position
G0 E10 F500 ;extrude filament to get better blob on end
G0 E{E} F600 ;retract additional filament to move out of melt zone
G92 E0
SFS_off
[gcode_macro SWAP_RESUME]
gcode:
RESTORE_GCODE_STATE NAME=M600_state
SFS_on
#########################
########Park commands####
#########################
# Park at center of build volume
[gcode_macro PARKCENTER]
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28 ; home if not already homed
{% endif %}
SAVE_GCODE_STATE NAME=PARKCENTER
G90 ; absolute positioning
G0 X{printer.toolhead.axis_maximum.x/2} Y{printer.toolhead.axis_maximum.y/2} Z{printer.toolhead.axis_maximum.z/2} F6000
RESTORE_GCODE_STATE NAME=PARKCENTER
# Park 15mm above center of bed
[gcode_macro PARKBED]
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28 ; home if not already homed
{% endif %}
SAVE_GCODE_STATE NAME=PARKBED
G90 ; absolute positioning
G0 X{printer.toolhead.axis_maximum.x/2} Y{printer.toolhead.axis_maximum.y/2} Z15 F6000
RESTORE_GCODE_STATE NAME=PARKBED
###################################
#########Case light control#########
####################################
[output_pin caselight]
pin: PC7
pwm: true
shutdown_value: 0
value:.5 #the brightness at startup (0-1)
cycle_time: 0.01
[gcode_macro CASELIGHT_ON]
description: Helper: Light on
gcode:
SET_PIN PIN=caselight VALUE=1.0
{action_respond_info("Caselight on")}
[gcode_macro CASELIGHT_OFF]
description: Helper: Light off
gcode:
SET_PIN PIN=caselight VALUE=0.0
{action_respond_info("Caselight off")}
#################################################
# Calibration #
################################################
#[gcode_macro M109]
#rename_existing: M99109
#gcode:
#Parameters
#{% set s = params.S|float %}
#M104 {% for p in params %}{'%s%s' % (p, params[p])}{% endfor %} ; Set hotend temp
#{% if s != 0 %}
#TEMPERATURE_WAIT SENSOR=extruder MINIMUM={s} MAXIMUM={s+1} ; Wait for hotend temp (within 1 degree)
#{% endif %}
[gcode_macro BED_MESH_CALIBRATION]
gcode:
M140 S60 #Set the bed temperature to 60 degrees Celsius
M190 S60 #Wait until the print bed has reached 60 degrees Celsius
BED_MESH_CLEAR
G28
BED_MESH_CALIBRATE PROFILE="default" #Start bed leveling with the "default" profile
M140 S0 # Switch off the heating bed
G1 X165 Y165 F6000 #Move the print head to the center of the bed (280/2=140)
SAVE_CONFIG # Save the configuration
#################################################
# Beep output #
#################################################
[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.
{% if printer["output_pin sound"].value|int == 1 %}
{% 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 %}
{% endif %}
[gcode_macro _CG28]
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28
{% endif %}
#################################################
# Manual bed leveling #
#################################################
[gcode_macro G30]
gcode:
BED_MESH_CLEAR #清除调平数据
# G28
BED_MESH_CALIBRATE mesh_min=10,10 mesh_max=310,310 METHOD=manual #手动动调平
#################################################
# Fan control Macro p1-p2-p3 orca #
#################################################
[gcode_macro M106]
gcode:
{% if params.P is defined %}
{% if params.S is defined %}
SET_PIN PIN=fan{params.P|int} VALUE={params.S|int}
{% else %}
SET_PIN PIN=fan{params.P|int} VALUE=255
{% endif %}
{% endif %}
{% if params.T is defined %}
{% if (params.T|int)==-2 %}
{% if params.S is defined %}
SET_PIN PIN=fan3 VALUE={params.S|int}
{% else %}
SET_PIN PIN=fan3 VALUE=255
{% endif %}
{% endif %}
{% endif %}
{% if params.P is undefined %}
{% if params.T is undefined %}
{% if params.S is defined %}
SET_PIN PIN=fan0 VALUE={params.S|int}
{% else %}
SET_PIN PIN=fan0 VALUE=255
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M107]
gcode:
SET_PIN PIN=fan0 VALUE=0
# SET_PIN PIN=fan1 VALUE=0
# SET_PIN PIN=fan2 VALUE=0
#################################################
# Pressure Advanced #
#################################################
[gcode_macro M900]
gcode:
{% if params.K is defined %}
SET_PRESSURE_ADVANCE ADVANCE={params.K}
{% endif %}
{% if params.T is defined %}
SET_PRESSURE_ADVANCE SMOOTH_TIME={params.T}
{% endif %}
#################################################
# Velocity limit #
#################################################
[gcode_macro M204]
rename_existing: M99204
gcode:
{% if params.S is defined %}
{% set s = params.S|float %}
{% endif %}
{% if params.P is defined %}
{% if params.T is defined %}
{% set s = [params.P|float ,params.T|float] | min %}
{% endif %}
{% endif %}
SET_VELOCITY_LIMIT ACCEL={s}
SET_VELOCITY_LIMIT ACCEL_TO_DECEL={s/2}
#################################################
# Z-Offset during the printing process #
#################################################
[gcode_macro M290]
gcode:
SET_GCODE_OFFSET Z_ADJUST={params.Z}
#################################################
# Shaper Calibrate #
#################################################
[gcode_macro shapper_calibrate]
gcode:
G28
SHAPER_CALIBRATE
SAVE_CONFIG
#################################################
# Pause printing process #
#################################################
[gcode_macro M0]
gcode:
PAUSE
[gcode_macro M25]
rename_existing: M9925
gcode:
PAUSE
#################################################
# Output pin Sound #
#################################################
[output_pin sound]
pin: PA13
value:1
#################################################
# BeEper #
#################################################
[gcode_macro beep_on]
gcode:
SET_PIN PIN=sound VALUE=1
[gcode_macro beep_off]
gcode:
SET_PIN PIN=sound VALUE=0