changeset 1413:cb1379b3555b

first try at moving-light effect Ignore-this: 5cbe6ac11058624908a5d65b3c4fa0e9
author drewp@bigasterisk.com
date Fri, 10 Jun 2016 03:27:22 +0000
parents 4916b397b5b8
children c35ec37c3c6e
files light9/effect/sequencer.py
diffstat 1 files changed, 29 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/light9/effect/sequencer.py	Fri Jun 10 03:26:27 2016 +0000
+++ b/light9/effect/sequencer.py	Fri Jun 10 03:27:22 2016 +0000
@@ -8,10 +8,10 @@
 from webcolors import rgb_to_hex
 import json, logging, bisect
 import treq
-from light9 import networking
+import math
 
+from light9 import networking
 from light9.namespaces import L9, RDF
-
 from light9.vidref.musictime import MusicTime
 
 log = logging.getLogger('sequencer')
@@ -63,7 +63,7 @@
         list of (device, attr, value)
         """
         effectSettings = [(L9['strength'], self.evalCurve(t))]
-        return self.effectEval.outputFromEffect(self.effect, effectSettings)
+        return self.effectEval.outputFromEffect(effectSettings, t)
                 
 
 class EffectEval(object):
@@ -78,7 +78,7 @@
         #for ds in g.objects(g.value(uri, L9['effectClass']), L9['deviceSetting']):
         #    self.setting = (g.value(ds, L9['device']), g.value(ds, L9['attr']))
 
-    def outputFromEffect(self, effectSettings):
+    def outputFromEffect(self, effectSettings, songTime):
         """
         From effect attr settings, like strength=0.75, to output device
         settings like light1/bright=0.72;light2/bright=0.78. This runs
@@ -89,18 +89,34 @@
         assert attr == L9['strength']
         c = int(255 * value)
         color = [0, 0, 0]
-        if self.effect == L9['RedStrip']: # throwaway
-            color[0] = c
-        elif self.effect == L9['BlueStrip']:
+        if self.effect == L9['effect/RedStrip']: # throwaway
+
+            mov = URIRef('http://light9.bigasterisk.com/device/moving1')
+            col = [
+                    (songTime + .1) % 1.0,
+                    (songTime + .4) % 1.0,
+                    (songTime + .8) % 1.0,
+                ]
+            print 'col', col
+            return [
+                # device, attr, lev
+                
+                (mov, L9['color'], Literal(rgb_to_hex([value*x*255 for x in col]))),
+                (mov, L9['rx'], Literal(100 + 70 * math.sin(songTime*2))),
+            ]
+
+        elif self.effect == L9['effect/BlueStrip']:
             color[2] = c
-        elif self.effect == URIRef('http://light9.bigasterisk.com/effect/WorkLight'):
+        elif self.effect == L9['effect/WorkLight']:
             color[1] = c
-        elif self.effect == URIRef('http://light9.bigasterisk.com/effect/Curtain'):
+        elif self.effect == L9['effect/Curtain']:
             color[0] = color[2] = 70/255 * c
+        else:
+            color[0] = color[1] = color[2] = c
 
         return [
             # device, attr, lev
-            (URIRef('http://light9.bigasterisk.com/device/colorStrip'),
+            (URIRef('http://light9.bigasterisk.com/device/moving1'),
              URIRef("http://light9.bigasterisk.com/color"),
              Literal(rgb_to_hex(color)))
             ]
@@ -138,5 +154,7 @@
             # we have to send zeros to make past settings go
             # away. might be better for collector not to merge our
             # past requests, and then we can omit zeroed notes?
-            settings.extend(note.outputSettings(t))
+            outs = note.outputSettings(t)
+            print 'out', outs
+            settings.extend(outs)
         self.sendToCollector(settings)