x52.py now rebuilds PyX52 upon execution
[PyX52.git] / x52.py
blob67255bf217d03ad70e43952bb061b49007d8c592
1 #!/usr/bin/env python
2 from os import system
3 from traceback import print_exc
5 build = system("setup.py build")
7 x52 = None
9 try:
10 print "Importing PyX52... ",
11 import PyX52
12 print "[ OK ]"
14 print "Creating PyX52.X52... ",
15 x52 = PyX52.X52()
16 print "[ OK ]"
18 x52types = {PyX52.TYPE_X52: "X52", PyX52.TYPE_X52PRO: "X52 Pro", PyX52.TYPE_YOKE: "Yoke"}
19 print "Detecting X52 device type... ",
20 typestr = x52types[x52.gettype()]
21 print "[ OK ]"
22 print "X52 device type: [ %s ]" % typestr
24 print "Setting date... ",
25 x52.setdate()
26 print "[ OK ]"
28 print "Setting time... ",
29 x52.settime()
30 print "[ OK ]"
32 print "Setting MFD brightness... ",
33 x52.setbri(0, 127)
34 x52.setbri(0, 63)
35 x52.setbri(0, 0)
36 x52.setbri(0, 127)
37 print "[ OK ]"
39 print "Setting LED brightness... ",
40 x52.setbri(1, 127)
41 x52.setbri(1, 63)
42 x52.setbri(1, 0)
43 x52.setbri(1, 127)
44 print "[ OK ]"
46 print "Setting text... ",
47 x52.settext(1, "1234567890123456")
48 x52.settext(2, "1234567890123456")
49 x52.settext(3, "1234567890123456")
50 x52.settext(1, "")
51 x52.settext(2, "")
52 x52.settext(3, "")
53 print "[ OK ]"
55 print "Setting LED states... ",
56 print "[ OK ]"
58 print "Setting time offset... ",
59 print "[ OK ]"
60 except:
61 print "[ FAIL ]"
62 print_exc()
63 exit(-1)