-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmacros_nozzle_scrub.cfg
70 lines (60 loc) · 3.03 KB
/
macros_nozzle_scrub.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
## Rewritten from Hernsl & Edwardyeeks and incorporate zellenralex rewrite concepts
[gcode_macro clean_nozzle]
description: Move toolhead to bucket, purge and scrub the nozzle. Usage: CLEAN_NOZZLE [INDEX=index(current_filament_index)] [DOPURGE=1]
gcode:
{% set user = printer['gcode_macro _USER_VARIABLE'] %}
{% set pos = user.purge.purge %} # x,y,z location
{% set move_z = [user.z_hop, printer.toolhead.position.z]|max %} ; Calculate hoihg move from higher of current toolhead location or defined z_hop height (if mag probe stuff is defined)
{% set filament = printer.save_variables.variables.filament %}
{% set _idx = params.INDEX|default(filament.index)|int %}
{% set dopurge = params.DOPURGE|default(1)|int %}
_CG28 ; Home if not already homed (removes original error message)
LED_CLEANING
SAVE_GCODE_STATE NAME=clean_nozzle
SET_GCODE_OFFSET Z=0.0
RESPOND MSG="Cleaning"
G90 ; Absolute positioning
{% set leftright = range(2)|random|int %} ; Randomly pick which side bucket to use
G1 Z{move_z} F{user.speed.z_hop} ; Move head up for travel
{% if leftright == 0 %} ; Randomly picked left
G1 X{[user.purge.wipe.start.x, user.purge.wipe.end.x]|min - 5} Y{pos.y} F{user.speed.travel} # move over left purge bucket
{% else %} ; Randomly picked right
G1 X{[user.purge.wipe.start.x, user.purge.wipe.end.x]|max + 5} Y{pos.y} F{user.speed.travel} # move over right purge bucket
{% endif %}
# Heat up hotend to current filament melt temp if needed
{% if dopurge == 1 %}
{% if not printer.extruder.can_extrude or (printer['extruder'].temperature < filament.array[_idx].hotend) %}
{action_respond_info("Extruder temp too low. Heating to %3.1fC" % [printer.configfile.settings.extruder.min_extrude_temp,filament.array[filament.index].hotend]|max)}
LED_TOOLHEAD_HEATING
M109 S{[printer.configfile.settings.extruder.min_extrude_temp,filament.array[filament.index].hotend]|max}
LED_CLEANING
{% endif %}
{% endif %}
{% if dopurge == 1 %}
# Do the purge
G92 E0 ; Reset extruder
M83 ; Extruder to relative
G1 E{user.filament.retract.end * 1.5} F200
G1 E-{user.filament.retract.end} F{user.speed.retract}
G4 P500
G92 E0
{% endif %}
_WIPE ; Perform the wipe
RESPOND MSG="Cleaned!"
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1
RESTORE_GCODE_STATE NAME=clean_nozzle
LED_STANDBY
[gcode_macro _WIPE]
description: Helper: Wipe nozzle at bucket
gcode:
{% set user = printer['gcode_macro _USER_VARIABLE'] %}
{% set wipe = user.purge.wipe %} # x,y,z location
G90 # Absolute positioning
# Wipe nozzle
G0 X{wipe.start.x} Y{wipe.end.y} Z{wipe.start.z} F{user.speed.wipe}
{% for wipes in range(0, wipe.cnt) %}
{% for coordinate in wipe.start.x, wipe.end.x %}
G0 X{coordinate} Y{wipe.end.y}
{% endfor %}
{% endfor %}
G0 X{wipe.end.x} Y{wipe.end.y} Z{wipe.end.z}