diff options
author | rcoh <rcoh@mit.edu> | 2010-12-20 15:42:13 -0500 |
---|---|---|
committer | rcoh <rcoh@mit.edu> | 2010-12-20 15:42:13 -0500 |
commit | a1d9b85320c9b07d62470d78ef0c5f9015baf813 (patch) | |
tree | 8df16aec8de793ba0f2e4b330b764a6f6a49f59a /pixelcore | |
parent | 17577b1b19387b2cefb7ac777ed1323dd36be086 (diff) | |
parent | 2736307c1d6d67868ca54a3df951f9e959efedd0 (diff) |
Merge branch 'master' into pixelregions
Conflicts:
Util.py
pixelmappers/SimpleMapper.py
Diffstat (limited to 'pixelcore')
-rw-r--r-- | pixelcore/Pixel.py | 9 | ||||
-rw-r--r-- | pixelcore/PixelStrip.py | 6 | ||||
-rw-r--r-- | pixelcore/Screen.py | 8 |
3 files changed, 14 insertions, 9 deletions
diff --git a/pixelcore/Pixel.py b/pixelcore/Pixel.py index ba87dff..f66d0bb 100644 --- a/pixelcore/Pixel.py +++ b/pixelcore/Pixel.py @@ -1,6 +1,7 @@ -import Util +import util.ColorOps as color import pdb from pixelevents.StepEvent import * +import util.TimeOps as clock #Pixel keeps a queue of events (PixelEvent objects) (actually a dictionary #keyed by event time). Every time is state is #requested, it processes all the members of its queue. If a member returns none, @@ -24,7 +25,7 @@ class Pixel: #arg #Add a pixelEvent to the list of active events def processInput(self,pixelEvent,zindex): #consider migrating arg to dict - self.events[Util.time()] = (zindex, pixelEvent) + self.events[clock.time()] = (zindex, pixelEvent) def clearAllEvents(self): self.events = {} #Combines all PixelEvents currently active and computes the current color of @@ -37,13 +38,13 @@ class Pixel: if len(self.events) == 0: return (0,0,0) deadEvents = [] - currentTime = Util.time() + currentTime = clock.time() resultingColor = (0,0,0) for eventTime in self.events: #TODO: right color weighting code (zindex,event) = self.events[eventTime] eventResult = event.state(currentTime-eventTime) if eventResult != None: - resultingColor = Util.combineColors(eventResult, resultingColor) + resultingColor = color.combineColors(eventResult, resultingColor) else: deadEvents.append(eventTime) [self.events.pop(event) for event in deadEvents] diff --git a/pixelcore/PixelStrip.py b/pixelcore/PixelStrip.py index c82a87a..cfab948 100644 --- a/pixelcore/PixelStrip.py +++ b/pixelcore/PixelStrip.py @@ -1,4 +1,6 @@ from pixelcore.Pixel import * +import util.Strings as Strings +import util.Geo as Geo from pixelevents.StepEvent import * import pygame import math @@ -21,7 +23,7 @@ class PixelStrip: [l.turnOnFor(time) for l in self.pixels] #TODO: add test-on method to #pixels def respond(self, responseInfo): - location = responseInfo[Util.location] + location = responseInfo[Strings.LOCATION] if not 'PixelEvent' in responseInfo: if 'Color' in responseInfo: color = responseInfo['Color'] @@ -32,7 +34,7 @@ class PixelStrip: pixel.processInput(responseInfo['PixelEvent'], 0) #TODO: z-index def getPixelNearest(self, location): - dists = [(Util.dist(location, pixel.location), pixel) for pixel in self.pixels] + dists = [(Geo.dist(location, pixel.location), pixel) for pixel in self.pixels] dists.sort() return dists[0] #just for now. diff --git a/pixelcore/Screen.py b/pixelcore/Screen.py index 92805a8..a20cc72 100644 --- a/pixelcore/Screen.py +++ b/pixelcore/Screen.py @@ -1,5 +1,7 @@ from pixelcore.Pixel import * from pixelcore.PixelStrip import * +from operationscore.PixelEvent import * +import util.Search as Search import itertools #Class representing a collection of Pixels grouped into PixelStrips. Needs a #PixelMapper, currently set via setMapper by may be migrated into the argDict. @@ -17,8 +19,8 @@ class Screen: self.computeXSortedPixels() #Returns (pixelIndex, pixel). Does a binary search. def pixelsInRange(self, minX, maxX): - minIndex = Util.find_ge(self.xPixelLocs, minX) - maxIndex = Util.find_le(self.xPixelLocs, maxX)+1 + minIndex = Search.find_ge(self.xPixelLocs, minX) + maxIndex = Search.find_le(self.xPixelLocs, maxX)+1 return self.xSortedPixels[minIndex:maxIndex] def computeXSortedPixels(self): for pixel in self: @@ -70,7 +72,7 @@ class Screen: pass #pdb.set_trace() pixelWeightList = self.mapper.mapEvent(responseInfo['Location'], self) - Util.addPixelEventIfMissing(responseInfo) + PixelEvent.addPixelEventIfMissing(responseInfo) for (pixel, weight) in pixelWeightList: pixel.processInput(responseInfo['PixelEvent'].scale(weight), 0) #TODO: z-index |