Featureful Python controller code for WS2811/WS2812/NeoPixels
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

18 行
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="")