diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2022-04-06 09:27:36 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2022-04-06 09:27:36 -0400 |
commit | dc7b02f329660a716a180c6a17ea15fc265d4527 (patch) | |
tree | 6176e7a90f8feae8d7a3d1a3f6f504a72bebfb24 /klippy/extras/neopixel.py | |
parent | 92de6e91dcc7df19d74100d349ef9dcf4d833441 (diff) | |
download | kutter-dc7b02f329660a716a180c6a17ea15fc265d4527.tar.gz kutter-dc7b02f329660a716a180c6a17ea15fc265d4527.tar.xz kutter-dc7b02f329660a716a180c6a17ea15fc265d4527.zip |
neopixel: Support arbitrary RGBW strings in color_order config
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/neopixel.py')
-rw-r--r-- | klippy/extras/neopixel.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/klippy/extras/neopixel.py b/klippy/extras/neopixel.py index d4dabf9f..abca823e 100644 --- a/klippy/extras/neopixel.py +++ b/klippy/extras/neopixel.py @@ -12,8 +12,6 @@ RESET_MIN_TIME=.000050 MAX_MCU_SIZE = 500 # Sanity check on LED chain length -COLOR_FORMATS = ["RGB", "GRB", "BRG", "BGR", "RGBW", "GRBW"] - class PrinterNeoPixel: def __init__(self, config): self.printer = printer = config.get_printer() @@ -25,8 +23,9 @@ class PrinterNeoPixel: self.oid = self.mcu.create_oid() self.pin = pin_params['pin'] self.mcu.register_config_callback(self.build_config) - formats = {v: v for v in COLOR_FORMATS} - color_order = config.getchoice("color_order", formats, "GRB") + color_order = config.get("color_order", "GRB") + if sorted(color_order) not in (sorted("RGB"), sorted("RGBW")): + raise config.error("Invalid color_order '%s'" % (color_order,)) if 'W' in color_order: color_index = [color_order.index(c) for c in "RGBW"] else: |