-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcode_macro.cfg
405 lines (367 loc) · 10.3 KB
/
gcode_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
# Ender-3V3 KE
[exclude_object]
[virtual_sdcard]
#path: /home/rock/gcode_files
path: /usr/data/printer_data/gcodes
[pause_resume]
[display_status]
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
TURN_OFF_HEATERS
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z2
G90
{% else %}
{action_respond_info("Printer not homed")}
G28 X Y
{% endif %}
G1 F3000X0Y220
M104 S0
M140 S0
M107
M84
CANCEL_PRINT_BASE
FINISH_INIT
[gcode_macro PRINT_CALIBRATION]
# This part of the command is replaced by the application side without passing parameters
gcode:
CX_PRINT_LEVELING_CALIBRATION
[gcode_macro FIRST_FLOOR_PAUSE_POSITION]
gcode:
{% set extruder_temp = printer.custom_macro.g28_ext_temp %}
M104 S{extruder_temp}
{% set y_park = printer.toolhead.axis_maximum.y/2 %}
{% set x_park = printer['gcode_macro PRINTER_PARAM'].max_x_position|float %}
G90
G1 Z2 F600
G1 X{x_park} Y{y_park} F6000
G1 Z0.2 F600
[gcode_macro FIRST_FLOOR_RESUME]
description: Resume the first floor print
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro FIRST_FLOOR_PAUSE"].extrude|float + 1.0 %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G1 E{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
[gcode_macro FIRST_FLOOR_PAUSE]
description: Pause the first floor print
# change this if you need more or less extrusion
variable_extrude: 2.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro FIRST_FLOOR_PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set y_park = printer.toolhead.axis_maximum.y/2 %}
{% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
##### calculate save lift position #####
{% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set z_safe = 0.0 %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% elif act_z < max_z %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float}
PAUSE_BASE
G91
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-1.0 F180
G1 E-{E} F4000
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
G1 Z{z_safe} F600
G90
G1 X{x_park} Y{y_park} F30000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### 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 - 5.0 %}
# {% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
{% set x_park = 0 %}
{% set y_park = 220 %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < 48.0 %}
{% set z_safe = 50.0 - act_z %}
{% elif act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float}
##### end of definitions #####
PAUSE_BASE
G91
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE={printer.extruder.target}
M104 S140
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G1 Z{z_safe} F600
M400
G90
G1 X{x_park} Y{y_park} F6000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
{% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int != 0 %}
{% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int > printer.extruder.temperature %}
M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
{% else %}
M104 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
{% endif %}
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE=0
{% endif %}
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
{% set z_resume_move = printer['gcode_macro PRINTER_PARAM'].z_safe_pause|int %}
{% if z_resume_move > 2 %}
{% set z_resume_move = z_resume_move - 2 %}
G91
G1 Z-{z_resume_move} F600
M400
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G1 E{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
[gcode_macro PRINTER_PARAM]
variable_z_safe_g28: 5.0
variable_z_safe_pause: 2.0
variable_max_x_position: 220.0
variable_max_y_position: 220.0
variable_max_z_position: 240.0
variable_fans: 3
variable_auto_g29: 0
variable_default_bed_temp: 50
variable_default_extruder_temp: 240
variable_g28_extruder_temp: 140
variable_print_calibration: 0
variable_fan0_min: 140
variable_hotend_temp: 200
gcode:
[gcode_macro STRUCTURE_PARAM]
variable_bed_length: 220
variable_bed_width: 220
variable_bed_hight: 240
variable_laser_x_offset: 45.0
variable_laser_y_offset: -8.0
variable_laser_z_offset: 3.0
variable_cali_x_offset: 204.0
variable_cali_y_offset: 14.0
variable_cali_z_offset: 3.0
gcode:
[gcode_macro M900]
gcode:
{% if 'K' in params %}
{% if 'E' in params %}
SET_PRESSURE_ADVANCE EXTRUDER={params.E} ADVANCE={params.K}
{% else %}
SET_PRESSURE_ADVANCE ADVANCE={params.K}
{% endif %}
{% endif %}
[gcode_arcs]#打印圆
resolution: 1.0
[gcode_macro M204]
rename_existing: M204.1
gcode:
# {% if printer['gcode_macro Qmode'].flag|int == 0 %}
{% set get_params = "" %}
{% if 'S' in params|upper %}
{% set get_params = (get_params + ' ' + 'S' + params.S) %}
{% endif %}
{% if 'P' in params|upper %}
{% set get_params = (get_params + ' ' + 'P' + params.P) %}
{% endif %}
{% if 'T' in params|upper %}
{% set get_params = (get_params + ' ' + 'T' + params.T) %}
{% endif %}
M204.1 {get_params}
# {% endif %}
[gcode_macro M205]
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 G29]
gcode:
M204 S5000
G90
M104S0
M107
G28
BED_MESH_CALIBRATE
G1 X110Y110Z10
M140S0
CXSAVE_CONFIG
[gcode_macro INPUTSHAPER_X]
gcode:
M84
G90
G28
SHAPER_CALIBRATE AXIS=x
CXSAVE_CONFIG
[gcode_macro INPUTSHAPER_Y]
gcode:
M84
G90
G28
SHAPER_CALIBRATE AXIS=y
CXSAVE_CONFIG
[gcode_macro INPUTSHAPER]
gcode:
G90
{% if "xyz" not in printer.toolhead.homed_axes %}
G28
{% endif %}
{% if 'X' in params.AXES|upper %}
SHAPER_CALIBRATE AXIS=X
{% elif 'Y' in params.AXES|upper %}
SHAPER_CALIBRATE AXIS=Y
{% else %}
SHAPER_CALIBRATE
{% endif %}
CXSAVE_CONFIG
[gcode_macro AUTOTUNE_SHAPERS]
variable_autotune_shapers: 'mzv'
gcode:
[gcode_macro Z_OFFSET_TEST]
gcode:
G28
Z_OFFSET_CALIBRATION
CXSAVE_CONFIG
[gcode_macro Z_COMPENSATE_TEST]
gcode:
G28
CRTENSE_NOZZLE_CLEAR
Z_OFFSET_CALIBRATION
[gcode_macro ZZ_OFFSET_TEST]
gcode:
G28
Z_OFFSET_AUTO
CXSAVE_CONFIG
[gcode_macro M106]
gcode:
{% set fan = 0 %}
{% set value = 255 %}
{% if params.S is defined %}
{% set tmp = params.S|int %}
{% if tmp <= 255 %}
{% set value = tmp %}
{% endif %}
{% endif %}
{% if params.P is defined %}
{% if params.P|int == 0 %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + (255 - printer["gcode_macro PRINTER_PARAM"].fan0_min) / 255 * tmp %}
{% if tmp < 1 %}
{% set value = tmp %}
{% endif %}
SET_PIN PIN=fan0 VALUE={value}
{% endif %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + (255 - printer["gcode_macro PRINTER_PARAM"].fan0_min) / 255 * tmp %}
{% if tmp < 1 %}
{% set value = tmp %}
{% endif %}
SET_PIN PIN=fan0 VALUE={value}
{% endif %}
[gcode_macro M107]
gcode:
{% if params.P is defined %}
SET_PIN PIN=fan0 VALUE=0
{% else %}
SET_PIN PIN=fan0 VALUE=0
# SET_PIN PIN=fan2 VALUE=0
{% endif %}
[gcode_macro LOAD_MATERIAL]
gcode:
SAVE_GCODE_STATE NAME=myMoveState
M109 S{printer.custom_macro.default_extruder_temp}
G91
G1 E150 F180
RESTORE_GCODE_STATE NAME=myMoveState
[gcode_macro QUIT_MATERIAL]
gcode:
SAVE_GCODE_STATE NAME=myMoveState
M109 S{printer.custom_macro.default_extruder_temp}
G91
G1 E20 F180
G1 E-30 F180
G1 E-50 F2000
RESTORE_GCODE_STATE NAME=myMoveState
[gcode_macro M600]
gcode:
PAUSE
{% set act_e = printer.toolhead.position.e|float %}
G91
G1 E20 F180
G1 E-30 F180
G1 E-50 F2000
G90
G92 E{act_e}
[gcode_macro FINISH_INIT]
gcode:
{% set extruder = printer.configfile.settings['extruder'] %}
{% set printer = printer.configfile.settings['printer'] %}
SET_PRESSURE_ADVANCE ADVANCE={extruder.pressure_advance}
SET_VELOCITY_LIMIT ACCEL_TO_DECEL={printer.max_accel_to_decel}
#转角速度:5mm/s
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=5
#加速度:5000mm/s²
M204 S5000
#减速加速度:5000mm/s²
SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000
#移动速率:100%
M220 S100
#挤出流量:100%
M221 S100