Python RGB Matrix games and animations https://www.xythobuz.de/ledmatrix_v2.html
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

solid.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env python3
  2. # ----------------------------------------------------------------------------
  3. # "THE BEER-WARE LICENSE" (Revision 42):
  4. # <xythobuz@xythobuz.de> wrote this file. As long as you retain this notice
  5. # you can do whatever you want with this stuff. If we meet some day, and you
  6. # think this stuff is worth it, you can buy me a beer in return. Thomas Buck
  7. # ----------------------------------------------------------------------------
  8. import time
  9. class Solid:
  10. def __init__(self, g, t = 1.0, c = (0, 0, 0)):
  11. self.gui = g
  12. self.time = t
  13. self.color = c
  14. self.restart()
  15. def restart(self):
  16. self.start = time.time()
  17. def finished(self):
  18. return (time.time() - self.start) >= self.time
  19. def draw(self):
  20. for x in range(0, self.gui.width):
  21. for y in range(0, self.gui.height):
  22. self.gui.set_pixel(x, y, self.color)
  23. if __name__ == "__main__":
  24. import platform
  25. t = None
  26. if platform.machine() == "armv7l":
  27. from pi import PiMatrix
  28. t = PiMatrix()
  29. else:
  30. from test import TestGUI
  31. t = TestGUI()
  32. d = Solid(t, 1.0, (0, 255, 0))
  33. t.debug_loop(d.draw)