Skip to content

Commit

Permalink
Flip tower fill order: tool changes start from front now
Browse files Browse the repository at this point in the history
  • Loading branch information
spegelius committed Feb 4, 2019
1 parent 2d1c2ea commit b0d8735
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/switch_tower.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,10 @@ def _get_wall_position_gcode(self, x_direction, y_direction, infill=False):
"""
if infill:
h = self.wall_height * self.infill_slots + (self.infill_slots - 1) * 0.4
y_pos = 0
else:
h = self.wall_height
y_pos = (self.wall_height + 0.4) * self.slot

y_pos = (self.wall_height + 0.4) * self.slot

if x_direction == self.E:
x_offset = -1.7
Expand Down Expand Up @@ -815,25 +815,25 @@ def _get_wall_gcode(self, extruder, layer: Layer, last_speed, x_direction, y_dir
yield gcode.gen_direction_move(x_dir, self.wall_width, last_speed, layer.height, extruder=extruder), b" wall"
yield gcode.gen_direction_move(y_dir, last_y, last_speed, layer.height, extruder=extruder, last_line=True), b" wall"

def get_slot(self, layer: Layer):
def get_slot(self, layer: Layer, tool_change):
"""
Get next viable slot, based on lowest z. Start from back
:param layer: current layer
:return: none
"""

if layer.action == ACT_SWITCH:
if tool_change:
slot = 0
min_z = 1000000000000

for s in range(layer.slots - 1, -1, -1):
for s in range(0, layer.slots):
if self.slots[s]['last_z'] < min_z:
slot = s
min_z = self.slots[s]['last_z']
self.slot = slot
else:
# fill infill slots from the first slot
self.slot = 0
# fill infill slots from the first available slot
self.slot = layer.slots - self.infill_slots

def _calculate_purge_values(self, layer: Layer, extruder):
"""
Expand Down Expand Up @@ -887,7 +887,7 @@ def get_tower_lines(self, layer: Layer, e_pos, old_e, new_e):
self.log.debug("Adding purge tower")
yield None, b" TOWER START"

self.get_slot(layer)
self.get_slot(layer, True)

initial_horizontal_dir = self.slots[self.slot]['horizontal_dir']

Expand Down Expand Up @@ -1055,7 +1055,7 @@ def get_infill_lines(self, layer: Layer, e_pos, extruder):
# TODO: move this to global state
self.e_pos = e_pos

self.get_slot(layer)
self.get_slot(layer, False)

self.log.debug("Adding purge tower infill")
yield None, b" TOWER INFILL START"
Expand All @@ -1070,7 +1070,7 @@ def get_infill_lines(self, layer: Layer, e_pos, extruder):

tower_z = layer.height + self.slots[self.slot]['last_z']
for s in range(self.infill_slots):
self.slots[s]['last_z'] = round(tower_z, 5)
self.slots[self.slot + s]['last_z'] = round(tower_z, 5)

# infill settings
infill_x = self.wall_width/6
Expand Down

0 comments on commit b0d8735

Please sign in to comment.