Skip to content

Commit d12de43

Browse files
authored
Update orphaned_mods/edwardyeeks/Decontaminator_Purge_Bucket_&_Nozzle_Scrubber/Macros/ by schiele (#1057)
* use native Jinja variable _bucket_pos The previous implementation of dynamically changing bucket_pos on each run had an extremely confusing semantic of changing the variable early in the execution of the macro but see the effect only on the next run of the macro. This led to the situation that the first bucket position after the machine started was never selected randomly, only all later ones. While this for sure is not a major problem of the implementation it is extremely confusing and makes extending the macro unnecessarily complicated. See the confusion this created on my side at https://klipper.discourse.group/t/conditional-changing-of-a-variable-inside-a-macro/19161 By using the native Jinja variable _bucket_pos instead, we can make the change effective immediately, making the macro behave how you would intuitively expect. * variable_bucket_park: select bucket to park nozzle after cleaning The previous implementation always parked the nozzle over the left bucket after cleaning. While this makes sense in most cases it is problematic when you happen to have something installed over the left bucket, like the Klicky Probe. If parking the nozzle over the Klicky Probe there is a certain risk to pull it out of the docking station by accident with the move command following the cleaning procedure. When we park the nozzle over the right bucket we can mitigate that risk. The default value for variable_bucket_park is still to park over the left bucket as in the original implementation. * variable_bucket_purge: select bucket for purging In the original implementation, the bucket for purging was selected randomly. Since I wanted to park the nozzle always over the right bucket to avoid conflicts with the Klicky Probe and as such always oozing into that (on my 350 build) smaller right bucket I thought that it might be useful to compensate for this by always purging to the larger left bucket. Now you can select the bucket you want to do the purging. With the default setting of -1 it will still randomly choose the bucket as before.
1 parent ec3ebba commit d12de43

File tree

1 file changed

+19
-12
lines changed
  • orphaned_mods/edwardyeeks/Decontaminator_Purge_Bucket_&_Nozzle_Scrubber/Macros

1 file changed

+19
-12
lines changed

orphaned_mods/edwardyeeks/Decontaminator_Purge_Bucket_&_Nozzle_Scrubber/Macros/nozzle_scrub.cfg

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ variable_bucket_gap: 22
128128
# installation of purge bucket at rear left.
129129
variable_bucket_start: 0
130130

131+
# Which bucket should the purge be done? -1 = random, 0 = left, 1 = right
132+
variable_bucket_purge: -1
133+
134+
# Which bucket should we park the nozzle at the end of purge? 0 = left, 1 = right
135+
variable_bucket_park: 0
136+
131137

132138
###############################################################################################################################################
133139
###############################################################################################################################################
@@ -138,9 +144,6 @@ variable_bucket_start: 0
138144
###############################################################################################################################################
139145
###############################################################################################################################################
140146

141-
# Placeholder. The variable will later be set to contain, at random, a number representing the left or right bucket.
142-
variable_bucket_pos: 1
143-
144147
gcode:
145148
# First, check if the axes are homed.
146149
{% if "xyz" in printer.toolhead.homed_axes %}
@@ -157,8 +160,12 @@ gcode:
157160
## Check if user enabled purge option or not.
158161
{% if enable_purge %}
159162

160-
### Randomly select left or right bin for purge. 0 = left, 1 = right
161-
SET_GCODE_VARIABLE MACRO=clean_nozzle VARIABLE=bucket_pos VALUE={(range(2) | random)}
163+
{% if bucket_purge < 0 %}
164+
### Randomly select left or right bin for purge. 0 = left, 1 = right
165+
{% set _bucket_pos = (range(2) | random) %}
166+
{% else %}
167+
{% set _bucket_pos = bucket_purge %}
168+
{% endif %}
162169

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

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

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

186193
{% endif %}
187194

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

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

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

208215
## Clear from area.
209216
M117 Cleaned!
210217
G1 Z{brush_top + clearance_z} F{prep_spd_z}
211-
G1 X{bucket_start + (bucket_left_width / 4)} F{prep_spd_xy} #bugfix for right side mounted buckets
218+
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
212219

213220
## Restore the gcode state to how it was before the macro.
214221
RESTORE_GCODE_STATE NAME=clean_nozzle

0 commit comments

Comments
 (0)