Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ variable_bucket_gap: 22
# installation of purge bucket at rear left.
variable_bucket_start: 0

# Which bucket should the purge be done? -1 = random, 0 = left, 1 = right
variable_bucket_purge: -1

# Which bucket should we park the nozzle at the end of purge? 0 = left, 1 = right
variable_bucket_park: 0


###############################################################################################################################################
###############################################################################################################################################
Expand All @@ -138,9 +144,6 @@ variable_bucket_start: 0
###############################################################################################################################################
###############################################################################################################################################

# Placeholder. The variable will later be set to contain, at random, a number representing the left or right bucket.
variable_bucket_pos: 1

gcode:
# First, check if the axes are homed.
{% if "xyz" in printer.toolhead.homed_axes %}
Expand All @@ -157,8 +160,12 @@ gcode:
## Check if user enabled purge option or not.
{% if enable_purge %}

### Randomly select left or right bin for purge. 0 = left, 1 = right
SET_GCODE_VARIABLE MACRO=clean_nozzle VARIABLE=bucket_pos VALUE={(range(2) | random)}
{% if bucket_purge < 0 %}
### Randomly select left or right bin for purge. 0 = left, 1 = right
{% set _bucket_pos = (range(2) | random) %}
{% else %}
{% set _bucket_pos = bucket_purge %}
{% endif %}

### Raise Z for travel.
G1 Z{brush_top + clearance_z} F{prep_spd_z}
Expand All @@ -171,7 +178,7 @@ gcode:
{% endif %}

### Position for purge. Randomly selects middle of left or right bucket. It references from the middle of the left bucket.
G1 X{bucket_start + (bucket_left_width / (2 - bucket_pos)) + (bucket_pos * bucket_gap) + (bucket_pos * (bucket_right_width / 2))}
G1 X{bucket_start + (bucket_left_width / (2 - _bucket_pos)) + (_bucket_pos * bucket_gap) + (_bucket_pos * (bucket_right_width / 2))}

### Perform purge if the temp is up to min temp. If not, it will skip and continue executing rest of macro. Small retract after
### purging to minimize any persistent oozing at 5x purge_spd. G4 dwell is in milliseconds, hence * 1000 in formula.
Expand All @@ -185,9 +192,9 @@ gcode:

{% endif %}

## Position for wipe. Either left or right of brush based off bucket_pos to avoid unnecessary travel.
## Position for wipe. Either left or right of brush based off _bucket_pos to avoid unnecessary travel.
G1 Z{brush_top + clearance_z} F{prep_spd_z}
G1 X{brush_start + (brush_width * bucket_pos)} F{prep_spd_xy}
G1 X{brush_start + (brush_width * _bucket_pos)} F{prep_spd_xy}

## Check if user chose to use rear location.
{% if location_bucket_rear %}
Expand All @@ -199,16 +206,16 @@ gcode:
## Move nozzle down into brush.
G1 Z{brush_top} F{prep_spd_z}

## Perform wipe. Wipe direction based off bucket_pos for cool random scrubby routine.
## Perform wipe. Wipe direction based off _bucket_pos for cool random scrubby routine.
{% for wipes in range(1, (wipe_qty + 1)) %}
G1 X{brush_start + (brush_width * (1 - bucket_pos))} F{wipe_spd_xy}
G1 X{brush_start + (brush_width * bucket_pos)} F{wipe_spd_xy}
G1 X{brush_start + (brush_width * (1 - _bucket_pos))} F{wipe_spd_xy}
G1 X{brush_start + (brush_width * _bucket_pos)} F{wipe_spd_xy}
{% endfor %}

## Clear from area.
M117 Cleaned!
G1 Z{brush_top + clearance_z} F{prep_spd_z}
G1 X{bucket_start + (bucket_left_width / 4)} F{prep_spd_xy} #bugfix for right side mounted buckets
G1 X{bucket_start + (bucket_left_width * (1 + (3 * bucket_park)) / 4) + (bucket_park * bucket_gap) + (bucket_park * (bucket_right_width / 2))} F{prep_spd_xy} #bugfix for right side mounted buckets

## Restore the gcode state to how it was before the macro.
RESTORE_GCODE_STATE NAME=clean_nozzle
Expand Down
Loading