diff --git a/klippy/configfile.py b/klippy/configfile.py index 9377fccf6..3e995e300 100644 --- a/klippy/configfile.py +++ b/klippy/configfile.py @@ -131,6 +131,8 @@ def getboolean(self, option, default=sentinel, note_valid=True): ) def getchoice(self, option, choices, default=sentinel, note_valid=True): + if isinstance(choices, list): + choices = {i: i for i in choices} if choices and isinstance(list(choices.keys())[0], int): c = self.getint(option, default, note_valid=note_valid) else: diff --git a/klippy/extras/bltouch.py b/klippy/extras/bltouch.py index 41747eade..00f4eb65b 100644 --- a/klippy/extras/bltouch.py +++ b/klippy/extras/bltouch.py @@ -58,7 +58,7 @@ def __init__(self, config): mcu = pin_params["chip"] self.mcu_endstop = mcu.setup_pin("endstop", pin_params) # output mode - omodes = {"5V": "5V", "OD": "OD", None: None} + omodes = ["5V", "OD", None] self.output_mode = config.getchoice("set_output_mode", omodes, None) # Setup for sensor test self.next_test_time = 0.0 diff --git a/klippy/extras/display/hd44780.py b/klippy/extras/display/hd44780.py index d7d4e0f7b..a57c1221b 100644 --- a/klippy/extras/display/hd44780.py +++ b/klippy/extras/display/hd44780.py @@ -7,7 +7,7 @@ BACKGROUND_PRIORITY_CLOCK = 0x7FFFFFFF00000000 LINE_LENGTH_DEFAULT = 20 -LINE_LENGTH_OPTIONS = {16: 16, 20: 20} +LINE_LENGTH_OPTIONS = [16, 20] TextGlyphs = {"right_arrow": b"\x7e"} diff --git a/klippy/extras/display/hd44780_spi.py b/klippy/extras/display/hd44780_spi.py index 9bc639ad5..be5a68b97 100644 --- a/klippy/extras/display/hd44780_spi.py +++ b/klippy/extras/display/hd44780_spi.py @@ -8,7 +8,9 @@ from .. import bus LINE_LENGTH_DEFAULT = 20 -LINE_LENGTH_OPTIONS = {16: 16, 20: 20} +LINE_LENGTH_OPTIONS = [16, 20] + +TextGlyphs = {"right_arrow": b"\x7e"} TextGlyphs = {"right_arrow": b"\x7e"} diff --git a/klippy/extras/display/menu_keys.py b/klippy/extras/display/menu_keys.py index 03da95507..7edf0bdf3 100644 --- a/klippy/extras/display/menu_keys.py +++ b/klippy/extras/display/menu_keys.py @@ -19,7 +19,7 @@ def __init__(self, config, callback): # Register rotary encoder encoder_pins = config.get("encoder_pins", None) encoder_steps_per_detent = config.getchoice( - "encoder_steps_per_detent", {2: 2, 4: 4}, 4 + "encoder_steps_per_detent", [2, 4], 4 ) if encoder_pins is not None: try: diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py index a30fcbf6c..f3c71a211 100644 --- a/klippy/extras/probe.py +++ b/klippy/extras/probe.py @@ -46,7 +46,7 @@ def __init__(self, config, mcu_probe): self.sample_retract_dist = config.getfloat( "sample_retract_dist", 2.0, above=0.0 ) - atypes = {"median": "median", "average": "average"} + atypes = ["median", "average"] self.samples_result = config.getchoice( "samples_result", atypes, "average" ) diff --git a/klippy/extras/replicape.py b/klippy/extras/replicape.py index 1fe697698..6d0ba4e59 100644 --- a/klippy/extras/replicape.py +++ b/klippy/extras/replicape.py @@ -203,7 +203,7 @@ def __init__(self, config): printer = config.get_printer() ppins = printer.lookup_object("pins") ppins.register_chip("replicape", self) - revisions = {"B3": "B3"} + revisions = ["B3"] config.getchoice("revision", revisions) self.host_mcu = mcu.get_printer_mcu(printer, config.get("host_mcu")) # Setup enable pin diff --git a/klippy/kinematics/cartesian.py b/klippy/kinematics/cartesian.py index ac4fa83c7..24577ab9f 100644 --- a/klippy/kinematics/cartesian.py +++ b/klippy/kinematics/cartesian.py @@ -26,7 +26,7 @@ def __init__(self, toolhead, config): self.supports_dual_carriage = True if config.has_section("dual_carriage"): dc_config = config.getsection("dual_carriage") - dc_axis = dc_config.getchoice("axis", {"x": "x", "y": "y"}) + dc_axis = dc_config.getchoice("axis", ["x", "y"]) self.dual_carriage_axis = {"x": 0, "y": 1}[dc_axis] # setup second dual carriage rail self.rails.append(stepper.LookupMultiRail(dc_config)) diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py index ac7988c9c..477de48a7 100644 --- a/klippy/kinematics/hybrid_corexy.py +++ b/klippy/kinematics/hybrid_corexy.py @@ -31,7 +31,7 @@ def __init__(self, toolhead, config): if config.has_section("dual_carriage"): dc_config = config.getsection("dual_carriage") # dummy for cartesian config users - dc_config.getchoice("axis", {"x": "x"}, default="x") + dc_config.getchoice("axis", ["x"], default="x") # setup second dual carriage rail self.rails.append(stepper.PrinterRail(dc_config)) self.rails[1].get_endstops()[0][0].add_stepper( diff --git a/klippy/kinematics/hybrid_corexz.py b/klippy/kinematics/hybrid_corexz.py index 63d1d5289..1ab45a6f2 100644 --- a/klippy/kinematics/hybrid_corexz.py +++ b/klippy/kinematics/hybrid_corexz.py @@ -31,7 +31,7 @@ def __init__(self, toolhead, config): if config.has_section("dual_carriage"): dc_config = config.getsection("dual_carriage") # dummy for cartesian config users - dc_config.getchoice("axis", {"x": "x"}, default="x") + dc_config.getchoice("axis", ["x"], default="x") # setup second dual carriage rail self.rails.append(stepper.PrinterRail(dc_config)) self.rails[2].get_endstops()[0][0].add_stepper( diff --git a/klippy/mcu.py b/klippy/mcu.py index b69262e62..3256af342 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -764,9 +764,8 @@ def __init__(self, config, clocksync): restart_methods = [None, "arduino", "cheetah", "command", "rpi_usb"] self._restart_method = "command" if self._baud: - rmethods = {m: m for m in restart_methods} self._restart_method = config.getchoice( - "restart_method", rmethods, None + "restart_method", restart_methods, None ) self._reset_cmd = self._config_reset_cmd = None self._is_mcu_bridge = False