-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlights.py
43 lines (35 loc) · 1013 Bytes
/
lights.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
import fixtureloader
import asyncio
import listener
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
fixtures = []
default_target = {
'x': config['target'].getfloat('x'),
'y': config['target'].getfloat('y'),
'z': config['target'].getfloat('z')
}
current_target = default_target.copy()
# Load fixtures
async def load():
global fixtures
fixtures, nodes = await fixtureloader.load() # Call fixtureloader to load
def set_positions():
global current_target
# set target for each of the fixtures
for f in fixtures:
f.set_target(current_target)
def reset_target():
global current_target
current_target = default_target.copy()
async def main():
await load() # Load fixtures
while True:
if not listener.paused:
set_positions()
await asyncio.sleep(1/44) # update position 30 times in a second
# Set target
async def set_target(new_target):
global current_target
current_target = new_target