aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dan <dan@rcoh-ubuntu-small.(none)>2011-01-25 15:28:25 -0500
committerGravatar Dan <dan@rcoh-ubuntu-small.(none)>2011-01-25 15:28:25 -0500
commit51d58d511d474cb01339d504624b9418c75869e3 (patch)
tree04c21e7d20a0e23682f70b19ef54bfdf12a37cca
parent7557819216cd7d9acd9a4f97d686d6ec84740655 (diff)
TouchOSC-specific behavior
-rw-r--r--behaviors/TouchOSC.py33
-rw-r--r--config/6thFloorOSC.xml11
-rw-r--r--inputs/OSCInput.py2
-rwxr-xr-xtestosc.py2
4 files changed, 41 insertions, 7 deletions
diff --git a/behaviors/TouchOSC.py b/behaviors/TouchOSC.py
new file mode 100644
index 0000000..1c41b5e
--- /dev/null
+++ b/behaviors/TouchOSC.py
@@ -0,0 +1,33 @@
+from operationscore.Behavior import *
+from logger import main_log
+#import util.ColorOps as color
+import colorsys
+import pdb
+import util.ComponentRegistry as compReg
+class TouchOSC(Behavior):
+ def behaviorInit(self):
+ self.h=0
+ self.s=0
+ self.v=0
+ self.xy = (-1,-1)
+ def processResponse(self, sensorInputs, recursiveInputs):
+ ret = []
+ for data in sensorInputs:
+ if data['Path'] == '/1/fader1':
+ try:
+ self.h = data['Value'][0]*360.0
+ except:
+ pdb.set_trace()
+ elif data['Path'] == '/1/fader2':
+ self.s = data['Value'][0]
+ elif data['Path'] == '/1/fader3':
+ self.v = data['Value'][0]
+ elif data['Path'] == '/1/xy':
+ val=data['Value']
+ ssize = compReg.getComponent('Screen').getSize()[-2:] #896 x 310
+ self.xy = (val[1]*ssize[0], (1.0-val[0])*ssize[1])
+ else:
+ main_log.error('Sensor Inputs: ' + str(sensorInputs))
+ ret.append({'Color':[i*255 for i in colorsys.hsv_to_rgb(self.h,self.s,self.v)],'Location':self.xy})
+
+ return (ret, [])
diff --git a/config/6thFloorOSC.xml b/config/6thFloorOSC.xml
index 0a27fda..792fd0c 100644
--- a/config/6thFloorOSC.xml
+++ b/config/6thFloorOSC.xml
@@ -41,7 +41,8 @@
<Class>inputs.OSCInput</Class>
<Args>
<Id>osc</Id>
- <Port>1234</Port>
+ <Port>12345</Port>
+ <RefreshInterval>10</RefreshInterval>
</Args>
</InputElement>
<InputElement>
@@ -80,9 +81,9 @@
</Behavior>
<Behavior>
<Args>
- <Id>mrmrcolor</Id>
+ <Id>touchosc</Id>
</Args>
- <Class>behaviors.MrmrSetColor</Class>
+ <Class>behaviors.TouchOSC</Class>
</Behavior>
<Behavior Id="redshift">
<InheritsFrom>behaviors/RedShift.xml</InheritsFrom>
@@ -266,12 +267,12 @@
<Args>
<Id>mousechaser</Id>
<Inputs>
- <Id>followmouse</Id>
+ <!--Id>followmouse</Id-->
<Id>tcp</Id>
<Id>osc</Id>
</Inputs>
<ChainedBehaviors>
- <Id>mrmrcolor</Id>
+ <Id>touchosc</Id>
<Id>square</Id>
<Id>singleframe</Id>
</ChainedBehaviors>
diff --git a/inputs/OSCInput.py b/inputs/OSCInput.py
index a998490..f867fb5 100644
--- a/inputs/OSCInput.py
+++ b/inputs/OSCInput.py
@@ -13,7 +13,7 @@ class OSCInput(Input):
# main_log.error(str(err))
def fallback(self,path,args,types, src):
- self.respond({'Path':path,'Type':types[0],'Value':args[0]})
+ self.respond({'Path':path,'Type':types,'Value':args})
def sensingLoop(self):
self.server.recv(100)
pass#(data,address) = self.sock.recvfrom(1024)
diff --git a/testosc.py b/testosc.py
index 6763f41..cea03f4 100755
--- a/testosc.py
+++ b/testosc.py
@@ -4,7 +4,7 @@ import liblo, sys
# create server, listening on port 1234
try:
- server = liblo.Server(1234)
+ server = liblo.Server(12345)
except liblo.ServerError, err:
print str(err)
sys.exit()