Changeset - a856693007b2
[Not reviewed]
default
0 2 0
Drew Perttula - 11 years ago 2014-06-13 07:32:06
drewp@bigasterisk.com
flip L/R, add blacklight() effect
Ignore-this: d0486e7678a1fe150f9fc5dc22c8ba13
2 files changed with 8 insertions and 2 deletions:
0 comments (0 inline, 0 general)
light9/Effects.py
Show inline comments
 
@@ -20,12 +20,15 @@ class ColorStrip(object):
 
    which = 'L'
 
    pixels = []
 
    
 
class Blacklight(float):
 
    """a level for the blacklight PWM output"""
 

	
 
@register
 
def blacklight(v):
 
    return Blacklight(v)
 
    
 
@register
 
def chase(t, ontime=0.5, offset=0.2, onval=1.0, 
 
          offval=0.0, names=None, combiner=max, random=False):
 
    """names is list of URIs. returns a submaster that chases through
 
    the inputs"""
light9/effecteval/effectloop.py
Show inline comments
 
@@ -140,15 +140,16 @@ class EffectLoop(object):
 
Z = numpy.zeros((50, 3), dtype=numpy.uint8)
 

	
 
class LedLoop(EffectLoop):
 
    def initOutput(self):
 
        kw = dict(baudrate=115200)
 
        self.boards = {
 
            'L': serial.Serial('/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A7027NYX-if00-port0', **kw),
 
            'R': serial.Serial('/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A7027JI6-if00-port0', **kw),
 
            'L': serial.Serial('/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A7027JI6-if00-port0', **kw),
 
            'R': serial.Serial('/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A7027NYX-if00-port0', **kw),
 
        }
 
        self.lastSentBacklight = None
 
        
 
    def combineOutputs(self, outputs):
 
        combined = {'L': Z, 'R': Z, 'blacklight': 0}
 
        
 
        for out in outputs:
 
            if isinstance(out, Effects.Blacklight):
 
@@ -160,14 +161,16 @@ class LedLoop(EffectLoop):
 
                
 
        return combined
 
                
 
    def sendOutput(self, combined):
 
        for which, px255 in combined.items():
 
            if which == 'blacklight':
 
                if px255 != self.lastSentBacklight:
 
                self.boards['L'].write('\x60\x01' + chr(px255))
 
                self.boards['L'].flush()
 
                    self.lastSentBacklight = px255
 
            else:
 
                board = self.boards[which]
 
                msg = '\x60\x00' + px255.reshape((-1,)).tostring()
 
                board.write(msg)
 
                board.flush()
 
                
0 comments (0 inline, 0 general)