aboutsummaryrefslogtreecommitdiff
path: root/pixelcore/PixelStrip.py
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-01-27 16:50:59 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-01-27 16:50:59 -0500
commit5fb3ea060025241105dc8e9a174513c112f9a133 (patch)
treee98b1b3eab0b05b0e518b08cbab086d224fd9250 /pixelcore/PixelStrip.py
parent5d29906fff79bc6e4ba83be7028e1380a0014d21 (diff)
A metric $#%$-ton of changes. Added doc-strings to EVERYTHING. Phew. Fixed a massive bug that
increases performance in by up to a factor of 60. A bunch of new behaviors for the class.
Diffstat (limited to 'pixelcore/PixelStrip.py')
-rw-r--r--pixelcore/PixelStrip.py29
1 files changed, 7 insertions, 22 deletions
diff --git a/pixelcore/PixelStrip.py b/pixelcore/PixelStrip.py
index 662b8fe..595ce72 100644
--- a/pixelcore/PixelStrip.py
+++ b/pixelcore/PixelStrip.py
@@ -4,36 +4,21 @@ import util.Geo as Geo
from pixelevents.StepEvent import *
import math
import pdb
-#Python class representing a single Pixel strip (usually 50 Pixels)
class PixelStrip:
+ """Python class representing a single Pixel strip (usually 50 Pixels)"""
+
def __init__(self, layoutEngine):
self.initStrip(layoutEngine)
self.argDict = layoutEngine.getStripArgs()
+
def initStrip(self, layoutEngine):
pixelLocations = layoutEngine.getPixelLocations()
self.pixels = [Pixel(l) for l in pixelLocations]
+
def __iter__(self):
return self.pixels.__iter__()
- def render(self, surface):
- [l.render(surface) for l in self.pixels]
- #step
- def allOn(self, time):
- [l.turnOnFor(time) for l in self.pixels] #TODO: add test-on method to
- #pixels
- def respond(self, responseInfo):
- location = responseInfo[Strings.LOCATION]
- if not 'PixelEvent' in responseInfo:
- if 'Color' in responseInfo:
- color = responseInfo['Color']
- else:
- raise Exception('Need Color. Probably')
- responseInfo['PixelEvent'] = StepEvent.generate(300, color)
- (dist, pixel) = self.getPixelNearest(location)
- pixel.processInput(responseInfo['PixelEvent'], 0) #TODO: z-index
+
+
+
- def getPixelNearest(self, location):
- dists = [(Geo.dist(location, pixel.location), pixel) for pixel in self.pixels]
- dists.sort()
- return dists[0]
- #just for now.