neopixel: Simplify color_order parsing

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2022-04-18 12:55:32 -04:00
parent 260fd7d367
commit fb3bae4531
1 changed files with 2 additions and 5 deletions

View File

@ -33,12 +33,9 @@ class PrinterNeoPixel:
raise config.error("color_order does not match chain_count") raise config.error("color_order does not match chain_count")
color_indexes = [] color_indexes = []
for lidx, co in enumerate(color_order): for lidx, co in enumerate(color_order):
rgb = "RGB" if sorted(co) not in (sorted("RGB"), sorted("RGBW")):
if 'W' in co:
rgb = "RGBW"
if sorted(co) != sorted(rgb):
raise config.error("Invalid color_order '%s'" % (co,)) 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)) self.color_map = list(enumerate(color_indexes))
if len(self.color_map) > MAX_MCU_SIZE: if len(self.color_map) > MAX_MCU_SIZE:
raise config.error("neopixel chain too long") raise config.error("neopixel chain too long")