aboutsummaryrefslogtreecommitdiff
path: root/LightInstallation.py
diff options
context:
space:
mode:
authorGravatar Russell Cohen <rcoh@mit.edu>2010-12-01 19:46:14 -0500
committerGravatar Russell Cohen <rcoh@mit.edu>2010-12-01 19:46:14 -0500
commit0366f46d3d7e946e254f933888aea4beb4e70658 (patch)
tree81e69d857c41d9ff6ab0ee49315c26cd6112f3a9 /LightInstallation.py
parentcf1f2224b3625b01a6aa7db221403849b308b3bc (diff)
Added support for RecursiveHooks, RecursiveBehaviors and GaussianMapper
supporting Gaussian based pixel mapping.
Diffstat (limited to 'LightInstallation.py')
-rw-r--r--LightInstallation.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/LightInstallation.py b/LightInstallation.py
index 7d8b7b0..849e41f 100644
--- a/LightInstallation.py
+++ b/LightInstallation.py
@@ -80,14 +80,20 @@ class LightInstallation:
return True
def mainLoop(self):
#self.screen.allOn()
+ lastLoopTime = Util.time()
+ refreshInterval = 30
while 1:
- time.sleep(.1)
+ loopStart = Util.time()
responses = self.evaluateBehaviors() #inputs are all queued when they
#happen, so we only need to run the behaviors
[self.screen.respond(response) for response in responses if
response != []]
self.screen.timeStep()
[r.render(self.screen) for r in self.renderers]
+ loopElapsed = Util.time()-loopStart
+ sleepTime = max(0,refreshInterval-loopElapsed)
+ if sleepTime > 0:
+ time.sleep(sleepTime/1000)
#evaluates all the behaviors (including inter-dependencies) and returns a
#list of responses to go to the screen.
def evaluateBehaviors(self):
@@ -114,7 +120,6 @@ class LightInstallation:
if inputId in self.inputBehaviorRegistry: #it could be a behavior
self.inputBehaviorRegistry[inputId].append(behavior['Id'])
def processResponse(self,inputDict, responseDict):
- print inputDict, responseDict
inputId = inputDict['Id']
boundBehaviorIds = self.inputBehaviorRegistry[inputId]
[self.componentDict[b].addInput(responseDict) for b in boundBehaviorIds]