Python RGB Matrix games and animations https://www.xythobuz.de/ledmatrix_v2.html
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

util.py 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. targetIsPi = None
  9. def isPi():
  10. global targetIsPi
  11. if targetIsPi == None:
  12. getTarget()
  13. return targetIsPi
  14. def getTarget():
  15. global targetIsPi
  16. target = None
  17. try:
  18. from pi import PiMatrix
  19. pi = PiMatrix()
  20. # TODO hard-coded adjustments
  21. from mapper import MapperColorAdjust
  22. target = MapperColorAdjust(pi)
  23. if targetIsPi == None:
  24. # only print once
  25. print("Raspberry Pi Adafruit RGB LED Matrix detected")
  26. targetIsPi = True
  27. except ModuleNotFoundError:
  28. from test import TestGUI
  29. target = TestGUI()
  30. if targetIsPi == None:
  31. # only print once
  32. print("Falling back to GUI debug interface")
  33. targetIsPi = False
  34. return target