-
Notifications
You must be signed in to change notification settings - Fork 0
/
lights-control
executable file
·72 lines (55 loc) · 2.35 KB
/
lights-control
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
63
64
65
66
67
68
69
70
71
72
#!/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)