aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar dxiao <dxiao@mit.edu>2011-02-20 17:52:18 -0500
committerGravatar dxiao <dxiao@mit.edu>2011-02-20 17:52:18 -0500
commit00576b225ad8b60ef1e0291e231aa499042436ba (patch)
treeb032b812e5734aaa842b09a1fc3716192f74858a
parent792dd4d7139f9080bf6d3d760efe763b8b3f60cc (diff)
Added an InitialLocationInput
-rw-r--r--config/C5Sign.xml41
-rw-r--r--inputs/InitialLocationInput.py24
-rw-r--r--operationscore/Input.py3
3 files changed, 68 insertions, 0 deletions
diff --git a/config/C5Sign.xml b/config/C5Sign.xml
index 6d7de20..f99ef2b 100644
--- a/config/C5Sign.xml
+++ b/config/C5Sign.xml
@@ -52,6 +52,14 @@
</Args>
</InputElement>
<InputElement>
+ <Class>inputs.InitialLocationInput</Class>
+ <Args>
+ <Id>centeronce</Id>
+ <xPos>0.5</xPos>
+ <yPos>0.5</yPos>
+ </Args>
+ </InputElement>
+ <InputElement>
<Class>inputs.OSCInput</Class>
<Args>
<Id>osc</Id>
@@ -130,6 +138,14 @@
<RenderToScreen>False</RenderToScreen>
</Args>
</Behavior>
+ <Behavior Id="redcolor">
+ <InheritsFrom>behaviors/RandomColor.xml</InheritsFrom>
+ <Args>
+ <ColorList>
+ <Color>(255,0,0)</Color>
+ </ColorList>
+ </Args>
+ </Behavior>
<Behavior Id="colorchange">
<InheritsFrom>behaviors/RandomColor.xml</InheritsFrom>
</Behavior>
@@ -183,6 +199,13 @@
<Behavior>
<Class>behaviors.LocationMask</Class>
<Args>
+ <Id>stripsonly</Id>
+ <Location>ts.all ls.all rs.all bs.all</Location>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.LocationMask</Class>
+ <Args>
<Id>wordsonly</Id>
<Location>wt.all cl.all c5.all</Location>
</Args>
@@ -312,6 +335,24 @@
<Behavior>
<Class>behaviors.BehaviorChain</Class>
<Args>
+ <Id>coloredframe</Id>
+ <Inputs>
+ <Id>centeronce</Id>
+ </Inputs>
+ <ChainedBehaviors>
+ <Id>redcolor</Id>
+ <Id>square</Id>
+ <Id>mover</Id>
+ <Id>singleframe</Id>
+ <Id>stripsonly</Id>
+ </ChainedBehaviors>
+ <RecursiveHooks>{'mover':'colorshift'}</RecursiveHooks>
+ <RenderToScreen>True</RenderToScreen>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
<Id>expandingcircles</Id>
<ChainedBehaviors>
<Id>colorchange</Id>
diff --git a/inputs/InitialLocationInput.py b/inputs/InitialLocationInput.py
new file mode 100644
index 0000000..8d39a40
--- /dev/null
+++ b/inputs/InitialLocationInput.py
@@ -0,0 +1,24 @@
+import util.TimeOps as clock
+import util.ComponentRegistry as compReg
+import util.Strings as Strings
+from operationscore.Input import *
+class InitialLocationInput(Input):
+ """Takes two arguments: xPos, yPos, where xPos and yPos is a value from
+ 0 to 1, where 0 represents top/left and 1 represents bottom/right of the
+ lightscreen. Will return that position on the screen only once."""
+
+ def inputInit(self):
+ compReg.getLock().acquire()
+ xmin, ymin, xmax, ymax = compReg.getComponent('Screen').getSize()
+ compReg.getLock().release()
+
+ xlen = xmax-xmin
+ ylen = ymax-ymin
+
+ self.xloc = xmin + xlen * self['xPos']
+ self.yloc = ymin + ylen * self['yPos']
+
+ def sensingLoop(self):
+ self.respond({Strings.LOCATION: (self.xloc, self.yloc)})
+ self.done = True
+
diff --git a/operationscore/Input.py b/operationscore/Input.py
index 7720847..8800556 100644
--- a/operationscore/Input.py
+++ b/operationscore/Input.py
@@ -14,6 +14,7 @@ class Input(ThreadedSmootCoreObject):
if not 'RefreshInterval' in self.argDict:
self.argDict['RefreshInterval'] = 500
self.parentScope = self.argDict['parentScope']
+ self.done = False
self.inputInit()
def respond(self, eventDict):
@@ -44,6 +45,8 @@ class Input(ThreadedSmootCoreObject):
self.acquireLock()
self.sensingLoop()
self.releaseLock()
+ if self.done:
+ break
def sensingLoop(self):
pass