Skip to content

Commit 3d4803d

Browse files
authored
[Bug]: Fixes #507, allows users to use non TMC drivers without erroring out (#522)
Fixes issue #507 where users with non-TMC stepper drivers (like a4988) would encounter errors when the TMC configuration section was not defined. The fix gates TMC-related operations behind the presence of a print_current setting, allowing AFC to work with different driver types.
1 parent b0afae3 commit 3d4803d

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Catch for JSON decode error when trying to read and load AFC.var.unit file
1111

12+
### Fixes
13+
- Issue where TMC section search would error out if not defined. Search is now gated behind user enabling print_current variable. If a user is using a different driver, like a4988 for example, AFC will not error out as long as print_current variable is not defined.
14+
1215
## [2025-08-24]
1316
### Added
1417
- You can now use the `install-afc.sh` script to delete the `AFC.var.unit` file if necessary. This option is located under

extras/AFC_stepper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def __init__(self, config):
3636
# Current to use while printing, set to a lower current to reduce stepper heat when printing.
3737
# Defaults to global_print_current, if not specified current is not changed.
3838
self.tmc_print_current = config.getfloat("print_current", self.afc.global_print_current)
39-
self._get_tmc_values( config )
39+
if self.tmc_print_current is not None:
40+
self._get_tmc_values( config )
4041

4142
# Get and save base rotation dist
4243
self.base_rotation_dist = self.extruder_stepper.stepper.get_rotation_distance()[0]
@@ -48,7 +49,9 @@ def _get_tmc_values(self, config):
4849
try:
4950
self.tmc_driver = next(config.getsection(s) for s in config.fileconfig.sections() if 'tmc' in s and config.get_name() in s)
5051
except:
51-
raise self.gcode.error("Count not find TMC for stepper {}".format(self.name))
52+
msg = f"Could not find TMC for stepper {self.name},"
53+
msg += "\nplease add TMC section or disable 'print_current' from config files"
54+
raise self.gcode.error(msg)
5255

5356
self.tmc_load_current = self.tmc_driver.getfloat('run_current')
5457

0 commit comments

Comments
 (0)