aboutsummaryrefslogtreecommitdiff
path: root/pixelcore
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2010-12-22 14:27:33 -0500
committerGravatar rcoh <rcoh@mit.edu>2010-12-22 14:27:33 -0500
commitc581408f028d5b8ceadc53c68d7c1252fbe09e6d (patch)
tree8724862d05bde3bb3427cdff378cdb08da8babd2 /pixelcore
parenta1d9b85320c9b07d62470d78ef0c5f9015baf813 (diff)
About halfway done with support for pixel regions. Modified the component registry a bit. Added
support for multiple pixel mappers (and along with that, default components). RCOH
Diffstat (limited to 'pixelcore')
-rw-r--r--pixelcore/PixelStrip.py1
-rw-r--r--pixelcore/Screen.py14
2 files changed, 10 insertions, 5 deletions
diff --git a/pixelcore/PixelStrip.py b/pixelcore/PixelStrip.py
index cfab948..fceff8e 100644
--- a/pixelcore/PixelStrip.py
+++ b/pixelcore/PixelStrip.py
@@ -4,7 +4,6 @@ import util.Geo as Geo
from pixelevents.StepEvent import *
import pygame
import math
-import Util
import pdb
#Python class representing a single Pixel strip (usually 50 Pixels)
class PixelStrip:
diff --git a/pixelcore/Screen.py b/pixelcore/Screen.py
index a20cc72..da03ad2 100644
--- a/pixelcore/Screen.py
+++ b/pixelcore/Screen.py
@@ -1,7 +1,10 @@
from pixelcore.Pixel import *
from pixelcore.PixelStrip import *
from operationscore.PixelEvent import *
+from operationscore.PixelMapper import *
import util.Search as Search
+import util.ComponentRegistry as compReg
+import util.Strings as Strings
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.
@@ -29,8 +32,6 @@ class Screen:
self.xPixelLocs = [p[0] for p in self.xSortedPixels]
def render(self, surface):
[lS.render(surface) for lS in self.pixelStrips]
- def setMapper(self, mapper):
- self.mapper = mapper
def allOn(self):
[lS.allOn(-1) for lS in self.pixelStrips]
def __iter__(self): #the iterator of all our pixel strips chained togther
@@ -70,8 +71,13 @@ class Screen:
#[strip.respond(dict(responseInfo)) for strip in self.pixelStrips]
if type(responseInfo) != type(dict()):
pass
- #pdb.set_trace()
- pixelWeightList = self.mapper.mapEvent(responseInfo['Location'], self)
+ if 'Mapper' in responseInfo:
+ mapper = compReg.getComponent(responseInfo['Mapper'])
+ else:
+ mapper = compReg.getComponent(Strings.DEFAULT_MAPPER)
+ #if type(mapper) != type(PixelMapper):
+ # raise Exception('No default mapper specified.')
+ pixelWeightList = mapper.mapEvent(responseInfo['Location'], self)
PixelEvent.addPixelEventIfMissing(responseInfo)
for (pixel, weight) in pixelWeightList:
pixel.processInput(responseInfo['PixelEvent'].scale(weight), 0) #TODO: z-index