-
Notifications
You must be signed in to change notification settings - Fork 4
/
wipepurge.cfg
78 lines (73 loc) · 3.33 KB
/
wipepurge.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
# Extra line here for no reason?
[gcode_macro DECONTAMINATE]
# Takes the following arguments:
# WIPE=x Number of times to wipe (defaults to zero)
# PURGE=x mm of filament to purge (defaults to zero)
# MOVE=x If non-zero, will always perform a move
variable_brush_start: 82
variable_brush_width: 40
variable_brush_depth: 2 # Amount *reachable* from max Y (must be integer)
variable_bucket_start: 6.0
variable_bucket_left_width: 92
variable_bucket_right_width: 40
variable_bucket_gap: 22.0
variable_brush_top: 1.5
variable_clearance_z: 5.0
variable_prep_spd_xy: 3000 # Travel (not cleaning) speed along x and y-axis in mm/min.
variable_prep_spd_z: 1500 # Travel (not cleaning) speed along z axis in mm/min.
variable_purge_spd: 150 # Speed, in mm/min, of the purge.
variable_purge_ret: 0.75 # Retract length, in mm, after purging to prevent
# slight oozing. Adjust as necessary.
variable_purge_temp_min: 220 # Minimum temperature for a purge.
variable_ooze_dwell: 10.0 # Dwell/wait time, in seconds, after purging and retracting.
variable_wipe_spd_xy: 5000 # Nozzle wipe speed in mm/min.
gcode:
{% set PURGE_LEN = params.PURGE|default(0)|float %}
{% set WIPE_COUNT = params.WIPE|default(0)|int %}
{% set DO_MOVE = params.MOVE|default(0)|int %}
{% set y_rear = printer.configfile.config["stepper_y"]["position_max"]|float %}
# Select a bucket randomly based on size (ie: more in the left bucket)
{% set bucket = range(bucket_left_width + bucket_right_width)|random %}
SAVE_GCODE_STATE NAME=DECONTAMINATE_STATE
M83 # relative extrusion mode
G90 # absolute position mode
# Move to clearance Z
G0 Z{brush_top + clearance_z} F{prep_spd_z}
# First, purge.
{% if PURGE_LEN > 0 %}
G0 Y{y_rear - brush_depth} F{prep_spd_xy}
{% if bucket < bucket_left_width %}
G0 X{bucket_start + (bucket_left_width / 2)} F{prep_spd_xy}
{% else %}
G0 X{bucket_start + bucket_left_width + bucket_gap + (bucket_right_width / 2)} F{prep_spd_xy}
{% endif %}
{% if printer.extruder.temperature >= purge_temp_min %}
G1 E{PURGE_LEN} F{purge_spd}
G1 E-{purge_ret} F{purge_spd * 5}
G4 P{ooze_dwell * 1000}
{% endif %}
{% endif %}
# Now wipe
# We want to start in a random direction and move to a random position
# on the other side of the brush.
{% if WIPE_COUNT > 0 %}
{% set off = range(0, 2)|random %}
G0 X{(brush_start + brush_width * (1 - off))} Y{y_rear - brush_depth} F{prep_spd_xy}
G0 Z{brush_top} F{prep_spd_z}
{% for wipes in range(0, WIPE_COUNT) %}
G0 X{brush_start + ((wipes + off) % 2) * brush_width} Y{y_rear - range(0, brush_depth)|random} F{wipe_spd_xy}
{% endfor %}
G0 Y{y_rear - brush_depth} F{prep_spd_xy}
{% endif %}
{% if DO_MOVE != 0 %}
ECHO DO_MOVE="{DO_MOVE}"
G0 Z{brush_top + clearance_z} F{prep_spd_z}
{% if bucket < bucket_left_width %}
G0 X{bucket_start + (bucket_left_width / 2)} Y{y_rear - brush_depth} F{prep_spd_xy}
{% else %}
G0 X{bucket_start + bucket_left_width + bucket_gap + (bucket_right_width / 2)} Y{y_rear - brush_depth} F{prep_spd_xy}
{% endif %}
RESTORE_GCODE_STATE NAME=DECONTAMINATE_STATE MOVE=0
{% else %}
RESTORE_GCODE_STATE NAME=DECONTAMINATE_STATE MOVE=1
{% endif %}