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

camp_small.py 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. url = "http://www.xythobuz.de"
  23. # Need to import InputWrapper before initializing RGB Matrix on Pi
  24. i = InputWrapper()
  25. t = util.getTarget()
  26. # Loading fonts and graphics takes a while.
  27. # So show a splash screen while the user waits.
  28. splash = SplashScreen(t)
  29. t.loop_start()
  30. splash.draw()
  31. t.loop_end()
  32. # UbaBot is online
  33. success = Manager(t)
  34. success.add(ImageScreen(t, "drinka.gif", 0.2, 2, 20.0, (0, 0, 0)))
  35. success.add(Solid(t, 1.0))
  36. success.add(QRScreen(t, url, 30.0, "Drinks:", "tom-thumb", (255, 255, 255), (0, 0, 0)))
  37. success.add(Solid(t, 1.0))
  38. # UbaBot is offline
  39. fail = Manager(t)
  40. fail.add(ImageScreen(t, "attention.gif", 0.2, 2, 20.0, (0, 0, 0)))
  41. fail.add(Solid(t, 1.0))
  42. fail.add(ScrollText(t, "The UbaBot Cocktail machine is currently closed. Please come back later for more drinks!", "lemon", 2, 75, camp_pink))
  43. fail.add(Solid(t, 1.0))
  44. fail.add(GameOfLife(t, 20, (0, 255, 0), (0, 0, 0), None, 2.0))
  45. fail.add(Solid(t, 1.0))
  46. # UbaBot status checker
  47. d = CheckHTTP(url)
  48. d.success(success)
  49. d.fail(fail)
  50. # Main "Menu"
  51. m = Manager(t, i)
  52. m.add(ScrollText(t, "#CCCAMP23", "lemon", 1, 75, camp_green))
  53. m.add(Solid(t, 1.0))
  54. m.add(ImageScreen(t, "Favicon.png", 0, 1, 10.0))
  55. m.add(Solid(t, 1.0))
  56. m.add(d) # HTTP Check, either "success" or "fail"
  57. m.add(Solid(t, 1.0))
  58. m.add(Snake(t, i, camp_pink, camp_green))
  59. m.add(Solid(t, 1.0))
  60. 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))
  61. m.add(Solid(t, 1.0))
  62. m.restart()
  63. t.loop(m.draw)