forked from Rat-OS/RatOS-configuration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.cfg
355 lines (326 loc) · 10.2 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
# WARNING: DO NOT EDIT OR INCLUDE THIS FILE. THIS IS A TEMPLATE.
# To change your macros, check the root macros.cfg file.
#####
# CONFIGURATION VARIABLES
#####
[gcode_macro ECHO_RATOS_VARS]
gcode:
{% for var, value in printer["gcode_macro RatOS"].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[gcode_macro RatOS]
# Configuration Defaults
# This is only here to make the config backwards compatible.
# Configuration should exclusively happen in printer.cfg.
variable_relative_extrusion: False
variable_preheat_extruder: True
variable_calibrate_bed_mesh: True
variable_nozzle_priming: "primeline"
variable_start_print_park_in: "back"
variable_start_print_park_z_height: 50
variable_end_print_park_in: "back"
variable_end_print_relative_z: 0
variable_pause_print_park_in: "back"
variable_macro_travel_speed: 150
gcode:
ECHO_RATOS_VARS
#####
# GENERAL MACROS
#####
[gcode_macro PAUSE]
rename_existing: PAUSE_BASE
variable_extrude: 1.5
gcode:
SAVE_GCODE_STATE NAME=PAUSE_state
# Define park positions
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
# Calculate safe Z 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 %}
PAUSE_BASE
G91
# Retract
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
# Move to park position
{% if "xyz" in printer.toolhead.homed_axes %}
G1 Z{z_safe} F900
_PARK LOCATION={printer["gcode_macro RatOS"].pause_print_park_in} X={printer["gcode_macro RatOS"].pause_print_park_x}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[gcode_macro RESUME]
rename_existing: RESUME_BASE
gcode:
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
# Prime
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G1 E{E} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
RESUME_BASE
[gcode_macro CANCEL_PRINT]
rename_existing: CANCEL_PRINT_BASE
gcode:
END_PRINT
TURN_OFF_HEATERS
CLEAR_PAUSE
#SDCARD_RESET_FILE
CANCEL_PRINT_BASE
[gcode_macro PRIME_LINE]
gcode:
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
# Absolute positioning
G90
# Absolute extrusion
M82
M117 Priming nozzle...
# Lift 5 mm
G1 Z5 F3000
# Move to prime area
G1 X{printer.toolhead.axis_minimum.x + 5} Y{printer.toolhead.axis_minimum.y + 10} F{speed}
# Get ready to prime
G1 Z0.3 F3000
# Reset extrusion distance
G92 E0
# Prime nozzle
G1 Y{printer.toolhead.axis_minimum.y + 80} E16 F1200
# Wipe
G1 Y{printer.toolhead.axis_minimum.y + 100} F{speed}
# Reset extrusion
G92 E0
[gcode_macro _PARK]
gcode:
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
# Get X position
{% if params.X != '' %}
{% if params.X|float >= printer.toolhead.axis_minimum.x + 5 and params.X|float <= printer.toolhead.axis_maximum.x - 5 %}
{% set safe_x = params.X|float %}
{% else %}
{action_respond_info('The requested X co-ordinate is outside the defined axis bounds - using defaults')}
{% set safe_x = printer.toolhead.axis_maximum.x / 2 %}
{% endif %}
{% else %}
{% set safe_x = printer.toolhead.axis_maximum.x / 2 %}
{% endif %}
# Get Y position
{% if params.LOCATION|default('back')|lower == 'back' %}
{% set y = printer.toolhead.axis_maximum.y - 5 %}
{% elif params.LOCATION|lower == 'front' %}
{% set y = printer.toolhead.axis_minimum.y + 5 %}
{% elif params.LOCATION|lower == 'center' %}
{% set y = printer.toolhead.axis_maximum.y / 2 %}
{% endif %}
# Absolute positioning
G90
# Park
G0 X{safe_x} Y{y} F{speed}
#####
# COLOR CHANGE
#####
[gcode_macro M600]
gcode:
PAUSE
UNLOAD_FILAMENT
M117 Please load new filament and resume
#####
# FILAMENT MANAGEMENT
#####
[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.
M104 S{params.TEMP|default(220, true)}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={params.TEMP|default(220, true)}
{% endif %}
M117 Unloading filament...
# Extract filament to cold end area
G0 E-5 F3600
# Wait for three seconds
G4 P3000
# Push back the filament to smash any stringing
G0 E5 F3600
# Extract back fast in to the cold zone
G0 E-15 F3600
# Continue extraction slowly, allow the filament time to cool solid before it reaches the gears
G0 E-130 F300
M117 Filament unloaded!
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...
M104 S{params.TEMP|default(220, true)}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={params.TEMP|default(220, true)}
{% endif %}
M117 Loading filament...
# Load the filament into the hotend area.
G0 E100 F600
# Wait a secod
G4 P1000
# Purge
G0 E40 F100
# Wait for purge to complete
M400e
M117 Filament loaded!
RESTORE_GCODE_STATE NAME=load_state
[gcode_macro SET_CENTER_KINEMATIC_POSITION]
gcode:
SET_KINEMATIC_POSITION X={printer.toolhead.axis_maximum.x / 2} Y={printer.toolhead.axis_maximum.y / 2} Z={printer.toolhead.axis_maximum.z / 2}
#####
# START PRINT MACROS
# Call this from your slicer (custom g-code).
# Read more here: https://rat-rig.github.io/V-CoreOS/#/slicers
#####
[gcode_macro START_PRINT]
gcode:
CLEAR_PAUSE
SAVE_GCODE_STATE NAME=start_print_state
# Metric values
G21
# Absolute positioning
G90
# Set extruder to absolute mode
M82
# Home
G28
M117 Heating bed...
# Wait for bed to heat up
M190 S{params.BED_TEMP|default(printer.heater_bed.target, true) }
# Run the customizable "AFTER_HEATING_BED" macro.
_START_PRINT_AFTER_HEATING_BED
# Run the customizable "BED_MESH" macro
_START_PRINT_BED_MESH
# Start heating extruder
M104 S{params.EXTRUDER_TEMP|default(printer.extruder.target, true) }
# Run the customizable "PARK" macro
_START_PRINT_PARK
# Wait for extruder to heat up
M117 Heating extruder...
M109 S{params.EXTRUDER_TEMP|default(printer.extruder.target, true) }
# Run the customizable "AFTER_HEATING_EXTRUDER" macro.
_START_PRINT_AFTER_HEATING_EXTRUDER
M117 Printing...
RESTORE_GCODE_STATE NAME=start_print_state
# Set extrusion mode based on user configuration
{% if printer["gcode_macro RatOS"].relative_extrusion|lower == 'true' %}
M83
{% else %}
M82
{% endif %}
G92 E0
#####
# START PRINT MACRO HOOKS
# You can copy these to printer.cfg and modify them to your liking, or just use them as is.
####
[gcode_macro _START_PRINT_AFTER_HEATING_BED]
gcode:
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
M117 Pre-heating extruder...
# Wait for extruder to reach 150 so an inductive probe (if present) is at a predictable temp.
# Also allows the bed heat to spread a little, and softens any plastic that might be stuck to the nozzle.
M104 S150
TEMPERATURE_WAIT SENSOR=extruder MINIMUM=150
{% endif %}
[gcode_macro _START_PRINT_BED_MESH]
gcode:
{% if printer["gcode_macro RatOS"].calibrate_bed_mesh|lower == 'true' %}
BED_MESH_CALIBRATE PROFILE=ratos
{% endif %}
BED_MESH_PROFILE LOAD=ratos
[gcode_macro _START_PRINT_PARK]
gcode:
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
_PARK LOCATION={printer["gcode_macro RatOS"].start_print_park_in} X={printer["gcode_macro RatOS"].start_print_park_x}
G0 Z{z} F6000
[gcode_macro _START_PRINT_AFTER_HEATING_EXTRUDER]
gcode:
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
PRIME_LINE
{% endif %}
{% if printer["gcode_macro RatOS"].skew_profile is defined %}
SKEW_PROFILE LOAD={printer["gcode_macro RatOS"].skew_profile}
{% endif %}
#####
# END PRINT MACROS
# Call this from your slicer (custom g-code).
# Read more here: https://rat-rig.github.io/V-CoreOS/#/slicers
#####
# The end_print macro is also called from CANCEL_PRINT.
[gcode_macro END_PRINT]
gcode:
SAVE_GCODE_STATE NAME=end_print_state
# Extruder heater off
M104 S0
# Bed heater off
M140 S0
_END_PRINT_AFTER_HEATERS_OFF
_END_PRINT_PARK
# Clear skew profile if any was loaded.
{% if printer["gcode_macro RatOS"].skew_profile is defined %}
SET_SKEW CLEAR=1
{% endif %}
# Steppers off
M84
# Part cooling fan off
M107
M117 Done.
RESTORE_GCODE_STATE NAME=end_print_state
#####
# END PRINT MACRO HOOKS
# You can copy these to printer.cfg and modify them to your liking, or just use them as is.
####
[gcode_macro _END_PRINT_AFTER_HEATERS_OFF]
gcode:
# Calculate safe Z 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 %}
# Relative positioning
G91
# Retract the filament a bit before lifting the nozzle.
G1 E-2 F3600
# Move to safe Z position
G0 Z{z_safe} F3600
# Retract filament even more
G1 E-2 F3600
[gcode_macro _END_PRINT_PARK]
gcode:
_PARK LOCATION={printer["gcode_macro RatOS"].end_print_park_in} X={printer["gcode_macro RatOS"].end_print_park_x}
SAVE_GCODE_STATE NAME=end_print_drop
# Calculate safe Z move
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - printer["gcode_macro RatOS"].end_print_relative_z|float) %}
{% set z_move = printer["gcode_macro RatOS"].end_print_relative_z|float %}
{% else %}
{% set z_move = max_z - act_z %}
{% endif %}
# Relative positioning
G91
#
G1 Z{z_move} F3600
RESTORE_GCODE_STATE NAME=end_print_drop