7 from pylibcerebrum
.serial_mux
import SerialMux
9 BASE_URI
='http://10.0.1.43/dmxacl/json/'
10 PORT
= '/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A700fmkX-if00-port0'
14 s
= SerialMux(PORT
, BAUDRATE
)
15 print('discovering cerebrum devices')
18 results
= s
.discover()
20 print('opening first device')
22 print('initializing device')
24 g
.schnurlinks
.state
= 1
25 g
.schnurmitte
.state
= 1
26 g
.schnurrechts
.state
= 1
27 print('starting event loop')
30 c
= (o
/255)**(1/GAMMA
) #inverse gamma correction
34 return round((c
**GAMMA
)*255)
37 state
= requests
.post(BASE_URI
, data
='{"method": "lightSync.pull", "params": [], "id": 0}').json()['result']
39 v
['red'] = xform(v
['red'], r
)
40 v
['green'] = xform(v
['green'], g
)
41 v
['blue'] = xform(v
['blue'], b
)
42 requests
.post(BASE_URI
, data
=json
.dumps({'method': 'lightSync.push', 'params': [state
], 'id': 0}))
45 sr
, sg
, sb
= False, False, False
47 if g
.schnurlinks
.state
:
53 if g
.schnurmitte
.state
:
59 if g
.schnurrechts
.state
: