You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
#!/usr/bin/python3 |
|
# Import needed modules from osc4py3 |
|
from osc4py3.as_eventloop import * |
|
from osc4py3 import oscbuildparse |
|
from osc4py3.oscmethod import * |
|
import logging |
|
from pprint import pprint |
|
|
|
logging.basicConfig(format='%(asctime)s - %(threadName)s ø %(name)s - ' |
|
'%(levelname)s - %(message)s') |
|
logger = logging.getLogger("osc") |
|
logger.setLevel(logging.ERROR) |
|
clientname="ledserver" |
|
|
|
|
|
|
|
def led_colour(value): |
|
print("Setting colour to {}".format(value)) |
|
|
|
def led_brightness(value): |
|
print("Setting brightness to {}".format(value)) |
|
|
|
def led_state(addr,value): |
|
led=addr.split("/")[6] |
|
pprint(value) |
|
state=['off','on'] |
|
print("Setting LED {} {}".format(led,state[int(value)])) |
|
|
|
# Start the system. |
|
osc_startup(logger=logger) |
|
server_address='127.0.0.1' |
|
server_port='9000' |
|
|
|
osc_udp_server(server_address,server_port, clientname) |
|
|
|
osc_method("/track/2/fx/1/fxparam/1/value",led_colour) |
|
osc_method("/track/2/fx/1/fxparam/2/value",led_brightness) |
|
osc_method("/track/2/fx/1/fxparam/[!12]/value",led_state,argscheme=OSCARG_ADDRESS+OSCARG_DATAUNPACK) |
|
|
|
|
|
finished=False |
|
while not finished: |
|
osc_process() |
|
|
|
|
|
|