-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathacab.py
58 lines (47 loc) · 1.26 KB
/
acab.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import serialinterface
import time
serials = [
"/dev/ttyUSB0",
# "/dev/ttyUSB1",
# "/dev/ttyUSB2",
# "/dev/ttyUSB3",
# "/dev/ttyUSB4",
# "/dev/ttyUSB5",
# "/dev/ttyUSB6",
# "/dev/ttyUSB7",
]
def createSerial(dev):
ser = serialinterface.SerialInterface(dev,115200,1)
# put the bridge into full drive mode
# ser.write('\\F')
return ser
serials = map(createSerial,serials)
def high(x):
return (x>>8)&0xff;
def low(x):
return x&0xff;
def set(lamp,r,g,b):
cmd = "%cP%c%c%c"%(chr(lamp),chr(r),chr(g),chr(b))
cmd = "\x5c\x30%s\x5c\x31"%cmd
cmd = cmd.replace("\\","\\\\")
for serial in serials:
serial.write(cmd);
def fade(lamp,r,g,b,ms):
cmd = "%cc%c%c%c%c%c"%(chr(lamp),chr(r),chr(g),chr(b),chr(high(ms)),chr(low(ms)))
cmd = cmd.replace("\\","\\\\")
cmd = "\x5c\x30%s\x5c\x31"%cmd
cmd = cmd.replace("\\","\\\\")
for serial in serials:
serial.write(cmd);
def update():
cmd = '%cU'%chr(0)
cmd = "\x5c\x30%s\x5c\x31"%cmd
cmd = cmd.replace("\\","\\\\")
for serial in serials:
serial.write(cmd);
def reset(lamp):
cmd = '%cB'%chr(lamp)
cmd = "\x5c\x30%s\x5c\x31"%cmd
cmd = cmd.replace("\\","\\\\")
for serial in serials:
serial.write(cmd);