summaryrefslogtreecommitdiffstats
path: root/bridge.py
diff options
context:
space:
mode:
authorgroup1 <f16_group1@pbridge.adm.cs.cmu.edu>2016-09-27 15:43:57 -0400
committergroup1 <f16_group1@pbridge.adm.cs.cmu.edu>2016-09-27 15:43:57 -0400
commite0115cae22bf4673393372be2c154da12804ee18 (patch)
treef9f08c17d17f4d4a645efc724ed778be6f7052c8 /bridge.py
parentc22e966ff681babb166eb77e0838cafb38d75d74 (diff)
downloadbridge-e0115cae22bf4673393372be2c154da12804ee18.tar.zst
Updates from first test
Diffstat (limited to 'bridge.py')
-rw-r--r--bridge.py33
1 files changed, 27 insertions, 6 deletions
diff --git a/bridge.py b/bridge.py
index 0ab5b4a..6e2ce02 100644
--- a/bridge.py
+++ b/bridge.py
@@ -1,12 +1,19 @@
-#!/usr/bin/python3
+#!/usr/bin/python
"""Simple demo of oscillating colors."""
+from __future__ import division
import lumiversepython
import random
import time
+FRAME_RATE = 44
+MIN_VALUE = 0
+MAX_VALUE = 1
+MAX_TIME = 4
+MIN_TIME = 0.3
+
def get_all_lights(rig):
"""Return a list of all panels."""
- return [rig.select('$panel={}'.format(i)) for i in range(32)]
+ return [rig.select('$side={}[$sequence={}]'.format(j, i)) for j in ['top', 'bot'] for i in range(1, 200)]
def restrict(low, x, high):
@@ -16,7 +23,12 @@ def restrict(low, x, high):
def random_change():
"""Return a random amount that a light should change each frame."""
- return random.random() / 30
+ min_time = int(MIN_TIME * FRAME_RATE)
+ max_time = int(MAX_TIME * FRAME_RATE)
+ rands = [random.randint(min_time, max_time) for _ in range(5)]
+ rand_binom = sum(rands) / 5
+ #inverse = (rand_binom - (MAX_VALUE - MIN_VALUE) / 2) % (MAX_VALUE - MIN_VALUE) + MIN_VALUE
+ return 1 / random.randint(min_time, max_time)
def demo(lights, rig):
@@ -37,15 +49,23 @@ def demo(lights, rig):
light = light_s['light']
current_value = light_s['current_value']
new_value = restrict(
- 0, current_value + change * (int(is_increasing) * 2 - 1), 1), 1
+ MIN_VALUE, current_value + change * (int(is_increasing) * 2 - 1), MAX_VALUE
)
light.setRGBRaw(0, 0, new_value)
light_s['current_value'] = new_value
- if new_value == 1:
+ if new_value in [MIN_VALUE, MAX_VALUE]:
light_s['is_increasing'] = not is_increasing
light_s['change'] = random_change()
rig.updateOnce()
- time.sleep(1 / 60)
+ time.sleep(1 / FRAME_RATE)
+
+
+def panels(lights, rig):
+ for light in lights:
+ light.setRGBRaw(1, 1, 1)
+ rig.updateOnce()
+ time.sleep(1)
+ light.setRGBRaw(0, 0, 0)
def main():
@@ -54,6 +74,7 @@ def main():
rig.init()
lights = get_all_lights(rig)
demo(lights, rig)
+ #panels(lights, rig)
if __name__ == '__main__':
main()