Python RGB Matrix games and animations https://www.xythobuz.de/ledmatrix_v2.html
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env python3
  2. #
  3. # ----------------------------------------------------------------------------
  4. # "THE BEER-WARE LICENSE" (Revision 42):
  5. # <xythobuz@xythobuz.de> wrote this file. As long as you retain this notice
  6. # you can do whatever you want with this stuff. If we meet some day, and you
  7. # think this stuff is worth it, you can buy me a beer in return. Thomas Buck
  8. # ----------------------------------------------------------------------------
  9. import interstate75
  10. class PicoMatrix:
  11. def __init__(self, w = 32, h = 32):
  12. self.width = w # x-axis
  13. self.height = h # y-axis
  14. self.panelW = w # x-axis
  15. self.panelH = h # y-axis
  16. # compatibility to TestGUI
  17. self.multiplier = 1.0
  18. if (w != 32) or (h != 32):
  19. raise RuntimeError("TODO not yet supported")
  20. self.matrix = interstate75.Interstate75(display = interstate75.DISPLAY_INTERSTATE75_32X32)
  21. self.loop_start() # initialize with blank image for ScrollText constructor
  22. def loop_start(self):
  23. self.matrix.display.clear()
  24. return False # no input, never quit on our own
  25. def loop_end(self):
  26. self.matrix.update()
  27. def loop(self, func = None):
  28. while True:
  29. if self.loop_start():
  30. break
  31. if func != None:
  32. func()
  33. self.loop_end()
  34. self.matrix.stop()
  35. def set_pixel(self, x, y, color):
  36. if (x < 0) or (y < 0) or (x >= self.width) or (y >= self.height):
  37. return
  38. pen = self.matrix.display.create_pen(color[0], color[1], color[2])
  39. self.matrix.display.set_pen(pen)
  40. self.matrix.display.pixel(int(x), int(y))
  41. if __name__ == "__main__":
  42. t = PicoMatrix(32, 32)
  43. t.loop(lambda: t.set_pixel(15, 15, (255, 255, 255)))