-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.cfg
326 lines (285 loc) · 10.3 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
[gcode_macro PRINT_START]
gcode:
#{% set user = printer['gcode_macro _USER_VARIABLE'] %}
# This part fetches data from your slicer. Such as bed temp, extruder temp, chamber temp and size of your printer.
{% set target_bed = params.BED|int %}
{% set target_extruder = params.EXTRUDER|int %}
{% set target_chamber = params.CHAMBER|default(0)|int %}
{% set filament_type = params.FILAMENT|default(ASA)|string %}
{% set nozzle_size = params.NOZZLE|default(0.4)|float %}
{% set x_wait = printer.toolhead.axis_maximum.x|float / 2 %}
{% set y_wait = printer.toolhead.axis_maximum.y|float / 2 %}
# {% if user.hw.caselight.ena %} _CASELIGHT_ON {% endif %} ; switch on light
RESPOND TYPE=command MSG="PRINT_START :: BED: {target_bed}, EXTRUDER: {target_extruder}, CHAMBER: {target_chamber}, FILAMENT: {filament_type}, NOZZLE: {nozzle_size}"
# Homes the printer, sets absolute positioning.
G28 # Full home (XYZ)
G90 # Absolut position
BED_MESH_CLEAR # Clears old saved bed mesh (if any)
M117 Heating Bed: {target_bed}c
G1 X{x_wait} Y{y_wait} Z15 F9000 # Goes to center of the bed
M190 S{target_bed} # Sets the target temp for the bed
M117 Bed heating for 1 minute
G4 P60000 # Waits 1 min for the bedtemp to stabilize
# Heating nozzle to 150 degrees. This helps with getting a correct Z-home
M117 Hotend: 150c
M109 S150 # Heats the nozzle to 150c
M117 Generating Bed Mesh
BED_MESH_CALIBRATE # Starts bed mesh
# Heats up the nozzle up to target via data from slicer
M117 "Heating Hotend: {target_extruder}c" # Displays info
G1 X{x_wait} Y{y_wait} Z15 F9000 # Goes to center of the bed
M107 # Turns off partcooling fan
M109 S{target_extruder} # Heats the nozzle to printing temp
LINE_PURGE # KAMP adaptive purge, used with adaptive bed mesh
G92 E0 # Reset extruder
M117 Print in progress
# UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1
[gcode_macro PRINT_END]
# Use PRINT_END for the slicer ending script - please customise for your slicer of choice
gcode:
# {% set user = printer['gcode_macro _USER_VARIABLE'] %}
# safe anti-stringing move coords
{% 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 + 2, th.axis_maximum.z]|min %}
SAVE_GCODE_STATE NAME=STATE_PRINT_END
M400 ; wait for buffer to clear
G92 E0 ; zero the extruder
G1 E-2.0 F3600 ; retract filament
TURN_OFF_HEATERS
G90 # absolute positioning
G0 X{x_safe} Y{y_safe} Z{z_safe} F720 # move nozzle to remove stringing
G1 X0 Y200 F2600 ; park
M107 # turn off fan
#M84 # disable motors
# {% if user.hw.caselight.ena %} _CASELIGHT_OFF {% endif %}
BED_MESH_CLEAR
RESTORE_GCODE_STATE NAME=STATE_PRINT_END
M117
#[gcode_macro TURN_OFF_HEATERS]
#gcode:
# M104 S0 # turn off temperature
# M140 S0 # turn off heatbed
[gcode_macro M486]
gcode:
CLEAR_PAUSE
[gcode_macro G80]
gcode:
M117 Bed leveling
BED_MESH_CALIBRATE
G1 X0 Y0 Z0.4 F4000
M117
M400
[gcode_macro G81]
gcode:
BED_MESH_OUTPUT
[gcode_macro M300]
gcode:
# Use a default 1kHz tone if S is omitted.
{% set S = params.S|default(1000)|int %}
# Use a 10ms duration is P is omitted.
{% set P = params.P|default(100)|int %}
SET_PIN PIN=BEEPER_pin VALUE=0.5 CYCLE_TIME={ 1.0/S if S > 0 else 1 }
G4 P{P}
SET_PIN PIN=BEEPER_pin VALUE=0
[gcode_macro UNLOAD_FILAMENT]
gcode:
SAVE_GCODE_STATE NAME=unload_state
G91
{% if params.TEMP is defined or printer.extruder.can_extrude|lower == 'false' %}
M117 Heating...
# Heat up hotend to provided temp or 220 as default as that should work OK with most filaments.
M109 S{params.TEMP|default(220, true)}
{% endif %}
M117 Unloading filament...
G92 E0.0
G91
G1 E-45 F5000
G1 E-15 F1000
G1 E-20 F1000
G90
G92 E0.0
M400
M117 Remove Filament Now!
M300 S300 P1000
M117 Filament unloaded!
# clear the active spool from spoolman
CLEAR_ACTIVE_SPOOL
RESTORE_GCODE_STATE NAME=unload_state
[gcode_macro LOAD_FILAMENT]
gcode:
SAVE_GCODE_STATE NAME=load_state
G91
# Heat up hotend to provided temp or 220 as default as that should work OK with most filaments.
{% if params.TEMP is defined or printer.extruder.can_extrude|lower == 'false' %}
M117 Heating...
M109 S{params.TEMP|default(220, true)}
{% endif %}
M117 Loading filament...
# Load the filament into the hotend area.
G92 E0.0
G91
G1 E70 F400
G1 E40 F100
G90
G92 E0.0
M400
M117 Filament loaded!
RESTORE_GCODE_STATE NAME=load_state
## Clear display output after Duration in seconds
## Use: UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1
[delayed_gcode _CLEAR_DISPLAY]
gcode:
M117
[pause_resume]
[display_status]
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
variable_park: True
gcode:
## Move head and retract only if not already in the pause state and park set to true
{% if printer.pause_resume.is_paused|lower == 'false' and park|lower == 'true'%}
_TOOLHEAD_PARK_PAUSE_CANCEL
{% else %}
# Raise nozzle by 60mm
G91
G0 Z60 F200
G90
{% endif %}
TURN_OFF_HEATERS
CLEAR_PAUSE
SDCARD_RESET_FILE
# Disable steppers
# M84
CANCEL_PRINT_BASE
M117
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
gcode:
PAUSE_BASE
_TOOLHEAD_PARK_PAUSE_CANCEL
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
##### read extrude from _TOOLHEAD_PARK_PAUSE_CANCEL macro #####
{% set extrude = printer['gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL'].extrude %}
#### 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' %}
M83
G1 E{extrude} F2100
{% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %}
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
CLEAR_PAUSE
[gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL]
description: Helper: park toolhead used in PAUSE and CANCEL_PRINT
variable_extrude: 1.0
gcode:
##### 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 z_park_delta = 2.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 - z_park_delta) %}
{% set z_safe = z_park_delta %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
M83
G1 E-{extrude} F2100
{% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %}
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000
{% if printer.gcode_move.absolute_coordinates|lower == 'false' %} G91 {% endif %}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
# Prusa's calibrate Z
[gcode_macro Calibrate_Z]
description: Calibrate Z axis
gcode:
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
G1 X20 Y0
G1 Z{max_z-10} F2000 #Update with Z height.
FORCE_MOVE STEPPER=stepper_z Distance=20 Velocity=10
G1 Z{max_z-50} F2000 # Move down
G28 # Home again
[gcode_macro PREHEAT_PLA]
gcode:
# Start bed heating
M140 S60
# Start nozzle heating
M104 S200
[gcode_macro PREHEAT_PETG]
gcode:
# Start bed heating
M140 S90
# Start nozzle heating
M104 S240
[gcode_macro PREHEAT_TPU]
gcode:
# Start bed heating
M140 S50
# Start nozzle heating
M104 S190
# Color Change
[gcode_macro M600]
description: Color change
gcode:
{% set X = params.X|default(0)|float %}
{% set Y = params.Y|default(0)|float %}
{% set Z = params.Z|default(10)|float %}
SAVE_GCODE_STATE NAME=M600_state
PAUSE
G91
G1 E-.8 F2700
G1 Z{Z}
G90
G1 X{X} Y{Y} F3000
G91
G1 E-50 F1000
RESTORE_GCODE_STATE NAME=M600_state
[gcode_macro M204]
description: Set and limit acceleration to cfg value
rename_existing: M204.1
gcode:
{% set accel = params.S|float if 'S' in params and params.S|float > 0
else [params.P|float,params.T|float]|min if 'P' in params and 'T' in params and
params.P|float > 0 and params.T|float > 0 %}
{% if accel is defined %}
{% set lim_accel = [accel, printer.configfile.settings.printer.max_accel ]|min %}
{% set lim_accel_to_decel = [accel / 2, printer.configfile.settings.printer.max_accel_to_decel]|min %}
SET_VELOCITY_LIMIT ACCEL={lim_accel} ACCEL_TO_DECEL={lim_accel_to_decel}
{% else %}
{action_respond_info("Invalid M204 command \"M204 %s\"" % rawparams)}
{% endif %}
[gcode_macro M900]
description: Set pressure advance
gcode:
# SET_PRESSURE_ADVANCE ADVANCE={params.K|default(0)}