aboutsummaryrefslogtreecommitdiff
path: root/pixelcore/Pixel.py
diff options
context:
space:
mode:
authorGravatar Russell Cohen <rcoh@mit.edu>2010-11-26 00:07:14 -0500
committerGravatar Russell Cohen <rcoh@mit.edu>2010-11-26 00:07:14 -0500
commit9c9babfa7032b443138c4b457aabaf79fad385b3 (patch)
treef9bf3e8b51423bf6769d2c655ffa15d81a42333f /pixelcore/Pixel.py
parent1754a1f4511ef52f0a093dd0f9915196bd4261e7 (diff)
Add PixelMapper functionality to abstract away from mapping locations->Pixels.
Diffstat (limited to 'pixelcore/Pixel.py')
-rw-r--r--pixelcore/Pixel.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/pixelcore/Pixel.py b/pixelcore/Pixel.py
index a71dba5..8c42581 100644
--- a/pixelcore/Pixel.py
+++ b/pixelcore/Pixel.py
@@ -3,26 +3,31 @@ import pdb
from pixelevents.StepEvent import *
#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 cue. If a member returns none,
+#requested, it processes all the members of its queue. If a member returns none,
#it is removed from the queue. Otherwise, its value added to the Pixels color
#weighted by z-index.
class Pixel:
radius = 2
timeOff = -1
- def __init__(self, location, color):
+ def __init__(self, location):
self.location = location
- self.color = color
self.events = {}
def turnOn(self):
self.turnOnFor(-1)
+ #Turn the light white for 'time' ms. Really only meant for testing. Use
+ #processInput instead. Also, you shouldn't use this anyway. You should be
+ #using the input method on the screen!
def turnOnFor(self, time):
- event = StepEvent.generate(time, (255,0,255)) #TODO: Move color to
+ event = StepEvent.generate(time, (255,255,255)) #TODO: Move color to
self.processInput(event, 0)
#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)
def clearAllEvents(self):
self.events = {}
+ #Combines all PixelEvents currently active and computes the current color of
+ #the pixel.
def state(self):
deadEvents = []
currentTime = Util.time()