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

Main to dev resync #200

Merged
merged 17 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ cd AFC-Klipper-Add-On

To update the AFC plugin software, you can simply run the following command:
```bash
cd AFC-Klipper-Add-On
./install-afc.sh
```
The update process should be non-destructive and will not overwrite any existing configuration files without your permission.
Expand Down
35 changes: 26 additions & 9 deletions extras/AFC_BoxTurtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ def cmd_CALIBRATE_AFC(self, gcmd):

cal_msg = ''

def find_lane_to_calibrate(lane_name):
"""
Search for the given lane across all units in the AFC system.

Args: lane_name: The name of the lane to search for

Returns: The lane name if found, otherwise None
"""
for UNIT in self.AFC.lanes.keys():
if lane_name in self.AFC.lanes[UNIT]:
return lane_name

# If the lane was not found
self.AFC.gcode.respond_info('{} not found in any unit.'.format(lane_name))
return None

# Helper functions for movement and calibration
def calibrate_hub(CUR_LANE, CUR_HUB):
hub_pos = 0
Expand Down Expand Up @@ -192,18 +208,13 @@ def calibrate_lane(LANE):
cal_msg += 'AFC Calibration distances +/-{}mm'.format(tol)
cal_msg += '\n<span class=info--text>Update values in AFC_Hardware.cfg</span>'
if lanes != 'all':
lane_to_calibrate = None
# Search for the lane within the units
for UNIT in self.AFC.lanes.keys():
if lanes in self.AFC.lanes[UNIT]:
lane_to_calibrate = lanes
break
lane_to_calibrate = find_lane_to_calibrate(lanes)

if lane_to_calibrate is None:
self.AFC.gcode.respond_info('{} not found in any unit.'.format(lanes))
return

# Calibrate the specific lane
checked, msg = calibrate_lane(lanes)
checked, msg = calibrate_lane(lane_to_calibrate)
if(not checked): return
cal_msg += msg
else:
Expand All @@ -223,7 +234,13 @@ def calibrate_lane(LANE):
self.AFC.gcode.respond_info('Starting AFC distance Calibrations')
cal_msg += 'AFC Calibration distances +/-{}mm'.format(tol)
cal_msg += '\n<span class=info--text>Update values in AFC_Hardware.cfg</span>'
lane = afc_bl

lane_to_calibrate = find_lane_to_calibrate(afc_bl)

if lane_to_calibrate is None:
return

lane = lane_to_calibrate
CUR_LANE = self.printer.lookup_object('AFC_stepper ' + lane)
CUR_EXTRUDER = self.printer.lookup_object('AFC_extruder ' + CUR_LANE.extruder_name)
CUR_HUB = self.printer.lookup_object('AFC_hub ' + CUR_LANE.unit)
Expand Down
5 changes: 2 additions & 3 deletions extras/AFC_spool.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
Args:
gcmd: The G-code command object containing the parameters for the command.
Expected parameters:

Check failure on line 115 in extras/AFC_spool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W293)

extras/AFC_spool.py:115:1: W293 Blank line contains whitespace
LANE: The name of the lane whose weight is to be changed.
WEIGHT: The new weight (optional, defaults to '').

Expand Down Expand Up @@ -141,7 +141,7 @@
Args:
gcmd: The G-code command object containing the parameters for the command.
Expected parameters:

Check failure on line 144 in extras/AFC_spool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W293)

extras/AFC_spool.py:144:1: W293 Blank line contains whitespace
LANE: The name of the lane whose material is to be changed.
MATERIAL: The new material (optional, defaults to '').

Expand All @@ -157,7 +157,6 @@
CUR_LANE.material = material
self.AFC.lanes[CUR_LANE.unit][CUR_LANE.name]['material'] = material
self.AFC.save_vars()

def set_active_spool(self, ID):
webhooks = self.printer.lookup_object('webhooks')
if self.AFC.spoolman_ip != None:
Expand Down
Loading