aboutsummaryrefslogtreecommitdiff
path: root/pixelcore
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-01-24 22:44:16 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-01-24 22:44:16 -0500
commit2019fb2895237aa9d86450daaf6d90831189fc13 (patch)
tree6dd9de45c5c2994c0a6aad2aa808092abb8f99bd /pixelcore
parent39de2bc415e6dc02c68018655962197a38207718 (diff)
Some new stuff. Fixed a bug where screen responses weren't being synchronized. Now they are.
Added XYMove to do a bouncy behavior.
Diffstat (limited to 'pixelcore')
-rw-r--r--pixelcore/Pixel.py6
-rw-r--r--pixelcore/Screen.py17
2 files changed, 17 insertions, 6 deletions
diff --git a/pixelcore/Pixel.py b/pixelcore/Pixel.py
index 7260e56..1fbea2c 100644
--- a/pixelcore/Pixel.py
+++ b/pixelcore/Pixel.py
@@ -52,7 +52,11 @@ class Pixel:
(zindex,scale,event) = self.events[eventTime]
eventResult = event.state(currentTime-eventTime)
if eventResult != None:
- colors.append(color.multiplyColor(eventResult,scale))
+ scaledEvent = color.multiplyColor(eventResult,scale)
+ if (scaledEvent[0] + scaledEvent[1] + scaledEvent[2]) < 5:
+ deadEvents.append(eventTime)
+ else:
+ colors.append(scaledEvent)
else:
deadEvents.append(eventTime)
diff --git a/pixelcore/Screen.py b/pixelcore/Screen.py
index cfadee8..a6fc8c4 100644
--- a/pixelcore/Screen.py
+++ b/pixelcore/Screen.py
@@ -49,11 +49,15 @@ class Screen:
#increment time -- This processes all queued responses. Responses generated
#during this period are added to the queue that will be processed on the next
#time step.
- def timeStep(self):
+ #SUBVERTING DESIGN FOR EFFICIENCY 1/24/11, RCOH -- It would be cleaner to store the time on the responses
+ #themselves, however, it is faster to just pass it in.
+ def timeStep(self, currentTime=None):
+ if currentTime == None:
+ currentTime = timeops.time()
tempQueue = list(self.responseQueue)
self.responseQueue = []
for response in tempQueue:
- self.processResponse(response)
+ self.processResponse(response, currentTime)
#public
def respond(self, responseInfo):
@@ -73,13 +77,15 @@ class Screen:
maxY = max(y, maxY)
self.size = (0,0, maxX, maxY)
self.sizeValid = True
- print self.size
return (0, 0, maxX+100, maxY+100) #TODO: cleaner
#private
- def processResponse(self, responseInfo): #we need to make a new dict for
+ def processResponse(self, responseInfo, currentTime=None): #we need to make a new dict for
#each to prevent interference
#[strip.respond(dict(responseInfo)) for strip in self.pixelStrips]
+ if currentTime == None:
+ currentTime = timeops.time()
+ print 'cachetime fail'
if type(responseInfo) != type(dict()):
pass
if 'Mapper' in responseInfo:
@@ -89,7 +95,8 @@ class Screen:
#if type(mapper) != type(PixelMapper):
# raise Exception('No default mapper specified.')
pixelWeightList = mapper.mapEvent(responseInfo['Location'], self)
+ main_log.debug('Screen processing response. ' + str(len(pixelWeightList)) + ' events\
+generated')
PixelEvent.addPixelEventIfMissing(responseInfo)
- currentTime = timeops.time()
for (pixel, weight) in pixelWeightList:
pixel.processInput(responseInfo['PixelEvent'], 0,weight, currentTime) #TODO: z-index