diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-08-25 10:36:45 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-08-25 10:36:45 -0400 |
commit | 84ac5b0146cbcec46419d4636b949f144992072e (patch) | |
tree | 81aaefd6ea5f939b9ad23935bdfbfaf4eefcb3b3 /klippy/extras/tmc.py | |
parent | 75183bfb86c7003d3bac0116dba7765e4a4ab241 (diff) | |
download | kutter-84ac5b0146cbcec46419d4636b949f144992072e.tar.gz kutter-84ac5b0146cbcec46419d4636b949f144992072e.tar.xz kutter-84ac5b0146cbcec46419d4636b949f144992072e.zip |
configfile: Support config.getchoice() with integer keys
If the choice mapping uses integer keys then lookup the config option
using self.getint(). This simplifies the callers and improves the
encoding of the printer.configfile.settings export.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/tmc.py')
-rw-r--r-- | klippy/extras/tmc.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/klippy/extras/tmc.py b/klippy/extras/tmc.py index d849c1bb..0279a040 100644 --- a/klippy/extras/tmc.py +++ b/klippy/extras/tmc.py @@ -472,11 +472,8 @@ 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 - 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)) + 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) fields.set_field("mres", mres) fields.set_field("intpol", config.getboolean("interpolate", True)) |