Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set bowden length mux, adjust movement #65

Closed
wants to merge 9 commits into from
47 changes: 40 additions & 7 deletions AFC.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
self.hub_dis = config.getfloat("hub_dis", 45)
self.hub_move_dis = config.getfloat("hub_move_dis", 50)
self.hub = ''

Check failure on line 44 in AFC.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W293)

AFC.py:44:1: W293 Blank line contains whitespace
# TOOL Cutting Settings
self.tool = ''
self.tool_cut_active = config.getboolean("tool_cut_active", False)
self.tool_cut_cmd = config.get('tool_cut_cmd')

Check failure on line 49 in AFC.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W293)

AFC.py:49:1: W293 Blank line contains whitespace
# CHOICES
self.park = config.getboolean("park", False)
self.park_cmd = config.get('park_cmd', None)
Expand All @@ -65,6 +65,7 @@
self.tool_stn = config.getfloat("tool_stn", 120)
self.tool_stn_unload = config.getfloat("tool_stn_unload", self.tool_stn)
self.afc_bowden_length = config.getfloat("afc_bowden_length", 900)
self.config_bowden_length = self.afc_bowden_length

# MOVE SETTINGS
self.tool_sensor_after_extruder = config.getfloat("tool_sensor_after_extruder", 0)
Expand All @@ -90,16 +91,39 @@
self.gcode.register_command('LANE_MOVE', self.cmd_LANE_MOVE, desc=self.cmd_LANE_MOVE_help)
self.gcode.register_command('TEST', self.cmd_TEST, desc=self.cmd_TEST_help)
self.gcode.register_command('HUB_CUT_TEST', self.cmd_HUB_CUT_TEST, desc=self.cmd_HUB_CUT_TEST_help)
self.gcode.register_mux_command('SET_BOWDEN_LENGTH', 'AFC', None, self.cmd_SET_BOWDEN_LENGTH, desc=self.cmd_SET_BOWDEN_LENGTH_help)
self.VarFile = config.get('VarFile')
# Get debug and cast to boolean
self.debug = True == config.get('debug', 0)

cmd_SET_BOWDEN_LENGTH_help = "Set length of bowden, hub to toolhead"
def cmd_SET_BOWDEN_LENGTH(self, gcmd):
config_bowden = self.afc_bowden_length
length_param = gcmd.get('LENGTH', None)
if length_param is None or length_param.strip() == '':
bowden_length = self.config_bowden_length
else:
if length_param[0] in ('+', '-'):
bowden_value = float(length_param)
bowden_length = config_bowden + bowden_value
else:
bowden_length = float(length_param)
self.afc_bowden_length = bowden_length
msg = (f"Config Bowden Length: {self.config_bowden_length}\n"
f"Previous Bowden Length: {config_bowden}\n"
f"New Bowden Length: {bowden_length}")
self.respond_info(msg)

Check failure on line 116 in AFC.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W293)

AFC.py:116:1: W293 Blank line contains whitespace
cmd_LANE_MOVE_help = "Lane Manual Movements"
def cmd_LANE_MOVE(self, gcmd):
lane = gcmd.get('LANE', None)
distance = gcmd.get_float('DISTANCE', 0)
CUR_LANE = self.printer.lookup_object('AFC_stepper ' + lane)
CUR_LANE.move(distance, self.short_moves_speed, self.short_moves_accel)
if distance < 0:
CUR_LANE.move(distance, self.short_moves_speed, self.short_moves_accel, True)
else:
CUR_LANE.move(distance, self.short_moves_speed, self.short_moves_accel)


def respond_info(self, msg):
"""
Expand Down Expand Up @@ -406,15 +430,18 @@
def cmd_HUB_LOAD(self, gcmd):
lane = gcmd.get('LANE', None)
CUR_LANE = self.printer.lookup_object('AFC_stepper ' + lane)
if self.hub.filament_present == True:

Check failure on line 433 in AFC.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W291)

AFC.py:433:46: W291 Trailing whitespace
self.respond_error(f"HUB TRIGGERED, CAN'T HUB LOAD {CUR_LANE.name.upper()}")
return
if CUR_LANE.load_state == False:
CUR_LANE.do_enable(True)
while CUR_LANE.load_state == False:
CUR_LANE.move( self.hub_move_dis, self.short_moves_speed, self.short_moves_accel)
CUR_LANE.move(self.hub_move_dis, self.short_moves_speed, self.short_moves_accel)
CUR_LANE.move(CUR_LANE.dist_hub, self.short_moves_speed, self.short_moves_accel)
while self.hub.filament_present == False:
CUR_LANE.move(self.hub_move_dis, self.short_moves_speed, self.short_moves_accel)
while self.hub.filament_present == True:
CUR_LANE.move(self.hub_move_dis * -1, self.short_moves_speed, self.short_moves_accel)
CUR_LANE.move(self.hub_move_dis * -1, self.short_moves_speed, self.short_moves_accel, True)
CUR_LANE.status = 'Hubed'
CUR_LANE.do_enable(False)

Expand All @@ -425,11 +452,11 @@
if CUR_LANE.name != self.current:
CUR_LANE.do_enable(True)
if CUR_LANE.dist_hub:
CUR_LANE.move(CUR_LANE.dist_hub * -1, self.short_moves_speed, self.short_moves_accel)
CUR_LANE.move(CUR_LANE.dist_hub * -1, self.short_moves_speed, self.short_moves_accel, True)
CUR_LANE.dist_hub = False
while CUR_LANE.load_state == True:
CUR_LANE.move( self.hub_move_dis * -1, self.short_moves_speed, self.short_moves_accel)
CUR_LANE.move( self.hub_move_dis * -5, self.short_moves_speed, self.short_moves_accel)
CUR_LANE.move(self.hub_move_dis * -1, self.short_moves_speed, self.short_moves_accel, True)
CUR_LANE.move(self.hub_move_dis * -5, self.short_moves_speed, self.short_moves_accel, True)
CUR_LANE.do_enable(False)
CUR_LANE.status = None
else:
Expand Down Expand Up @@ -457,6 +484,9 @@
CUR_LANE.do_enable(True)
if CUR_LANE.hub_load == False:
CUR_LANE.move(CUR_LANE.dist_hub, self.short_moves_speed, self.short_moves_accel)
if self.hub.filament_present == False:
CUR_LANE.move(self.hub_dis + self.short_move_dis, self.short_moves_speed, self.short_moves_accel)
self.toolhead.wait_moves()
hub_attempts = 0
while self.hub.filament_present == False:
CUR_LANE.move( self.short_move_dis, self.short_moves_speed, self.short_moves_accel)
Expand All @@ -467,7 +497,7 @@
message = (' PAST HUB, CHECK FILAMENT PATH\n||=====||==>--||-----||\nTRG LOAD HUB TOOL')
self.handle_lane_failure(CUR_LANE, message)
return
CUR_LANE.move( self.afc_bowden_length, self.long_moves_speed, self.long_moves_accel)
CUR_LANE.move(self.afc_bowden_length - (hub_attempts * self.short_move_dis), self.long_moves_speed, self.long_moves_accel)
CUR_LANE.extruder_stepper.sync_to_extruder(CUR_LANE.extruder_name)
tool_attempts = 0
while self.tool.filament_present == False:
Expand Down Expand Up @@ -497,7 +527,7 @@
break
self.failure = True
CUR_LANE.hub_load = True

Check failure on line 530 in AFC.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W293)

AFC.py:530:1: W293 Blank line contains whitespace
if self.failure == False:
CUR_LANE.status = 'Tooled'
pos = self.toolhead.get_position()
Expand Down Expand Up @@ -590,6 +620,9 @@
self.toolhead.wait_moves()
CUR_LANE.extruder_stepper.sync_to_extruder(None)
CUR_LANE.move( self.afc_bowden_length * -1, self.long_moves_speed, self.long_moves_accel, True)
if self.hub.filament_present == True:
CUR_LANE.move( self.hub_dis * -1, self.short_moves_speed, self.short_moves_accel, True)
self.toolhead.wait_moves()
num_tries = 0
while self.hub.filament_present == True:
CUR_LANE.move(self.short_move_dis * -1, self.short_moves_speed, self.short_moves_accel, True)
Expand Down
Loading