forked from tdamdouni/Raspberry-Pi-DIY-Projects
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path8x8grid.py
executable file
·28 lines (27 loc) · 898 Bytes
/
8x8grid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os, sys
if os.path.isfile("/proc/device-tree/hat/product"):
file = open("/proc/device-tree/hat/product","r")
hat = file.readline()
if hat == "Sense HAT\x00":
print('Sense HAT detected')
mypath = os.path.dirname(os.path.abspath(__file__))
file.close()
os.system("/usr/bin/env python3 " + mypath+"/8x8grid-sense.py")
elif hat == "Unicorn HAT\x00":
print('Unicorn HAT detected')
mypath = os.path.dirname(os.path.abspath(__file__))
file.close()
os.system("/usr/bin/env python3 " + mypath+"/8x8grid-unicorn.py")
else:
print("Unknown HAT : " + str(hat))
file.close()
sys.exit()
else:
print('No HAT detected')
answer = input('Do you have a Unicorn Phat (y/n)?')
if answer == 'y':
print('Configuring for Unicorn Phat')
mypath = os.path.dirname(os.path.abspath(__file__))
os.system("/usr/bin/env python3 " + mypath+"/8x8grid-unicornphat.py")
else:
sys.exit()