forked from computergeek125/enttec-usb-dmx-pro
-
Notifications
You must be signed in to change notification settings - Fork 1
/
EnttecUtils.py
62 lines (49 loc) · 826 Bytes
/
EnttecUtils.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
57
58
59
60
61
62
import sys
import time
import EnttecUsbDmxPro
import serial
try:
import serial.tools
import serial.tools.list_ports
serial_tools_avail = True
except ImportError:
serial_tools_avail = False
dmx = EnttecUsbDmxPro.EnttecUsbDmxPro()
data = [0]*512
def begin(port):
dmx.setPort(port)
dmx.connect()
def send():
dmx.sendDMX(data)
def on(ch):
global data
data[ch] = 255
send()
def off(ch):
global data
data[ch] = 255
send()
def one(ch):
global data
data = [0]*255
data[ch] = 255
send()
def oneBox(box):
allOff()
for i in range(0,16):
on(getDMX(box,i))
def getDMX(box, plug):
return box*16+plug
def allOn():
global data
data = [255]*512
send()
def allOff():
global data
data = [0]*512
send()
def loop(start, end, t):
for i in range(start, end+1):
one(i)
time.sleep(t)
begin("/dev/ttyUSB0")