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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. targetPlatform = None
  9. def isPi():
  10. global targetPlatform
  11. if targetPlatform == None:
  12. getTarget()
  13. return targetPlatform == "pi"
  14. def isPico():
  15. global targetPlatform
  16. if targetPlatform == None:
  17. getTarget()
  18. return targetPlatform == "pico"
  19. def getTarget():
  20. global targetPlatform
  21. target = None
  22. try:
  23. # First we try the Raspberry Pi interface
  24. from pi import PiMatrix
  25. pi = PiMatrix()
  26. # TODO hard-coded adjustments
  27. from mapper import MapperColorAdjust, MapperStripToRect
  28. col = MapperColorAdjust(pi)
  29. target = MapperStripToRect(col)
  30. if targetPlatform == None:
  31. # only print once
  32. print("Raspberry Pi Adafruit RGB LED Matrix detected")
  33. targetPlatform = "pi"
  34. except:
  35. try:
  36. # Next we try the Pico Interstate75 interface
  37. from pico import PicoMatrix
  38. target = PicoMatrix()
  39. if targetPlatform == None:
  40. # only print once
  41. print("Raspberry Pi Pico Interstate75 RGB LED Matrix detected")
  42. targetPlatform = "pico"
  43. except:
  44. # If this fails fall back to the SDL/pygame GUI
  45. from test import TestGUI
  46. target = TestGUI()
  47. if targetPlatform == None:
  48. # only print once
  49. print("Falling back to GUI debug interface")
  50. targetPlatform = "tk"
  51. return target