summaryrefslogtreecommitdiffstats
path: root/brige.py
diff options
context:
space:
mode:
Diffstat (limited to 'brige.py')
-rwxr-xr-xbrige.py100
1 files changed, 0 insertions, 100 deletions
diff --git a/brige.py b/brige.py
deleted file mode 100755
index 314f9db..0000000
--- a/brige.py
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/python2
-from __future__ import division, print_function
-import color
-import constants
-import curses
-import fish_render
-import time
-import random
-try:
- import lumiversepython
-except ImportError:
- have_lumiversepython = False
- from DummyRig import DummyRig
-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 colorSection(lights, color, *ranges):
- for start, end in ranges:
- map(lambda l: map(lambda x: x.light.setRGBRaw(*color), l), lights[start:end])
-
-def onSection(lights, *ranges):
- colorSection(lights, (1, 1, 1), *ranges)
-
-def offSection(lights, *ranges):
- colorSection(lights, (0, 0, 0), *ranges)
-
-def mapKey(key):
- if key == ord('a'):
- return (0, 20)
- if key == ord('o'):
- return (20, 40)
- if key == ord('e'):
- return (40, 60)
- if key == ord('u'):
- return (60, 80)
- if key == ord('i'):
- return (80, 100)
- if key == ord('d'):
- return (100, 120)
- if key == ord('h'):
- return (120, 140)
- if key == ord('t'):
- return (140, 160)
- if key == ord('n'):
- return (160, 180)
- if key == ord('s'):
- return (180, 200)
- return (0, 0)
-
-def demo(lights, rig, screen):
- """Do some light things."""
- sections = []
- while True:
- k = screen.getch()
- offSection(lights, *sections)
- r = mapKey(k)
- try:
- i = sections.index(r)
- except ValueError:
- sections.append(r)
- else:
- del sections[i]
- onSection(lights, *sections)
- rig.updateOnce()
-
-def main():
- """Run show."""
- if have_lumiversepython:
- rig = lumiversepython.Rig('/home/teacher/Lumiverse/PBridge.rig.json')
- else:
- rig = DummyRig(200, 2)
- rig.init()
- stdscr = curses.initscr()
- stdscr.keypad(1)
- curses.noecho()
-
- lights = get_all_lights(rig)
- try:
- demo(lights, rig, stdscr)
- except BaseException:
- curses.nocbreak()
- stdscr.keypad(0)
- curses.echo()
- curses.endwin()
- raise
-
-if __name__ == '__main__':
- main()