mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-08-07 22:14:05 -06:00
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>
This commit is contained in:
parent
75183bfb86
commit
84ac5b0146
5 changed files with 24 additions and 24 deletions
|
@ -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))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue