From 00576b225ad8b60ef1e0291e231aa499042436ba Mon Sep 17 00:00:00 2001 From: dxiao Date: Sun, 20 Feb 2011 17:52:18 -0500 Subject: Added an InitialLocationInput --- config/C5Sign.xml | 41 +++++++++++++++++++++++++++++++++++++++++ inputs/InitialLocationInput.py | 24 ++++++++++++++++++++++++ operationscore/Input.py | 3 +++ 3 files changed, 68 insertions(+) create mode 100644 inputs/InitialLocationInput.py diff --git a/config/C5Sign.xml b/config/C5Sign.xml index 6d7de20..f99ef2b 100644 --- a/config/C5Sign.xml +++ b/config/C5Sign.xml @@ -51,6 +51,14 @@ 1800 + + inputs.InitialLocationInput + + centeronce + 0.5 + 0.5 + + inputs.OSCInput @@ -130,6 +138,14 @@ False + + behaviors/RandomColor.xml + + + (255,0,0) + + + behaviors/RandomColor.xml @@ -180,6 +196,13 @@ {y}<2 or {y}>24 + + behaviors.LocationMask + + stripsonly + ts.all ls.all rs.all bs.all + + behaviors.LocationMask @@ -309,6 +332,24 @@ + + behaviors.BehaviorChain + + coloredframe + + centeronce + + + redcolor + square + mover + singleframe + stripsonly + + {'mover':'colorshift'} + True + + behaviors.BehaviorChain 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 -- cgit v1.2.3