Skip to content

Commit

Permalink
Merge pull request #200 from jimmyjon711/main_to_dev_resync
Browse files Browse the repository at this point in the history
Main to dev resync
  • Loading branch information
MG-longshot authored Dec 19, 2024
2 parents 4091b9e + 5109320 commit b451aba
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
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 @@ def cmd_SET_WEIGHT(self, gcmd):
Args:
gcmd: The G-code command object containing the parameters for the command.
Expected parameters:
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 @@ def cmd_SET_MATERIAL(self, gcmd):
Args:
gcmd: The G-code command object containing the parameters for the command.
Expected parameters:
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 @@ def cmd_SET_MATERIAL(self, gcmd):
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

0 comments on commit b451aba

Please sign in to comment.