summaryrefslogtreecommitdiffstats
path: root/bridge.py
blob: 87b339c269080928121a31a8c9544a4fa0b9a9d4 (plain) (blame)
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
#!/usr/bin/python2
"""Simple demo of oscillating colors."""
from __future__ import division, unicode_literals
import color
import constants
from DummyRig import DummyRig
import fish_render
import time
try:
    import lumiversepython
except ImportError:
    have_lumiversepython = False
else:
    have_lumiversepython = True

def get_all_lights(rig):
    """Return a list of all panels."""
    return [
        [
            fish_render.Light(
                x, int(y == 'top'),
                rig.select('$side={y}[$sequence={x}]'.format(y=y, x=x))
            ) for y in ('top', 'bot')
        ] for x in xrange(1, 200)
    ]


def demo(lights, rig):
    """Do some light things."""
    fish = fish_render.Fish(0, 0, 2, 1, color.red, 1 / constants.FRAME_RATE)
    bridge = fish_render.Bridge(lights, fish, rig)
    while True:
        bridge.update()
        time.sleep(1 / constants.FRAME_RATE)


def main():
    """Run show."""
    if have_lumiversepython:
        rig = lumiversepython.Rig('/home/teacher/Lumiverse/PBridge.rig.json')
    else:
        rig = DummyRig(200, 2)
    rig.init()
    lights = get_all_lights(rig)
    demo(lights, rig)

if __name__ == '__main__':
    main()