Python RGB Matrix games and animations https://www.xythobuz.de/ledmatrix_v2.html
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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. camp_pink = (251, 72, 196)
  9. camp_green = (63, 255, 33)
  10. from splash import SplashScreen
  11. from scroll import ScrollText
  12. from solid import Solid
  13. from life import GameOfLife
  14. from net import CheckHTTP
  15. from image import ImageScreen
  16. from qr import QRScreen
  17. from snake import Snake
  18. from gamepad import InputWrapper
  19. from manager import Manager
  20. import util
  21. url = "http://ubabot.frubar.net"
  22. # Need to import InputWrapper before initializing RGB Matrix on Pi
  23. i = InputWrapper()
  24. t = util.getTarget()
  25. # Loading fonts and graphics takes a while.
  26. # So show a splash screen while the user waits.
  27. splash = SplashScreen(t)
  28. t.loop_start()
  29. splash.draw()
  30. t.loop_end()
  31. # UbaBot is online
  32. success = Manager(t)
  33. success.add(ImageScreen(t, "drinka.gif", 0.2, 2, 20.0))
  34. success.add(Solid(t, 1.0))
  35. success.add(QRScreen(t, url, 30.0, "Drinks:", "tom-thumb", (255, 255, 255), (0, 0, 0)))
  36. success.add(Solid(t, 1.0))
  37. # UbaBot is offline
  38. fail = Manager(t)
  39. fail.add(ImageScreen(t, "attention.gif", 0.2, 2, 20.0, (0, 0, 0)))
  40. fail.add(ScrollText(t, "The UbaBot Cocktail machine is currently closed. Please come back later for more drinks!", "lemon", 2, 75, camp_pink))
  41. fail.add(Solid(t, 1.0))
  42. fail.add(GameOfLife(t, 20, (0, 255, 0), (0, 0, 0), None, 2.0))
  43. fail.add(Solid(t, 1.0))
  44. # UbaBot status checker
  45. d = CheckHTTP(url)
  46. d.success(success)
  47. d.fail(fail)
  48. # Main "Menu"
  49. m = Manager(t)
  50. m.add(ScrollText(t, "#CCCAMP23", "lemon", 1, 75, camp_green))
  51. m.add(Solid(t, 1.0))
  52. m.add(ImageScreen(t, "Favicon.png", 0, 1, 10.0))
  53. m.add(Solid(t, 1.0))
  54. m.add(d) # HTTP Check, either "success" or "fail"
  55. m.add(Solid(t, 1.0))
  56. m.add(Snake(t, i, camp_pink, camp_green))
  57. m.add(Solid(t, 1.0))
  58. m.add(ScrollText(t, "Your advertisement could appear here. Open a Pull Request on git.xythobuz.de/thomas/rgb-matrix-visualizer or send an e-mail to thomas@xythobuz.de", "iv18x16u", 2, 70, camp_green))
  59. m.add(Solid(t, 1.0))
  60. m.restart()
  61. t.loop(m.draw)