Featureful Python controller code for WS2811/WS2812/NeoPixels
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
426B

  1. from colors import Colors
  2. def termcolor(r, g, b):
  3. return f"\x1b[48;2;{r};{g};{b}m"
  4. class TermLEDs:
  5. def __init__(self, length):
  6. self.leds = [Colors.black] * length
  7. def __getitem__(self, key):
  8. return self.leds[key]
  9. def __setitem__(self, key, value):
  10. self.leds[key] = value
  11. def show(self):
  12. print("\r" + " ".join(termcolor(*led) for led in self.leds) + " \x1b[0m", end="")