setoffs and settext now confirmed working, although setoffs still needs some work...
[PyX52.git] / x52.py
blobf7654e6e6cd8a80e7ad91f460f2366b2be726e86
1 #!/usr/bin/env python
2 from os import system
3 from traceback import print_exc
4 import time
6 build = system("setup.py build")
8 x52 = None
10 try:
11 print "Importing PyX52... ",
12 import PyX52
13 print "[ OK ]"
15 print "Creating PyX52.X52... ",
16 x52 = PyX52.X52()
17 print "[ OK ]"
19 x52types = {PyX52.TYPE_X52: "X52", PyX52.TYPE_X52PRO: "X52 Pro", PyX52.TYPE_YOKE: "Yoke"}
20 print "Detecting X52 device type... ",
21 typestr = x52types[x52.gettype()]
22 print "[ OK ]"
23 print "X52 device type: [ %s ]" % typestr
25 print "Setting date... ",
26 x52.setdate()
27 print "[ OK ]"
29 print "Setting time... ",
30 x52.settime()
31 print "[ OK ]"
33 print "Setting MFD brightness... ",
34 x52.setbri(0, 127)
35 time.sleep(0.1)
36 x52.setbri(0, 63)
37 time.sleep(0.1)
38 x52.setbri(0, 0)
39 time.sleep(0.1)
40 x52.setbri(0, 127)
41 print "[ OK ]"
43 print "Setting LED brightness... ",
44 x52.setbri(1, 127)
45 time.sleep(0.1)
46 x52.setbri(1, 63)
47 time.sleep(0.1)
48 x52.setbri(1, 0)
49 time.sleep(0.1)
50 x52.setbri(1, 127)
51 print "[ OK ]"
53 print "Setting text... ",
54 x52.settext(0, "1234567890123456")
55 time.sleep(0.1)
56 x52.settext(1, "1234567890123456")
57 time.sleep(0.1)
58 x52.settext(2, "1234567890123456")
59 time.sleep(0.1)
60 x52.settext(0, "")
61 time.sleep(0.1)
62 x52.settext(1, "")
63 time.sleep(0.1)
64 x52.settext(2, "")
65 print "[ OK ]"
67 print "Setting LED states... ",
68 for i in range(PyX52.LED_FIRE, PyX52.LED_IGREEN+1):
69 x52.setled(i, 1)
70 time.sleep(0.1)
71 x52.setled(i, 0)
72 print "[ OK ]"
74 print "Setting time offset... ",
75 x52.setoffs(60, -5*60)
76 print "[ OK ]"
77 except:
78 print "[ FAIL ]"
79 print_exc()
80 exit(-1)