diff options
author | Russell Cohen <rcoh@mit.edu> | 2010-11-24 01:09:12 -0500 |
---|---|---|
committer | Russell Cohen <rcoh@mit.edu> | 2010-11-24 01:09:12 -0500 |
commit | b042647b68abdc82490ca6e059993b8eba28904c (patch) | |
tree | a9ee95a38e98b377c251b7b2e9af9cbd8056cf7c /pixelcore/Screen.py | |
parent | 407ac922fc4178021cf3a16dfb1bd875b6083ac4 (diff) |
Refactoring complete! Made modules/packages as appropriate. Finally.
Diffstat (limited to 'pixelcore/Screen.py')
-rw-r--r-- | pixelcore/Screen.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/pixelcore/Screen.py b/pixelcore/Screen.py new file mode 100644 index 0000000..9806daa --- /dev/null +++ b/pixelcore/Screen.py @@ -0,0 +1,31 @@ +from pixelcore.Pixel import * +from pixelcore.PixelStrip import * +import itertools +class Screen: + def __init__(self): + self.responseQueue = [] + self.pixelStrips = [] + def addStrip(self, lS): + self.pixelStrips.append(lS) + def render(self, surface): + [lS.render(surface) for lS in self.pixelStrips] + 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]) + #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): + tempQueue = list(self.responseQueue) + self.responseQueue = [] + for response in tempQueue: + self.processResponse(response) + #public + def respond(self, responseInfo): + self.responseQueue.append(responseInfo) + #private + def processResponse(self, responseInfo): #we need to make a new dict for + #each to prevent interference + [strip.respond(dict(responseInfo)) for strip in self.pixelStrips] + |