tmc: Use config.getint() when reading microstep setting

Don't use config.getchoice() as that results in a string reported by
printer.configfile.settings.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-08-22 10:50:18 -04:00
parent e37d2dee90
commit f2d10b5729
1 changed files with 5 additions and 3 deletions

View File

@ -472,9 +472,11 @@ def TMCMicrostepHelper(config, mcu_tmc):
and config.get('microsteps', None, note_valid=False) is not None):
# Older config format with microsteps in tmc config section
ms_config = config
steps = {'256': 0, '128': 1, '64': 2, '32': 3, '16': 4,
'8': 5, '4': 6, '2': 7, '1': 8}
mres = ms_config.getchoice('microsteps', steps)
ms = ms_config.getint('microsteps')
mres = {256: 0, 128: 1, 64: 2, 32: 3, 16: 4, 8: 5, 4: 6, 2: 7, 1: 8}.get(ms)
if mres is None:
raise config.error("Invalid '%s' microstep setting (%d)"
% (config.get_name(), ms))
fields.set_field("mres", mres)
fields.set_field("intpol", config.getboolean("interpolate", True))