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.

util.py 1.1KB

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. 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. target = PiMatrix()
  20. if targetIsPi == None:
  21. # only print once
  22. print("Raspberry Pi Adafruit RGB LED Matrix detected")
  23. targetIsPi = True
  24. except ModuleNotFoundError:
  25. from test import TestGUI
  26. target = TestGUI()
  27. if targetIsPi == None:
  28. # only print once
  29. print("Falling back to GUI debug interface")
  30. targetIsPi = False
  31. return target