Changeset - da8a4696227f
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 10 years ago 2015-06-13 06:28:30
drewp@bigasterisk.com
make the rgb strip work more like the neo ones
Ignore-this: e272be49d61373e188f7da5de19c273b
2 files changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
light9/Effects.py
Show inline comments
 
@@ -15,13 +15,13 @@ def register(f):
 
    registered.append(f)
 
    return f
 

	
 
@register
 
class Strip(object):
 
    """list of r,g,b tuples for sending to an LED strip"""
 
    which = 'L' # LR means both
 
    which = 'L' # LR means both. W is the wide one
 
    pixels = []
 
    @classmethod
 
    def solid(cls, which='L', color=(1,1,1), hsv=None):
 
        """hsv overrides color"""
 
        if hsv is not None:
 
            color = colorsys.hsv_to_rgb(hsv[0] % 1.0, hsv[1], hsv[2])
light9/effecteval/effectloop.py
Show inline comments
 
@@ -223,34 +223,35 @@ class LedLoop(EffectLoop):
 
        self.board = ControlBoard()
 
        self.lastSent = {} # what's in arduino's memory
 
        
 
    def combineOutputs(self, outputs):
 
        combined = {'L': Z, 'R': Z,
 
                    'blacklight0': 0, 'blacklight1': 0,
 
                    'rgb': numpy.zeros((1, 3), dtype=numpy.float16)}
 
                    'W': numpy.zeros((1, 3), dtype=numpy.float16)}
 
        
 
        for out in outputs:
 
            log.debug('combine output %r', out)
 
            if isinstance(out, Effects.Blacklight):
 
                key = 'blacklight%s' % out.which
 
                combined[key] = max(combined[key], out)
 
            elif isinstance(out, Effects.Strip):
 
                pixels = numpy.array(out.pixels, dtype=numpy.float16)
 
                for w in out.which:
 
                    combined[w] = numpy.maximum(combined[w], pixels)
 
                    combined[w] = numpy.maximum(
 
                        combined[w], pixels[:1,:] if w == 'W' else pixels)
 
                
 
        return combined
 

	
 
    @inlineCallbacks
 
    def sendOutput(self, combined):
 
        for meth, selectArgs, value in [
 
                ('setStrip', (0,), combined['L']),
 
                ('setStrip', (1,), combined['R']),
 
                ('setUv', (0,), combined['blacklight0']),
 
                ('setUv', (1,), combined['blacklight1']),
 
                ('setRgb', (), combined['rgb']),
 
                ('setRgb', (), combined['W']),
 
            ]:
 
            key = (meth, selectArgs)
 
            compValue = value.tolist() if isinstance(value, numpy.ndarray) else value
 
            
 
            if self.lastSent.get(key) == compValue:
 
                continue
0 comments (0 inline, 0 general)