aboutsummaryrefslogtreecommitdiff
path: root/pixelcore/Screen.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/Screen.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/Screen.py')
-rw-r--r--pixelcore/Screen.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/pixelcore/Screen.py b/pixelcore/Screen.py
index b595847..9a81df7 100644
--- a/pixelcore/Screen.py
+++ b/pixelcore/Screen.py
@@ -10,9 +10,10 @@ import itertools
import sys
import pdb
from logger import main_log
-#Class representing a collection of Pixels grouped into PixelStrips. Needs a
-#PixelMapper, currently set via setMapper by may be migrated into the argDict.
class Screen:
+ """Class representing a collection of Pixels grouped into PixelStrips. Needs a
+ PixelMapper, currently set via setMapper by may be migrated into the argDict."""
+
def __init__(self):
self.responseQueue = []
self.pixelStrips = []
@@ -20,14 +21,15 @@ class Screen:
self.xPixelLocs = []
sizeValid = False
self.pixelsSorted = False
+
def addStrip(self, lS):
self.pixelStrips.append(lS)
self.sizeValid = False #keep track of whether or not our screen size has
self.pixelsSorted = False
#been invalidated by adding more pixels
- #Returns (pixelIndex, pixel). Does a binary search.
def pixelsInRange(self, minX, maxX):
+ """Returns (pixelIndex, pixel). Does a binary search."""
if not self.pixelsSorted:
self.computeXSortedPixels()
minIndex = Search.find_ge(self.xPixelLocs, minX)
@@ -41,10 +43,7 @@ class Screen:
self.xSortedPixels.sort()
self.xPixelLocs = [p[0] for p in self.xSortedPixels]
self.pixelsSorted = True
- #For debug only
- def allOn(self):
- [lS.allOn(-1) for lS in self.pixelStrips]
-
+
def __iter__(self): #the iterator of all our pixel strips chained togther
return itertools.chain(*[strip.__iter__() for strip in \
self.pixelStrips]) #the * operator breaks the list into args