Skip to content

Commit 0a4490e

Browse files
committed
Add analogous feature for Prusa-firmware's M862.1
1 parent b82f53f commit 0a4490e

1 file changed

Lines changed: 34 additions & 21 deletions

File tree

macros.cfg

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ gcode:
1212
{% for var, value in printer["gcode_macro RatOS"].items() %}
1313
{action_respond_info(var ~ ": " ~ value)}
1414
{% endfor %}
15-
15+
1616
[gcode_macro RatOS]
1717
description: RatOS variable storage macro, will echo variables to the console when run.
1818
# Configuration Defaults
@@ -90,7 +90,7 @@ rename_existing: PAUSE_BASE
9090
variable_extrude: 1.5
9191
gcode:
9292
SAVE_GCODE_STATE NAME=PAUSE_state
93-
# Define park positions
93+
# Define park positions
9494
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
9595
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
9696
# Calculate safe Z position
@@ -115,7 +115,7 @@ gcode:
115115
_PARK LOCATION={printer["gcode_macro RatOS"].pause_print_park_in} X={printer["gcode_macro RatOS"].pause_print_park_x}
116116
{% else %}
117117
{action_respond_info("Printer not homed")}
118-
{% endif %}
118+
{% endif %}
119119

120120
[gcode_macro RESUME]
121121
description: Resumes the print if the printer is paused.
@@ -149,7 +149,7 @@ gcode:
149149
SAVE_GCODE_STATE NAME=prime_line_state
150150
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
151151
# Absolute positioning
152-
G90
152+
G90
153153
# Absolute extrusion
154154
M82
155155
M117 Priming nozzle with prime line..
@@ -162,7 +162,7 @@ gcode:
162162
G1 Z0.3 F3000
163163
# Reset extrusion distance
164164
G92 E0
165-
# Prime nozzle
165+
# Prime nozzle
166166
G1 Y{printer.toolhead.axis_minimum.y + 80} E16 F1200
167167
# Wipe
168168
G1 Y{printer.toolhead.axis_minimum.y + 100} F{speed}
@@ -176,7 +176,7 @@ gcode:
176176
RESPOND MSG="Priming nozzle with prime blob.."
177177
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
178178
# Absolute positioning
179-
G90
179+
G90
180180
# Relative extrusion
181181
M83
182182
# Lift 5 mm
@@ -186,11 +186,11 @@ gcode:
186186
# Extrude a blob
187187
G1 F60 E20
188188
# 40% fan
189-
M106 S102
189+
M106 S102
190190
# Move the extruder up by 5mm while extruding, breaks away from blob
191-
G1 Z5 F100 E5
191+
G1 Z5 F100 E5
192192
# Move to wipe position, but keep extruding so the wipe is attached to blob
193-
G1 F200 Y{printer.toolhead.axis_minimum.y + 25} E1
193+
G1 F200 Y{printer.toolhead.axis_minimum.y + 25} E1
194194
# Go down diagonally while extruding
195195
# Broken down in z moves under 2mm as a workaround for a tuning tower test.
196196
# The tuning tower command thinks a new print has been started when z moves over 2mm and aborts.
@@ -201,12 +201,12 @@ gcode:
201201
# 0% fan
202202
M106 S0
203203
# small wipe line
204-
G1 F200 Y{printer.toolhead.axis_minimum.y +50} Z0.2 E0.6
204+
G1 F200 Y{printer.toolhead.axis_minimum.y +50} Z0.2 E0.6
205205
# Break away wipe
206206
G1 F{speed} Y{printer.toolhead.axis_minimum.y + 100}
207207
RESTORE_GCODE_STATE NAME=prime_blob_state
208208

209-
209+
210210
[gcode_macro _PARK]
211211
gcode:
212212
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
@@ -230,9 +230,18 @@ gcode:
230230
{% set y = printer.toolhead.axis_maximum.y / 2 %}
231231
{% endif %}
232232
# Absolute positioning
233-
G90
233+
G90
234234
# Park
235-
G0 X{safe_x} Y{y} F{speed}
235+
G0 X{safe_x} Y{y} F{speed}
236+
237+
[gcode_macro ASSERT_NOZZLE_DIAMETER]
238+
gcode:
239+
{% set expected_diameter = params.NOZZLE_DIAMETER|float %}
240+
{% set actual_diameter = printer.configfile.config.extruder.nozzle_diameter|float %}
241+
{% if expected_diameter != actual_diameter %}
242+
M117 Aborting print due to nozzle-diameter mismatch between printer config and slicer.
243+
{ action_raise_error("Nozzle-diameter mismatch between printer config (%s mm) and slicer (%s mm)." % (expected_diameter, actual_diameter)) }
244+
{% endif %}
236245

237246
#####
238247
# COLOR CHANGE
@@ -261,15 +270,15 @@ gcode:
261270
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={params.TEMP|default(220, true)}
262271
{% endif %}
263272
M117 Unloading filament...
264-
# Extract filament to cold end area
273+
# Extract filament to cold end area
265274
G0 E-5 F3600
266275
# Wait for three seconds
267276
G4 P3000
268-
# Push back the filament to smash any stringing
277+
# Push back the filament to smash any stringing
269278
G0 E5 F3600
270-
# Extract back fast in to the cold zone
279+
# Extract back fast in to the cold zone
271280
G0 E-15 F3600
272-
# Continue extraction slowly, allow the filament time to cool solid before it reaches the gears
281+
# Continue extraction slowly, allow the filament time to cool solid before it reaches the gears
273282
G0 E-130 F300
274283
M117 Filament unloaded!
275284
RESPOND MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
@@ -306,7 +315,7 @@ gcode:
306315

307316
#####
308317
# START PRINT MACROS
309-
# Call this from your slicer (custom g-code).
318+
# Call this from your slicer (custom g-code).
310319
# Read more here: https://rat-rig.github.io/V-CoreOS/#/slicers
311320
#####
312321

@@ -318,11 +327,15 @@ gcode:
318327
# Metric values
319328
G21
320329
# Absolute positioning
321-
G90
330+
G90
322331
# Set extruder to absolute mode
323332
M82
324333
# Home if needed
325334
MAYBE_HOME
335+
# Check nozzle if told to do so
336+
{% if params.NOZZLE_DIAMETER %}
337+
ASSERT_NOZZLE_DIAMETER NOZZLE_DIAMETER={params.NOZZLE_DIAMETER}
338+
{% endif %}
326339
M117 Heating bed...
327340
RESPOND MSG="Heating bed..."
328341
# Wait for bed to heat up
@@ -360,7 +373,7 @@ gcode:
360373
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
361374
M117 Pre-heating extruder...
362375
RESPOND MSG="Pre-heating extruder..."
363-
# Wait for extruder to reach 150 so an inductive probe (if present) is at a predictable temp.
376+
# Wait for extruder to reach 150 so an inductive probe (if present) is at a predictable temp.
364377
# Also allows the bed heat to spread a little, and softens any plastic that might be stuck to the nozzle.
365378
M104 S150
366379
TEMPERATURE_WAIT SENSOR=extruder MINIMUM=150
@@ -393,7 +406,7 @@ gcode:
393406

394407
#####
395408
# END PRINT MACROS
396-
# Call this from your slicer (custom g-code).
409+
# Call this from your slicer (custom g-code).
397410
# Read more here: https://rat-rig.github.io/V-CoreOS/#/slicers
398411
#####
399412

0 commit comments

Comments
 (0)