From fb3bae4531740fa4ba8a6057aa5856f0c0582494 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 18 Apr 2022 12:55:32 -0400 Subject: [PATCH] neopixel: Simplify color_order parsing Signed-off-by: Kevin O'Connor --- klippy/extras/neopixel.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/klippy/extras/neopixel.py b/klippy/extras/neopixel.py index ef728fc2..b6daeb4d 100644 --- a/klippy/extras/neopixel.py +++ b/klippy/extras/neopixel.py @@ -33,12 +33,9 @@ class PrinterNeoPixel: raise config.error("color_order does not match chain_count") color_indexes = [] for lidx, co in enumerate(color_order): - rgb = "RGB" - if 'W' in co: - rgb = "RGBW" - if sorted(co) != sorted(rgb): + if sorted(co) not in (sorted("RGB"), sorted("RGBW")): raise config.error("Invalid color_order '%s'" % (co,)) - color_indexes.extend([(lidx, rgb.index(c)) for c in co]) + color_indexes.extend([(lidx, "RGBW".index(c)) for c in co]) self.color_map = list(enumerate(color_indexes)) if len(self.color_map) > MAX_MCU_SIZE: raise config.error("neopixel chain too long")