Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 72 lines (55 sloc) 2.35 KB
#!/usr/bin/env python3
import time
import argparse
import sys
import subprocess
import os
from pythonosc import udp_client
PILLAR_COUNT = 10
SOUNDS_DIR = os.path.realpath(os.path.dirname(os.path.realpath(__file__)) + "/../sounds")
client = udp_client.SimpleUDPClient("127.0.0.1", 3030)
def send_message(path, value):
client.send_message(path, value)
def play(file, wait=True):
if wait:
return subprocess.run(["paplay", f"{SOUNDS_DIR}/{file}"])
else:
return subprocess.Popen(["paplay", f"{SOUNDS_DIR}/{file}"])
def send_pillar_message(pillar, path, value):
if pillar == None:
for i in range(0, PILLAR_COUNT):
send_pillar_message(i + 1, path, value)
else:
send_message(f"/lx/channel/Pillar {pillar}{path}", value)
def activate(args):
send_pillar_message(args.pillar, "/activePattern", 1)
play("activation.wav", wait=False)
def deactivate(args):
send_pillar_message(args.pillar, "/activePattern", 0)
def head(args):
send_pillar_message(args.pillar, "/pattern/active/headActive", args.active == 'on')
def final(args):
time.sleep(3) # wait for last pillar to activate
send_message('/lx/channel/Final/activePattern', 1)
time.sleep(3)
subprocess = play("final.wav", wait=False)
time.sleep(75)
send_message('/lx/channel/Overlay/activePattern', 1)
subprocess.wait()
send_message('/lx/channel/Final/activePattern', 0)
send_message('/lx/channel/Overlay/activePattern', 0)
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
pillar_parser = argparse.ArgumentParser(add_help=False)
pillar_parser.add_argument('pillar', type=int, help='pillar number', nargs='?')
activate_parser = subparsers.add_parser('activate', help='activate a pillar', parents=[pillar_parser])
activate_parser.set_defaults(func=activate)
deactivate_parser = subparsers.add_parser('deactivate', help='deactivate a pillar', parents=[pillar_parser])
deactivate_parser.set_defaults(func=deactivate)
head_parser = subparsers.add_parser('head', help='set the head active state', parents=[pillar_parser])
head_parser.add_argument('active', choices=['on', 'off'], help='head active')
head_parser.set_defaults(func=head)
final_parser = subparsers.add_parser('final', help='trigger the final pattern', parents=[pillar_parser])
final_parser.set_defaults(func=final)
args = parser.parse_args()
args.func(args)
You can’t perform that action at this time.