-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.cfg
289 lines (255 loc) · 10.1 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
[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 %}
##### 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 - 2.0) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
PAUSE_BASE
G91
{% 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} F900
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:
##### 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 %}
##### 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 CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
TURN_OFF_HEATERS
CANCEL_PRINT_BASE
M83 ;set relative extrusion
G92 E0 ;reset extrusion amount
M204 S10000 ;set max acceleration
G1 E-2 F4000 ;retract 2mm
M204 S3000 ;set max acceleration
G91 ;set relative extrusion
G1 Z30 F1000 ;move Z axis up 30mm
G1 X0 Y200 F24000 ;park tool at back of printer
M107
M84 ;disable motors
M117 Canceled.
# load filament
[gcode_macro LOAD_FILAMENT]
description: Load in filament
gcode:
SAVE_GCODE_STATE NAME=loading_filament
M117 Loading Filament
M83
G92 E0.0
LOW_TEMP_CHECK
G1 E420 F6000 # length of bowden tube till cold-end (~420mm)
G1 E100 F200 # some extra to prime the nozzle --> slower
G92 E0.0
RESTORE_GCODE_STATE NAME=loading_filament
# unload filament
[gcode_macro UNLOAD_FILAMENT]
description: Unload filament
gcode:
SAVE_GCODE_STATE NAME=unloading_filament
M125 # park
M117 Unloading Filament
LOW_TEMP_CHECK
G91 # set relative
G1 E10 F100
G92 E0.0
G1 E-530 F6000 # the E is the length of the bowden tube (420mm) + 100 mm.
G92 E0.0
RESTORE_GCODE_STATE NAME=unloading_filament
# filament change
[gcode_macro CHANGE_FILAMENT]
description: Filament change.
gcode:
M117 Filament Change
M118 Filament Change
SAVE_GCODE_STATE NAME=filament_change
PAUSE
LOW_TEMP_CHECK
G91 # relative
G1 E-1 F300 # retract 1
M125 # park
M702 # unload
M117 New filament
M118 New filament
COUNTDOWN TIME=25 MSG="Switch"
M701
COUNTDOWN TIME=10 MSG="Clean"
RESUME
M117 Resuming
M118 Resuming
RESTORE_GCODE_STATE NAME=filament_change
M117 Printing..
M118 Printing..
[gcode_macro THE_END]
gcode:
TURN_OFF_HEATERS ;turn off heaters...
SAVE_GCODE_STATE NAME=END_state
M83 ;set relative extrusion
G92 E0 ;reset extrusion amount
M204 S10000 ;set max acceleration
G1 E-6 F4000 ;retract 6mm
M204 S3000 ;set max acceleration
;move the toolhead out of the way
;if the tool is less than 30mm away from Z Max, move it to Z max, otherwise, move Z up 30mm
;Obtain the Z axis limit from the [stepper_z] section of the config file and make
; a decision where to move the Z axis based on the current toolhead
{% if printer.toolhead.position.z|float + 30 >= printer.configfile.config["stepper_z"]["position_max"]|float %}
G90 ;set absolute extrusion
G1 Z{printer.configfile.config["stepper_z"]["position_max"]|float} F1000 ;Move tool
{% else %}
G91 ;set relative extrusion
G1 Z30 F1000 ;move Z axis up 30mm
{% endif %}
RESTORE_GCODE_STATE NAME=END_state
G1 X0 Y200 F24000 ;park tool at back of printer
M107
#UNLOAD_FILAMENT ;this is a good spot to call an unload
;filament macro, if you are into that sort of thing
SET_GCODE_OFFSET Z=0 ;reset whatever babystepping you have done
M84 ;disable motors
CLEAR_PAUSE ;clear whatever PAUSE state you may have if you have it
M117 Done.
[gcode_macro SAVE_Z_OFFSET]
gcode:
Z_OFFSET_APPLY_PROBE
[gcode_macro BED_MESH_CALIBRATE]
rename_existing: BED_MESH_CALIBRATE_BASE
; gcode parameters
variable_parameter_AREA_START: 0,0
variable_parameter_AREA_END: 0,0
; the clearance between print area and probe area
variable_mesh_area_offset: 5.0
; number of sample per probe point
variable_probe_samples: 2
; minimum and maximum probe count
variable_min_probe_count: 3
; scale up the probe count, the vlaue should be 1.0 ~ < max/min probe count
variable_probe_count_scale_factor: 1.0
gcode:
{% if params.AREA_START and params.AREA_END %}
{% set bedMeshConfig = printer["configfile"].config["bed_mesh"] %}
{% set safe_min_x = bedMeshConfig.mesh_min.split(",")[0]|float %}
{% set safe_min_y = bedMeshConfig.mesh_min.split(",")[1]|float %}
{% set safe_max_x = bedMeshConfig.mesh_max.split(",")[0]|float %}
{% set safe_max_y = bedMeshConfig.mesh_max.split(",")[1]|float %}
{% set area_min_x = params.AREA_START.split(",")[0]|float %}
{% set area_min_y = params.AREA_START.split(",")[1]|float %}
{% set area_max_x = params.AREA_END.split(",")[0]|float %}
{% set area_max_y = params.AREA_END.split(",")[1]|float %}
{% set meshPointX = bedMeshConfig.probe_count.split(",")[0]|int %}
{% set meshPointY = bedMeshConfig.probe_count.split(",")[1]|int %}
{% set meshMaxPointX = meshPointX %}
{% set meshMaxPointY = meshPointY %}
{% if (area_min_x < area_max_x) and (area_min_y < area_max_y) %}
{% if area_min_x - mesh_area_offset >= safe_min_x %}
{% set area_min_x = area_min_x - mesh_area_offset %}
{% else %}
{% set area_min_x = safe_min_x %}
{% endif %}
{% if area_min_y - mesh_area_offset >= safe_min_y %}
{% set area_min_y = area_min_y - mesh_area_offset %}
{% else %}
{% set area_min_y = safe_min_y %}
{% endif %}
{% if area_max_x + mesh_area_offset <= safe_max_x %}
{% set area_max_x = area_max_x + mesh_area_offset %}
{% else %}
{% set area_max_x = safe_max_x %}
{% endif %}
{% if area_max_y + mesh_area_offset <= safe_max_y %}
{% set area_max_y = area_max_y + mesh_area_offset %}
{% else %}
{% set area_max_y = safe_max_y %}
{% endif %}
#PRINT MSG="Set custom mesh area to ({area_min_x},{area_min_y}),({area_max_x},{area_max_y})" OUTPUT_TARGET=1
{% set meshPointX = (meshPointX * (area_max_x - area_min_x) / (safe_max_x - safe_min_x) * probe_count_scale_factor|float)|round(0)|int %}
{% if meshPointX < min_probe_count %}
{% set meshPointX = min_probe_count %}
{% endif %}
{% if meshPointX > meshMaxPointX %}
{% set meshPointX = meshMaxPointX %}
{% endif %}
{% set meshPointY = (meshPointY * (area_max_y -area_min_y ) / (safe_max_y - safe_min_y) * probe_count_scale_factor|float)|round(0)|int %}
{% if meshPointY < min_probe_count %}
{% set meshPointY = min_probe_count %}
{% endif %}
{% if meshPointY > meshMaxPointY %}
{% set meshPointY = meshMaxPointY %}
{% endif %}
#PRINT MSG="Set custom mesh matrix to {meshPointX}x{meshPointY}" OUTPUT_TARGET=1
#PRINT MSG="Mesh: {meshPointX}x{meshPointY}" OUTPUT_TARGET=2
BED_MESH_CALIBRATE_BASE mesh_min={area_min_x},{area_min_y} mesh_max={area_max_x},{area_max_y} probe_count={meshPointX},{meshPointY} samples={probe_samples|int}
{% else %}
#PRINT MSG="Invalid custom mesh parameters, probe using default setting" OUTPUT_TARGET=1
#PRINT MSG="Mesh: default" OUTPUT_TARGET=2
BED_MESH_CALIBRATE_BASE
{% endif %}
{% else %}
#PRINT MSG="Invalid custom mesh parameters, probe using default setting" OUTPUT_TARGET=1
#PRINT MSG="Mesh: default" OUTPUT_TARGET=2
BED_MESH_CALIBRATE_BASE
{% endif %}
# START_PRINT EXTRUDER_TEMP=[first_layer_temperature] BED_TEMP=[first_layer_bed_temperature] AREA_START={first_layer_print_min[0]},{first_layer_print_min[1]} AREA_END={first_layer_print_max[0]},{first_layer_print_max[1]}
[gcode_macro START_PRINT]
variable_parameter_EXTRUDER_TEMP: 190
variable_parameter_BED_TEMP: 60
; gcode parameters for area bed mesh
variable_parameter_AREA_START : 0,0
variable_parameter_AREA_END : 0,0
gcode:
# preheat temp
M104 S170
M140 S{params.BED_TEMP|default(70)|float}
M117 Homing XY...
G28 X Y ; home xy axis
M190 S{params.BED_TEMP|default(70)|float}
M117 Waiting for temperature
M117 Homing Z...
G28 Z ;home Z
#BED_MESH_CALIBRATE
BED_MESH_CALIBRATE AREA_START={params.AREA_START|default("0,0")} AREA_END={params.AREA_END|default("0,0")}
G0 X0 Y0 Z10 F6000
M117 Waiting for temperature
M109 S{params.EXTRUDER_TEMP|default(220)|float}
M117 {printer.print_stats.filename}