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

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