aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2022-04-18 12:55:32 -0400
committerKevin O'Connor <kevin@koconnor.net>2022-04-18 12:55:32 -0400
commitfb3bae4531740fa4ba8a6057aa5856f0c0582494 (patch)
treedaf5b3bdb0bf2e7bf4cad799a20f7ce0d8f9f53e
parent260fd7d367b78a53170dde80fb53dac12df7576e (diff)
downloadkutter-fb3bae4531740fa4ba8a6057aa5856f0c0582494.tar.gz
kutter-fb3bae4531740fa4ba8a6057aa5856f0c0582494.tar.xz
kutter-fb3bae4531740fa4ba8a6057aa5856f0c0582494.zip
neopixel: Simplify color_order parsing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/extras/neopixel.py7
1 files 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")