Exemple #1
0
    def __init__(self, num_leds, num_segments=None, brightness=255):
        # set the total number of LEDs in the strip
        self.num_leds = num_leds
        self.num_segments = num_segments
        self.brightness = brightness
        
        # initialize the list of segment overrides to include all, left and right.
        # This segment list is used to override other segment control based on
        # the bling command itself. For example, we may want to apply a pattern to either
        # the left or right side of the robot.
        led_half = int((self.num_leds/2))
        led_quarter = int((self.num_leds/4))
        self.segments = { 'ALL':          ( 0, self.num_leds ),
                          'LEFT':         ( 0, led_half-1 ),
                          'RIGHT':        ( led_half, int(self.num_leds) ),
                          'RIGHT_FRONT':  ( 0, (led_quarter-1) ),
                          'RIGHT_REAR':   ( led_quarter, (led_quarter+led_quarter-1) ),
                          'LEFT_REAR':    ( (led_quarter*2), ((led_quarter*2)+led_quarter-1) ),
                          'LEFT_FRONT':   ( (led_quarter*3), ((led_quarter*3)+led_quarter-1) )
                        }

        # initialize the driver with the type and count of LEDs that we are using
        # also, define the correct RGB channel order once you have run the test pattern
        # the other parameters are set based on the controlling application. We're using
        # the RaspberryPi as the controller with the SPI port
        self.driver = DriverLPD8806(num=self.num_leds, c_order = ChannelOrder.GRB, SPISpeed=2, use_py_spi=True, dev='/dev/spidev0.0')

        # we are using the LED strip configuration, other available configurations include an LED matrix,
        # but we have only a single strip at this time
        self.led = LEDStrip(self.driver, threadedUpdate=True, masterBrightness=self.brightness)

        # the frames per second is used to control how fast the animation runs. some of the animations
        # work better when run at a low frames per second
        self.fps = None

        # the pattern variable contains the most recent bling pattern that has been assigned
        self.pattern = None
        
        # initialize the bling command parameters to provide reasonable default values for each
        # setting
        self.params = {}
        self.init_params()
        
        self.bling_patterns = bling_patterns.BlingPatterns(self)

        ###### TODO: remove these variables after converting the menu processing to use #####
        ######       the new patterns                                                   #####
        # animation object containing pattern to apply to the LEDs
        self.anim = None

        # flag to indicate whether the selected mode requires animation. Displaying a solid color across all or a range
        # of LEDs does not require animation
        self.animate = True
Exemple #2
0
def init_pixels(type, npixels=200):
    try:
        if type == "spi" or type == "raspberry":
            LED_DRIVER = DriverWS2801(npixels)
        else:
            raise ValueError("device type has not in {}".format(
                str(['spi', 'raspberry'])))
    except ImportError as e:
        print("Not able to initialize the driver. Error{}".format(
            str(e.message)))
        print("Use bibliopixel.drivers.dummy_driver")
        LED_DRIVER = DriverDummy(npixels)

    return LEDStrip(LED_DRIVER, masterBrightness=BRIGHTNESS)
def main():
    global led, presets

    parser = argparse.ArgumentParser(description='AllPixel OSC controller',
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--port', dest='port', default=7676,
                        help='Port to listen on')
    parser.add_argument('--num-leds', dest='num_leds', default=194,
                        help='Number of LEDs on strip')
    args = parser.parse_args()

    signal(SIGINT, sig_exit)
    signal(SIGTERM, sig_exit)

    osc = Server(args.port, UDP)
    osc.add_method("/off", None, set_off)
    osc.add_method("/presets", None, set_preset)

    driver = DriverSerial(type=LEDTYPE.WS2801, num=int(args.num_leds), c_order=ChannelOrder.GRB)
    led = LEDStrip(driver)

    presets += [
        LarsonScanners.LarsonScanner(led, color=colors.Cyan, tail=60),
        LarsonScanners.LarsonRainbow(led, tail=60),
        Rainbows.Rainbow(led),
        PartyMode.PartyMode(led, [colors.White, colors.Blue]),
        FireFlies.FireFlies(led, [colors.Gold, colors.Red], width=12, count=4),
        WhiteTwinkle.WhiteTwinkle(led),
        Wave.Wave(led, color=colors.Cyan, cycles=4),
        ColorChase.ColorChase(led, color=colors.Cyan, width=20)
    ]

    set_preset('', [0, 50], '', '')

    while True:
        osc.recv(100)
        self._brightness +=  self._dir * amt
        if self._brightness < 0:
            self._brightness = 0
            self._dir = 1
        elif self._brightness > 255:
             self._brightness = 255
             self._dir = -1            
             
        self._led.changeBrightness(self._brightness)
        #print "buffer {} unscaled {}".format(self._led.buffer[0:3],  self._led.unscaledbuffer[0:3])
        self._step += amt
        self._count += 1

if __name__ == '__main__':
    driver = DriverVisualizer(160, pixelSize=62, stayTop=False, maxWindowWidth=1024)
    led = LEDStrip(driver, masterBrightness=255, masterBrightnessLimit=200)

    w1 = Worm(led, [(255, 100, 50)]*10)
    w2 = Worm(led, [(2, 100, 250)]*10)
    dim = dimLights(led)

#    animQ.addAnim(w2, fps=10, max_steps=40)
    #animQ.addAnim(dim, amt=5, fps=30, max_steps=70)
#    animQ.addAnim(w1, fps=5, max_steps = 10)
 
 
    animQ = AnimationQueue(led)
    animQ.addAnim(dim, amt=10, fps=5, max_steps=40, threaded=True)
    animQ.addAnim(w1, fps=5, max_steps=20)
    animQ.addAnim(w2, fps=5, max_steps=20)
                     
    tp = range(ind(nleft, ntop), ind(nright, ntop), 1)
    sright = range(ind(nright, ntop), ind(nright, nbot), -rounds)
    bt = range(ind(nright, nbot), ind(nleft, nbot), -1)
    path = sleft+tp+sright+bt
    if len(path) == 0:
        path = [ind(nleft, nbot)]
    path = map(lambda x: (shift+x) % nled, path)
    log.logger.info("pathgen({}, {}, {}, {}, {}) is {}".format(nleft, nright, nbot, ntop, shift, path))
    return path 

if True: #__name__ == '__main__':  
    drivermaster = DriverVisualizer(160, pixelSize=62, stayTop=False, maxWindowWidth=1024)
    # using pixelSize 62 and changed code of visualizer.py to have maxWindowWidth=1024
    #drivermaster = DriverVisualizer(160, pixelSize=31, stayTop=False)
    #ledmaster = LEDStrip(drivermaster, threadedUpdate=True)
    ledmaster = LEDStrip(drivermaster)
    
    lnin = [255, 222, 200, 150, 125]
    bluedimming = [(0, 0, i) for i in lnin]
    bluedimming = [(0, 0, 0) for i in lnin]
    reddimming = [(i, 0, 0) for i in lnin]
    greendimming = [(0, i, 0) for i in lnin]
    cyandimming = [(0, i, i) for i in lnin]
    whitedimming = [(i, i, i) for i in lnin]
    
    # Worm arguments
    wormblue = (bluedimming, pathgen(5, 10, 0, 9), 1, 1, 6)
    wormred = (reddimming, pathgen(1, 14, 1, 8), 1, 1, 2)
    wormgreen = (greendimming, pathgen(2, 13, 2, 7), 1, 1, 3)
    wormcyan = (cyandimming, pathgen(3, 12, 3, 6), 1, 1, 4)
    wormwhite = (whitedimming, pathgen(4, 11, 4, 5), 1, 1, 5)
Exemple #6
0
import time
from operator import or_, ior, ixor
import matplotlib.pyplot as plt
import BiblioPixelAnimations.matrix.bloom as BA
import BiblioPixelAnimations.strip.Wave as WA

import sys
sys.path.append('D:\Bill\SpyderWork')  # to get wormanimclass
from wormanimclass import Worm, pathgen

drivermaster = DriverVisualizer(160,
                                pixelSize=62,
                                stayTop=False,
                                maxWindowWidth=1024)
# drivermaster = DriverVisualizer(160, pixelSize=31, stayTop=False, , maxWindowWidth=512)
ledmaster = LEDStrip(drivermaster, threadedUpdate=False)

# segment colors
lnin = [255, 222, 200, 150, 125]
bluedimming = [(0, 0, i) for i in lnin]
reddimming = [(i, 0, 0) for i in lnin]
greendimming = [(0, i, 0) for i in lnin]
cyandimming = [(0, i, i) for i in lnin]
whitedimming = [(i, i, i) for i in lnin]

# Worm arguments = (segment colors, path, cyclelength, direction, height)
wormblue = (bluedimming, None, 1, 1, 6)
wormred = (reddimming, None, 1, 1, 2)
wormgreen = (greendimming, None, 1, 1, 3)
wormcyan = (cyandimming, None, 1, 1, 4)
wormwhite = (whitedimming, None, 1, 1, 5)
        path = [ind(nleft, nbot)]
    path = map(lambda x: (shift + x) % nled, path)
    log.logger.info("pathgen({}, {}, {}, {}, {}) is {}".format(
        nleft, nright, nbot, ntop, shift, path))
    return path


if True:  #__name__ == '__main__':
    drivermaster = DriverVisualizer(160,
                                    pixelSize=62,
                                    stayTop=False,
                                    maxWindowWidth=1024)
    # using pixelSize 62 and changed code of visualizer.py to have maxWindowWidth=1024
    #drivermaster = DriverVisualizer(160, pixelSize=31, stayTop=False)
    #ledmaster = LEDStrip(drivermaster, threadedUpdate=True)
    ledmaster = LEDStrip(drivermaster)

    lnin = [255, 222, 200, 150, 125]
    bluedimming = [(0, 0, i) for i in lnin]
    bluedimming = [(0, 0, 0) for i in lnin]
    reddimming = [(i, 0, 0) for i in lnin]
    greendimming = [(0, i, 0) for i in lnin]
    cyandimming = [(0, i, i) for i in lnin]
    whitedimming = [(i, i, i) for i in lnin]

    # Worm arguments
    wormblue = (bluedimming, pathgen(5, 10, 0, 9), 1, 1, 6)
    wormred = (reddimming, pathgen(1, 14, 1, 8), 1, 1, 2)
    wormgreen = (greendimming, pathgen(2, 13, 2, 7), 1, 1, 3)
    wormcyan = (cyandimming, pathgen(3, 12, 3, 6), 1, 1, 4)
    wormwhite = (whitedimming, pathgen(4, 11, 4, 5), 1, 1, 5)
Exemple #8
0
#driver = DriverLPD8806(160,c_order = ChannelOrder.GRB, SPISpeed = 16)
#driver = DriverVisualizer(160, 16, 10, 30, stayTop=True)
# by setting to 160 pixels and size 31 will produce 10 h, 16 wide
#  wrapped
driver = DriverVisualizer(160, pixelSize=31, stayTop=True)

# not much difference whether set threadedUpdate to True or False
#  But CANT stop the updateThread see end of code
#led = LEDStrip(driver, threadedUpdate=True) 
led = LEDStrip(driver)

#print led.buffer
#print len(led.buffer)
#print led.bufByteCount

ledfake = LEDStrip(driver)
def dummy():
    print 'hello'
    
ledfake.update = dummy


# Set up 3 worms - my 160 led strip is wound in a spiral around a cylinder approximately 
# 10 times. Led's x+16 is above and only slightly to left of led x. While led x+17 is above
# and a bit more to right. 

#lnin = [255, 255>>1, 255>>2, 255>>3, 255>>4, 255>>5, 255>>6 ]
lnin = [255, 222, 200, 150, 125]
bluedimming = [(0,0,i) for i in lnin ]
reddimming = [(i,0,0) for i in lnin ]
greendimming = [(0,i,0) for i in lnin ]
Exemple #9
0
        self._activecount += amt
        self._activecount %= self._cyclelen
        self._step += amt


#load driver and controller and animation queue
#driver = DriverLPD8806(160,c_order = ChannelOrder.GRB, SPISpeed = 16)
#driver = DriverVisualizer(160, 16, 10, 30, stayTop=True)
# by setting to 160 pixels and size 31 will produce 10 h, 16 wide
#  wrapped
driver = DriverVisualizer(160, pixelSize=31, stayTop=True)

# not much difference whether set threadedUpdate to True or False
#  But CANT stop the updateThread see end of code
#led = LEDStrip(driver, threadedUpdate=True)
led = LEDStrip(driver)

#print led.buffer
#print len(led.buffer)
#print led.bufByteCount

ledfake = LEDStrip(driver)


def dummy():
    print 'hello'


ledfake.update = dummy

# Set up 3 worms - my 160 led strip is wound in a spiral around a cylinder approximately
Exemple #10
0
thanksgiving = [(00,102,51), (00,204,153), (00,204,102)]

class Kitt(BaseStripAnim):
    def __init__(self, led):
        super(Kitt, self).__init__(led)
        self.length = 32*5

    def step(self, amt=1):
        middle = self.length / 2
        self._led.set(middle, orange)
        self._step += amt

speed = 0.001
speed = 16.0
led = LEDStrip(DriverLPD8806(32*5, dev="/dev/spidev0.0", SPISpeed=speed))
#anim = StripTest(led)
#anim = Halloween1(led)

from strip_animations import *
anim = RainbowCycle(led)
#anim = ColorPattern(led, [purple, orange], 10)
#anim = ColorPattern(led, thanksgiving, 32)
anim = ColorFade(led, [blue], 2) # maybe?
#anim = ColorFade(led, thanksgiving, 3)
#anim = ColorChase(led, orange, 10)
anim = FireFlies(led, [blue, red], width=3, count=2)
#anim = LarsonScanner(led, blue, 10) # cat toy
#anim = LarsonScanner(led, orange, 10) # cat toy
#anim = Kitt(led)
#anim = LarsonRainbow(led)
Exemple #11
0
class Bling(object):

    def __init__(self, num_leds, num_segments=None, brightness=255):
        # set the total number of LEDs in the strip
        self.num_leds = num_leds
        self.num_segments = num_segments
        self.brightness = brightness
        
        # initialize the list of segment overrides to include all, left and right.
        # This segment list is used to override other segment control based on
        # the bling command itself. For example, we may want to apply a pattern to either
        # the left or right side of the robot.
        led_half = int((self.num_leds/2))
        led_quarter = int((self.num_leds/4))
        self.segments = { 'ALL':          ( 0, self.num_leds ),
                          'LEFT':         ( 0, led_half-1 ),
                          'RIGHT':        ( led_half, int(self.num_leds) ),
                          'RIGHT_FRONT':  ( 0, (led_quarter-1) ),
                          'RIGHT_REAR':   ( led_quarter, (led_quarter+led_quarter-1) ),
                          'LEFT_REAR':    ( (led_quarter*2), ((led_quarter*2)+led_quarter-1) ),
                          'LEFT_FRONT':   ( (led_quarter*3), ((led_quarter*3)+led_quarter-1) )
                        }

        # initialize the driver with the type and count of LEDs that we are using
        # also, define the correct RGB channel order once you have run the test pattern
        # the other parameters are set based on the controlling application. We're using
        # the RaspberryPi as the controller with the SPI port
        self.driver = DriverLPD8806(num=self.num_leds, c_order = ChannelOrder.GRB, SPISpeed=2, use_py_spi=True, dev='/dev/spidev0.0')

        # we are using the LED strip configuration, other available configurations include an LED matrix,
        # but we have only a single strip at this time
        self.led = LEDStrip(self.driver, threadedUpdate=True, masterBrightness=self.brightness)

        # the frames per second is used to control how fast the animation runs. some of the animations
        # work better when run at a low frames per second
        self.fps = None

        # the pattern variable contains the most recent bling pattern that has been assigned
        self.pattern = None
        
        # initialize the bling command parameters to provide reasonable default values for each
        # setting
        self.params = {}
        self.init_params()
        
        self.bling_patterns = bling_patterns.BlingPatterns(self)

        ###### TODO: remove these variables after converting the menu processing to use #####
        ######       the new patterns                                                   #####
        # animation object containing pattern to apply to the LEDs
        self.anim = None

        # flag to indicate whether the selected mode requires animation. Displaying a solid color across all or a range
        # of LEDs does not require animation
        self.animate = True

    def get_num_leds(self):
        return self.num_leds

    def get_num_segments(self):
        return self.num_segments

    def get_segment_size(self):
        return int(self.num_leds/self.num_segments)

    def get_segment_min_max_led( self, num_segments, segment_index ):
        segment_leds = int(self.num_leds/num_segments)
        min_led = segment_leds*segment_index
        max_led = min_led+segment_leds-1
        return min_led,max_led
        
    def set_brightness(self, level):
        self.led.setMasterBrightness(level)
        self.brightness = level

    def stop_animation(self):
        # reset the brightness level back to the default value that was set upon initialization
        self.led.setMasterBrightness(self.brightness)

        if self.pattern is not None:
            self.pattern.stop()
        else:
            if self.anim is not None:
                self.anim.stopThread(wait=True)
            self.led.all_off()
            self.led.update()

    def get_leds_from_segment(self, segment_str):
        segment_leds = [0,-1]
        try:
            segment_def = self.segments[segment_str]
            segment_leds[0] = segment_def[0]
            segment_leds[1] = segment_def[1]
        except:
            # if the specified segment doesn't exist, return all LEDs
            pass
            segment_leds = [0,-1]
        return segment_leds

    def init_params(self):
        self.params['Pattern'] = 'Error'
        self.params['Segment'] = 'All'
        self.params['Color'] = 'Error'
        self.params['Speed'] = 'Medium'
        self.params['Min'] = '0'
        self.params['Max'] = '100'
        self.params['Brightness'] = str(self.brightness)

    def apply_min_max_params(self, leds):
        # Re-calculate the minimum and maximum LED values by applying any
        # specified min/max percentage parameter setting
        min_param = int(self.params['Min'])
        max_param = int(self.params['Max'])
        if min_param > 100:
            print 'Invalid  Minimum Setting: %d, Must be 0-100' % min_param
            min_param = 0
        if max_param > 100:
            print 'Invalid  Maximum Setting: %d, Must be 0-100' % max_param
            max_param = 100
        led_range = leds[1]-leds[0]
        min_adjust=0
        max_adjust=0
        if min_param is not 0:
            min_adjust = int((float(led_range)*(min_param)/100)+1)
            #min_adjust = int(float((min_param/led_range)*100))
            leds[0] += min_adjust
        if max_param is not 100:
            max_adjust = int((float(led_range)*(100-max_param)/100)+1)
            leds[1] -= max_adjust
        return leds
    
    def process_cmd(self, cmd_str):
        result = 'OK'

        # start by starting any animation that is already running
        self.stop_animation()

        # re-initialize the animation parameters to the default settings
        self.init_params()
        
        try:
            # Parse command string into parameter list
            print 'Command: %s' % cmd_str
            cmd_params=cmd_str.split(',')
            for param in cmd_params:
                name,value=param.split('=')
                self.params[name.title()] = value.upper()
    
            if self.params['Pattern'] == 'OFF':
                # if the patter is OFF, then simply return. we have already turned off
                # the LEDs
                return result

            # process the command based on the provided parameters
            # first get the specified pattern
            self.pattern = self.bling_patterns.get_pattern(self.params['Pattern'].upper())
            
            # process the segment parameter, getting the list of LEDs that will be
            # controlled by this command
            leds = self.get_leds_from_segment( self.params['Segment'])
            leds = self.apply_min_max_params( leds )

            # if the pattern specifies a brightness level, then update the level for the entire strip
            try:
                brightness = int(self.params['Brightness'])
                self.led.setMasterBrightness(brightness)
            except ValueError:
                print 'Invalid Brightness Value: %d' % brightness
            except KeyError:
                pass

            self.pattern.setup( self.led, self.params['Color'], self.params['Speed'], leds[0], leds[1], self.num_segments )

            # run the configured pattern
            self.pattern.run()
    
        except:
            raise
            # catch any thrown exceptions and generate the error pattern
            print 'Error processing command: %s' % cmd_str
            self.pattern = self.bling_patterns.get_pattern('Error')
            self.pattern.setup(self.led, 'RED')
            self.pattern.run()

            result = 'ERROR'

        return result

 
    # TODO: Most of the following code will be removed once we complete the implementation of the pattern
    # classes and convert the menu over to using the pattern classes insead
    def menu(self):
        menu_str  = '\n'
        menu_str += '                              Available Bling Patterns\n\n'
        menu_str += '(1)  Alternates (two alternating colors)        '
        menu_str += '(14) Linear Rainbow (another variation)\n'
        menu_str += '(2)  Color Chase (one LED moving end to end)    '
        menu_str += '(15) Search Lights (colors moving up/down)\n'
        menu_str += '(3)  Color Fade (one color fading in/out)       '
        menu_str += '(16) Wave (colors moving up/down)\n'
        menu_str += '(4)  Color Pattern (mix of colors)              '
        menu_str += '(17) Solid Red (one color on all LEDs)\n'
        menu_str += '(5)  Color Wipe (one color moving up/down)      '
        menu_str += '(18) Solid Yellow (one color on all LEDs)\n'
        menu_str += '(6)  Fire Flies (colors randomly blinking)      '
        menu_str += '(19) Solid Green (one color on all LEDs)\n'
        menu_str += '(7)  Scanner (one color moving up/down)         '
        menu_str += '(20) Test Strip (test pattern for RGB cal.)\n'
        menu_str += '(8)  Rainbow Scanner (colors moving up/down)    '
        menu_str += '(21) Blinking Green (slow on all LEDs)\n'
        menu_str += '(9)  Ping Pong (colors bouncing around)         '
        menu_str += '(22) Blinking Green (medium on all LEDs)\n'
        menu_str += '(10) Party Mode (colors blinking on/off)        '
        menu_str += '(23) Blinking Green (fast on all LEDs)\n'
        menu_str += '(11) Rainbow Halves (strand divided in two      '
        menu_str += '(24) Blinking Green (medium on left LEDs)\n'
        menu_str += '(12) Rainbow (set of colors moving end to end)  '
        menu_str += '(25) Blinking Green (medium on right LEDs)\n'
        menu_str += '(13) Rainbow Cycles (variation of above)        '
        menu_str += '\n'
        menu_str += '\n'
        menu_str += '\n'
    
        return menu_str


    def menu_select( self, menu_selection ):
        result = 'OK'

        if menu_selection == 1:
            # Alternates
            result = self.process_cmd('Pattern=Alternates,Color=TEAMCOLORS,Speed=MEDIUM,Segment=ALL')
        elif menu_selection == 2:
            # Color Chase
            result = self.process_cmd('Pattern=ColorChase,Color=GREEN,Speed=MEDIUM')
        elif menu_selection == 3:
            # Color Fade
            result = self.process_cmd('Pattern=ColorFade,Color=RAINBOW,Speed=MEDIUM')
        elif menu_selection == 4:
            # Color Pattern
            result = self.process_cmd('Pattern=ColorPattern,Color=RAINBOW,Speed=MEDIUM')
        elif menu_selection == 5:
            # Color Wipe
            result = self.process_cmd('Pattern=ColorWipe,Color=GREEN,Speed=MEDIUM')
        elif menu_selection == 6:
            # Fire Flies
            result = self.process_cmd('Pattern=FireFLies,Color=RAINBOW,Speed=MEDIUM')
        elif menu_selection == 7:
            # Scanner
            result = self.process_cmd('Pattern=Scanner,Color=BLUE,Speed=MEDIUM')
        elif menu_selection == 8:
            # Rainbow Scanner
            result = self.process_cmd('Pattern=RainbowScanner,Color=RAINBOW,Speed=MEDIUM')
        elif menu_selection == 9:
            # Ping Pong
            result = self.process_cmd('Pattern=PingPong,Color=BLUE,Speed=MEDIUM')
        elif menu_selection == 10:
            # Party Mode
            result = self.process_cmd('Pattern=PartyMode,Color=RAINBOW,Speed=MEDIUM')
        elif menu_selection == 11:
            # Rainbow Halves
            result = self.process_cmd('Pattern=RainbowHalves,Color=RAINBOW,Speed=MEDIUM')
        elif menu_selection == 12:
            # Rainbow
            result = self.process_cmd('Pattern=Rainbow,Color=RAINBOW,Speed=MEDIUM')
        elif menu_selection == 13:
            # Rainbow Cycle
            result = self.process_cmd('Pattern=RainbowCycle,Color=RAINBOW,Speed=MEDIUM')
        elif menu_selection == 14:
            # Linear Rainbow
            result = self.process_cmd('Pattern=LinearRainbow,Color=RAINBOW,Speed=MEDIUM')
        elif menu_selection == 15:
            # Search Lights
            result = self.process_cmd('Pattern=SearchLights,Color=RAINBOW,Speed=MEDIUM')
        elif menu_selection == 16:
            # Wave
            result = self.process_cmd('Pattern=Wave,Color=BLUE,Speed=MEDIUM')
        elif menu_selection == 17:
            # Solid Red
            result = self.process_cmd('Pattern=Solid,Color=RED')
        elif menu_selection == 18:
            # Solid Yellow
            result = self.process_cmd('Pattern=Solid,Color=YELLOW')
        elif menu_selection == 19:
            # Solid Green
            result = self.process_cmd('Pattern=Solid,Color=GREEN')
        elif menu_selection == 20:
            # Test Pattern
            # This animation is used to test the strip and the color order
            result = self.process_cmd('Pattern=Test,Color=TEST,Speed=MEDIUM')
        elif menu_selection == 21:
            result = self.process_cmd('Pattern=Blinking,Color=PURPLE,Speed=SLOW,Segment=ALL')
        elif menu_selection == 22:
            result = self.process_cmd('Pattern=Blinking,Color=GREEN,Speed=MEDIUM,Segment=ALL')
        elif menu_selection == 23:
            result = self.process_cmd('Pattern=Blinking,Color=GREEN,Speed=FAST,Segment=ALL')
        elif menu_selection == 24:
            result = self.process_cmd('Pattern=Blinking,Color=GREEN,Speed=MEDIUM,Segment=LEFT')
        elif menu_selection == 25:
            result = self.process_cmd('Pattern=Blinking,Color=GREEN,Speed=MEDIUM,Segment=RIGHT')
        elif menu_selection == 99:
            # All off
            result = self.process_cmd('Pattern=OFF')
        else:
            raise ValueError
            result = 'ERROR'

        return result
Exemple #12
0
wormredpixmap = pathgen(1, 14, 1, 8)
wormgreenpixmap = pathgen(2, 13, 2, 7)
wormcyanpixmap = pathgen(3, 12, 3, 6)
wormwhitepixmap = pathgen(4, 11, 4, 5)

# List of triple (animation arguments, slavedriver argument, fps)
wormdatalist = [(wormblue, wormbluepixmap, 24), (wormred, wormredpixmap, 20),
                (wormgreen, wormgreenpixmap, 16),
                (wormcyan, wormcyanpixmap, 12),
                (wormwhite, wormwhitepixmap, 8)]

# dummy strips must each have their own slavedriver as thread is attached
# to the driver
# Here using worm path for pixmap
ledslaves = [
    LEDStrip(DriverSlave(len(sarg), pixmap=sarg, pixheights=-1),
             threadedUpdate=True) for aarg, sarg, fps in wormdatalist
]

# dummy  LED strips must each have their own slavedrivers
ledslaves = [LEDStrip(DriverSlave(len(sarg), pixmap=sarg, pixheights=-1), threadedUpdate=False) \
             for aarg, sarg, fps in wormdatalist]

# Make the animation list
# Worm animations as list pairs (animation instances, fps) added
animationlist = [(Worm(ledslaves[i], *wd[0]), wd[2])
                 for i, wd in enumerate(wormdatalist)]

ledslaveb = LEDMatrix(DriverSlave(160, None, 0),
                      width=16,
                      height=10,
                      threadedUpdate=False)
	if self._direction == 1:
            for j in range(self._pos):
       	        diff = min(self._tail, abs(j - self._pos)) 
                brightness = (512 >> diff) -1
                self._led.set(min(self._ledCount-1, j), (brightness, 0, 0))
            self._pos = self._pos+1

	    if self._pos >= self._ledCount + self._tail:
		self._direction = 0

	if self._direction == 0:
	    for j in range(self._ledCount-1, self._pos, -1):
                diff = min(self._tail, abs(j - self._pos))
                brightness = (512 >> diff) - 1
                self._led.set(max(0, j), (brightness, 0, 0))
            self._pos = self._pos-1
	
	    if self._pos <= -self._tail:
		self._direction = 1

driver = DriverLPD8806(32, c_order = ChannelOrder.GRB)
led = LEDStrip(driver, threadedUpdate = True)
anim = KnightRiderScanBar(led)

try:
    anim.run()
except KeyboardInterrupt:
    #Ctrl+C will exit the animation and turn the LEDs offs
    led.all_off()
    led.update()
Exemple #14
0
    bt = range(ind(nright, nbot), ind(nleft, nbot), -1)
    path = sleft + tp + sright + bt
    if len(path) == 0:
        path = [ind(nleft, nbot)]
    path = map(lambda x: (shift + x) % nled, path)
    log.logger.info("pathgen({}, {}, {}, {}, {}) is {}".format(
        nleft, nright, nbot, ntop, shift, path))
    return path


if __name__ == '__main__':
    drivermaster = DriverVisualizer(160, pixelSize=62, stayTop=False)
    # dummy strips must each have their own slavedriver as thread is attached
    # to the driver
    ledslaves = [
        LEDStrip(DriverSlave(160, 0), threadedUpdate=True) for _ in range(5)
    ]
    ledmaster = LEDStrip(drivermaster, threadedUpdate=True)

    lnin = [255, 222, 200, 150, 125]
    bluedimming = [(0, 0, i) for i in lnin]
    reddimming = [(i, 0, 0) for i in lnin]
    greendimming = [(0, i, 0) for i in lnin]
    cyandimming = [(0, i, i) for i in lnin]
    whitedimming = [(i, i, i) for i in lnin]

    wormblue = Worm(ledslaves[0], bluedimming, pathgen(5, 10, 0, 9), 1, 1)
    wormred = Worm(ledslaves[1], reddimming, pathgen(1, 14, 1, 8), 1, 1)
    wormgreen = Worm(ledslaves[2], greendimming, pathgen(2, 13, 2, 7), 1, 1)
    wormcyan = Worm(ledslaves[3], cyandimming, pathgen(3, 12, 3, 6), 1, 1)
    wormwhite = Worm(ledslaves[4], whitedimming, pathgen(4, 11, 4, 5), 1, 1)
Exemple #15
0
from bibliopixel.led import *
from bibliopixel.animation import StripChannelTest
from bibliopixel.drivers.WS2801 import *
from bibliopixel import LEDStrip
import bibliopixel.colors as colors
import sys ## for param

numLeds = 25
driver = DriverWS2801(numLeds, c_order = ChannelOrder.RGB)
led = LEDStrip(driver)

r = int(sys.argv[1])
g = int(sys.argv[2])
b = int(sys.argv[3])

led.fillRGB(r,g,b)
led.update()
Exemple #16
0
    sleft = range(ind(nleft, nbot), ind(nleft, ntop), rounds)
    tp = range(ind(nleft, ntop), ind(nright, ntop), 1)
    sright = range(ind(nright, ntop), ind(nright, nbot), -rounds)
    bt = range(ind(nright, nbot), ind(nleft, nbot), -1)
    path = sleft+tp+sright+bt
    if len(path) == 0:
        path = [ind(nleft, nbot)]
    path = map(lambda x: (shift+x) % nled, path)
    log.logger.info("pathgen({}, {}, {}, {}, {}) is {}".format(nleft, nright, nbot, ntop, shift, path))
    return path 

drivermaster = DriverVisualizer(160, pixelSize=62, stayTop=False, maxWindowWidth=1024)
# using pixelSize 62 and changed code of visualizer.py to have maxWindowWidth=1024
#drivermaster = DriverVisualizer(160, pixelSize=31, stayTop=False)
#ledmaster = LEDStrip(drivermaster, threadedUpdate=True)
ledmaster = LEDStrip(drivermaster)

lnin = [255, 222, 200, 150, 125]
bluedimming = [(0, 0, i) for i in lnin]
bluedimming = [(0, 0, 0) for i in lnin]
reddimming = [(i, 0, 0) for i in lnin]
greendimming = [(0, i, 0) for i in lnin]
cyandimming = [(0, i, i) for i in lnin]
whitedimming = [(i, i, i) for i in lnin]

# Worm arguments
wormblue = (bluedimming, pathgen(5, 10, 0, 9), 1, 1, 6)
wormred = (reddimming, pathgen(1, 14, 1, 8), 1, 1, 2)
wormgreen = (greendimming, pathgen(2, 13, 2, 7), 1, 1, 3)
wormcyan = (cyandimming, pathgen(3, 12, 3, 6), 1, 1, 4)
wormwhite = (whitedimming, pathgen(4, 11, 4, 5), 1, 1, 5)
from bibliopixel import *
from bibliopixel.drivers.LPD8806 import *
from bibliopixel import LEDStrip
import bibliopixel.colors as colors
import csv
import numpy as np

# In[2]:

LedsPerSide = 8

# In[3]:

NumLeds = LedsPerSide * 4 * 2  ##* 4 sides * 2 levels
driver = DriverLPD8806(NumLeds)
led = LEDStrip(driver)

# ### Import data

# In[4]:

clean_ratio = []
with open('Carbon_lbsperMW_monthly_average.csv') as csvfile:
    reader = csv.reader(csvfile, delimiter=',')
    for row in reader:
        clean_ratio.append(row)
        ## Column 1: Month
        ## Column 2: Lbs CO2 / MW of energy
        ## Column 3: Year

# ### Generating color scale
Exemple #18
0
# load driver and controller and animation queue
# driver = DriverLPD8806(160,c_order = ChannelOrder.GRB, SPISpeed = 16)

# by setting to 160 pixels and size 31 will produce 10 h, 16 wide
#  wrapped
#driver = DriverVisualizer(160, pixelSize=31, stayTop=True)
driver = DriverVisualizer(160, pixelSize=62, stayTop=True)

nbytes_load = 3 * 160

log.logger.info('before led instantiation {}'.format(', '.join(
    re.findall('(?<=<).*?\(.*?(?=,)', str(threading.enumerate())))))

#  True is faster! threadedUpdate to True or False
#  But CANT stop the updateThread see end of code
led = LEDStrip(driver, threadedUpdate=True)
#led = LEDStrip(driver)

log.logger.info('after led instantiation {}'.format(', '.join(
    re.findall('(?<=<).*?\(.*?(?=,)', str(threading.enumerate())))))

log.logger.info('before animation instantiation {}'.format(', '.join(
    re.findall('(?<=<).*?\(.*?(?=,)', str(threading.enumerate())))))

nostepAnim = NoStep(led)
#nostepAnim2 = NoStep(led)

log.logger.info('after animation instantiation {}'.format(', '.join(
    re.findall('(?<=<).*?\(.*?(?=,)', str(threading.enumerate())))))

start = time.time()
Exemple #19
0

client = opc.Client('localhost:7890')

#digital strip stuff

#init driver with the type and count of LEDs you're using
numLeds = 120
driver = DriverLPD8806(numLeds,
                       c_order=ChannelOrder.BRG,
                       use_py_spi=True,
                       dev="/dev/spidev0.0",
                       SPISpeed=16)

#init controller
led = LEDStrip(driver)

#init animation; replace with whichever animation you'd like to use
anim = LarsonScanners.LarsonScanner(led, (255, 0, 0))


# Define a function for the thread
class thread_lights(threading.Thread):
    def __init__(self, threadID, name, counter):
        threading.Thread.__init__(self)
        self.threadID = threadID
        self.name = name
        self.counter = counter

    def run(self):
        print "Starting " + self.name
Exemple #20
0
wormbluepixmap = pathgen(3, 12, 0, 9)
wormredpixmap = pathgen(4, 11, 1, 8)
wormgreenpixmap = pathgen(5, 10, 2, 7)
wormcyanpixmap = pathgen(6, 9, 3, 6)
wormwhitepixmap = pathgen(7, 8, 4, 5)

# List of triple (animation arguments, slavedriver argument, fps)
wormdatalist = [(wormblue, wormbluepixmap, 20), (wormred, wormredpixmap, 20),
                (wormgreen, wormgreenpixmap, 19),
                (wormcyan, wormcyanpixmap, 21),
                (wormwhite, wormwhitepixmap, 16)]

# dummy  LED strips must each have their own slavedrivers
ledslaves = [
    LEDStrip(DriverSlave(len(sarg), pixmap=sarg, pixheights=-1),
             threadedUpdate=False,
             masterBrightness=255) for aarg, sarg, fps in wormdatalist
]

# Make the animation list
# Worm animations as list pairs (animation instances, fps) added
animationlist = [(Worm(ledslaves[i], *wd[0]), wd[2])
                 for i, wd in enumerate(wormdatalist)]


# needed to run on pixelweb
def genParams():
    return {"start": 0, "end": -1, "animcopies": animationlist}


if __name__ == '__main__':
Exemple #21
0
#!/usr/bin/env python

from daylight import SunRange
from bibliopixel.drivers.visualizer import *
from bibliopixel import LEDStrip
import time

num_leds = 10

driver = DriverVisualizer(num_leds, stayTop=True)
led_strip = LEDStrip(driver)
pdx = SunRange()

def nightRemainingRGB():
    return (178, 102, 255)

def nightFadedRGB():
    return (76, 0, 153)

def dayRemainingRGB():
    return (255, 255, 51)

def dayFadedRGB():
    return (150, 150, 0)


led_strip.fill(dayRemainingRGB())
led_strip.update()

for i in range(0, num_leds):
    time.sleep(1)
Exemple #22
0
wavewhite = ((255, 255, 255), 1)

# Wave slave driver arguments
wavebluepixmap = pathgen(1, 15, 0, 9)
waveredpixmap = pathgen(1, 14, 1, 8)
wavegreenpixmap = pathgen(2, 13, 2, 7)
wavecyanpixmap = pathgen(3, 12, 3, 6)
wavewhitepixmap = pathgen(4, 11, 4, 5)

# List of triple (animation arguments, slavedriver argument, fps)
wavedatalist = [(waveblue, wavebluepixmap, 5), (wavered, waveredpixmap, 6),
                (wavegreen, wavegreenpixmap, 7), (wavecyan, wavecyanpixmap, 8),
                (wavewhite, wavewhitepixmap, 9)]

# dummy  LED strips must each have their own slavedrivers
ledslaves = [LEDStrip(DriverSlave(len(sarg), pixmap=sarg, pixheights=-1), threadedUpdate=False) \
             for aarg, sarg, fps in wavedatalist]

# Make the animation list
# Wave animations as list pairs (animation instances, fps) added
animationlist = [(WA.Wave(ledslaves[i], *wd[0]), wd[2])
                 for i, wd in enumerate(wavedatalist)]


# needed to run on pixelweb
def genParams():
    return {"start": 0, "end": -1, "animcopies": animationlist}


if __name__ == '__main__':
    masteranimation = MasterAnimation(ledmaster, animationlist, runtime=2)
Exemple #23
0
from bibliopixel import log
log.setLogLevel(log.DEBUG)
from bibliopixel.led import *
from bibliopixel.animation import StripChannelTest
from bibliopixel.drivers.LPD8806 import *
from bibliopixel import LEDStrip
import bibliopixel.colors as colors
from bibliopixel.animation import BaseStripAnim

import math
import time
import random

#create driver for a 12 pixels
driver = DriverLPD8806(12, c_order=ChannelOrder.GRB)
led = LEDStrip(driver)
try:
    while True:
        led.fillRGB(150, 150, 150)
except KeyboardInterrupt:
    led.all_off()
    led.update()
from WormThreadTest import pathgen

DEBUG = 0

# Configurable values
# spi = spidev.SpiDev()
# note spi.writebytes, spi.xfer2, spi.xfer must take list NOT bytearray or
#   they will fail and terminate program
# Open SPI device
# spi.open(0,0)

driver = DriverVisualizer(160, pixelSize=62, stayTop=True)
# driver = DriverVisualizer(160, pixelSize=31, stayTop=True)

threadedUpdate = True
led = LEDStrip(driver, threadedUpdate=threadedUpdate)


class Worm:
    # colors a list the worm segment (starting with head) colors of 9 bit integers first hi 3 bits red level, next 3 green, next 3 blue
    #   color levels correspond to 0b0,0b1,0b11,0b111,0b1111,0b11111,0b111111,0b1111111
    # path a list of the LED indices over which the worm will travel (from 0 to 159 for 5 m strip)
    # cyclelen controls speed, worm movement only when LED upload cycles == 0 mod cyclelen
    # height (of worm segments) is same length as colors: higher value worms segments go over top of lower value worms
    #    equal value segments are xor'd with LED strip
    def __init__(self, colors, path, cyclelen, direction=1, height=None, strip_len=160):
        numzerobytes = (strip_len - 1) / 32 + 1  # number of zero bytes needed to reset spi
        reset = bytearray(numzerobytes)
        clear = bytearray(3 * strip_len)
        for cnt in range(len(clear)):
            # clear[cnt] = 0x80
Exemple #25
0
class LEDClock:
	'LEDClock'

	debug = True
	shadow = True
	
	totalLED = 25 
	startLED = 1
	endLED = 25

	hour = 0
	min = 0
	sec = 0

	hColor = (255, 255, 255)
	mColor = (128, 0, 0)
	sColor = (0, 0, 64)
   
	def __init__(self):
		driver = DriverWS2801(self.totalLED, c_order = ChannelOrder.RGB)
		self.LEDStrip = LEDStrip(driver)
		self.aLEDs =[]
		self.updateTime()
       
	def setHourLEDs(self):
		idx = self.startLED + self.hour * 2
		if (self.hour>=12): idx = idx - self.endLED + 1
		if (idx > self.endLED): idx =  idx - self.endLED
		self.aLEDs.append(LED(idx, self.hColor, "h")) 

	def setMinLEDs(self):
		idx = self.startLED + self.min * 24/60
		if (idx >= self.endLED): idx =  idx - self.endLED
		self.aLEDs.append(LED(idx, self.mColor, "m"))

	def setSecLEDs(self):
		idx = self.startLED + self.sec * 24/60
		if (idx >= self.endLED): idx =  idx - self.endLED
		self.aLEDs.append(LED(idx, self.sColor, "s"))        

	def updateLEDs(self):
		self.LEDStrip.all_off()
		del self.aLEDs[:]

		self.setHourLEDs()
		self.setMinLEDs()
		self.setSecLEDs()

		if (self.debug):
			print self.hour,":", self.min,":",self.sec
		
		for led in self.aLEDs:
			if (self.shadow):
				print "original: ",led.index
			led.index = self.endLED-led.index
			self.LEDStrip.set(led.index, led.color)
			
			if (self.debug):
				print led.type,":", led.index

		
		self.LEDStrip.update()
		
	def updateTime(self): 
		t = time.localtime(time.time())
		self.hour = t.tm_hour
		self.min = t.tm_min
		self.sec = t.tm_sec
		
	def update(self):
		time.sleep(2)
		self.updateTime()
		self.updateLEDs()
from bibliopixel import LEDStrip
import bibliopixel.colors as colors
import csv
import numpy as np


# In[2]:

LedsPerSide = 8


# In[3]:

NumLeds= LedsPerSide*4*2 ##* 4 sides * 2 levels
driver=DriverLPD8806(NumLeds)
led=LEDStrip(driver)


# ### Import data

# In[4]:

clean_ratio = [] 
with open('Carbon_lbsperMW_monthly_average.csv') as csvfile:
    reader = csv.reader(csvfile, delimiter=',')
    for row in reader:
        clean_ratio.append(row)
        ## Column 1: Month
        ## Column 2: Lbs CO2 / MW of energy
        ## Column 3: Year
Exemple #27
0
	def __init__(self):
		driver = DriverWS2801(self.totalLED, c_order = ChannelOrder.RGB)
		self.LEDStrip = LEDStrip(driver)
		self.aLEDs =[]
		self.updateTime()
from bibliopixel import LEDStrip, colors
from bibliopixel.drivers.serial_driver import DriverSerial, LEDTYPE, ChannelOrder
import time
from bibliopixel import log
log.setLogLevel(log.DEBUG)

driver = DriverSerial(LEDTYPE.NEOPIXEL, 350, c_order=ChannelOrder.RGB)
led = LEDStrip(driver, threadedUpdate=False)
led.setMasterBrightness(192)

try:
    while True:
        led.fill(colors.Red)
        led.update()
        time.sleep(0.5)
        led.fill(colors.Green)
        led.update()
        time.sleep(0.5)
        led.fill(colors.Blue)
        led.update()
        time.sleep(0.5)
        led.fill(colors.White)
        led.update()
        time.sleep(0.5)
except KeyboardInterrupt:
    led.all_off()
    led.update()
Exemple #29
0
# load driver and controller and animation queue
# driver = DriverLPD8806(160,c_order = ChannelOrder.GRB, SPISpeed = 16)

# by setting to 160 pixels and size 31 will produce 10 h, 16 wide
#  wrapped
#driver = DriverVisualizer(160, pixelSize=31, stayTop=True)
driver = DriverVisualizer(160, pixelSize=62, stayTop=True)

nbytes_load = 3 * 160

log.logger.info('before led instantiation {}'.format(', '.join(re.findall('(?<=<).*?\(.*?(?=,)',str(threading.enumerate())))))

#  True is faster! threadedUpdate to True or False
#  But CANT stop the updateThread see end of code
led = LEDStrip(driver, threadedUpdate=True)
#led = LEDStrip(driver)

log.logger.info('after led instantiation {}'.format(', '.join(re.findall('(?<=<).*?\(.*?(?=,)',str(threading.enumerate())))))



log.logger.info('before animation instantiation {}'.format(', '.join(re.findall('(?<=<).*?\(.*?(?=,)',str(threading.enumerate())))))

nostepAnim = NoStep(led)
#nostepAnim2 = NoStep(led)


log.logger.info('after animation instantiation {}'.format(', '.join(re.findall('(?<=<).*?\(.*?(?=,)',str(threading.enumerate())))))

start = time.time()

class Dummy(BaseStripAnim):
    def __init__(self, led, start=0, end=-1):
        super(Dummy, self).__init__(led, start, end)

    def step(self, amt=1):
        pass


if __name__ == '__main__':
    pixelWidth = 5
    masterBrightness = 155
    driver = DriverVisualizer(160, pixelSize=8, stayTop=True)
    led = LEDStrip(driver,
                   pixelWidth=pixelWidth,
                   masterBrightness=masterBrightness)
    dum = Dummy(led)

    print "masterBrightness is {}".format(dum._led.masterBrightness)
    dum._led.all_off()
    print "Pixel width {}".format(dum._led.pixelWidth)
    print "Numer of scaled pixels {}".format(dum._led.numLEDs)
    print "set scaled pixel 14 to red and scaled pixel 15 to green"
    print "these colors are scaled via masterBrightness"
    dum._led.set(14, (255, 0, 0))
    dum._led.update()
    px1c = (0, 255, 0)
    dum._led.set(15, px1c)
    dum._led.update()
    print "But when ask for pixel 14s color get {}".format(dum._led.get(14))
Exemple #31
0
from datetime import datetime

import tweepy
from tweepy import Stream
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler


# ### Define LED parameters

# In[13]:

LedsPerSide = 10
NumLeds= LedsPerSide*4*2 ##* 4 sides * 2 levels
driver=DriverLPD8806(NumLeds, ChannelOrder.BRG)
led=LEDStrip(driver)


# ### Authentication 1
# #### (From BrannonDorsey LoopLamp Project)

# In[14]:

consumer_key = "TroyIuC1l3i3laNlwl5mg"
consumer_secret = "qYRSTEHzHhTsL0CBcMnXxjqeY5UQ6U4C0kNvmPSG4K4"
access_token = "1230084602-UtUB4QdlhNkv1aLqrjS3eYoZ96APon5IhjOqBFt"
access_secret = "wscl1nV8gFO4kMhtJy7DjhQKkpJHB1fW5Jzb4RXZq8"


# ### Authentication 2
# #### (SmartLamp App)
    tp = range(ind(nleft, ntop), ind(nright, ntop), 1)
    sright = range(ind(nright, ntop), ind(nright, nbot), -rounds)
    bt = range(ind(nright, nbot), ind(nleft, nbot), -1)
    path = sleft+tp+sright+bt
    if len(path) == 0:
        path = [ind(nleft, nbot)]
    path = map(lambda x: (shift+x) % nled, path)
    log.logger.info("pathgen({}, {}, {}, {}, {}) is {}".format(nleft, nright, nbot, ntop, shift, path))
    return path 

if True: #__name__ == '__main__':  
    drivermaster = DriverVisualizer(160, pixelSize=62, stayTop=False, maxWindowWidth=1024)
    # using pixelSize 62 and changed code of visualizer.py to have maxWindowWidth=1024
    #drivermaster = DriverVisualizer(160, pixelSize=31, stayTop=False)
    #ledmaster = LEDStrip(drivermaster, threadedUpdate=True)
    ledmaster = LEDStrip(drivermaster)
    
    lnin = [255, 222, 200, 150, 125]
    bluedimming = [(0, 0, i) for i in lnin]
    bluedimming = [(0, 0, 0) for i in lnin]
    reddimming = [(i, 0, 0) for i in lnin]
    greendimming = [(0, i, 0) for i in lnin]
    cyandimming = [(0, i, i) for i in lnin]
    whitedimming = [(i, i, i) for i in lnin]
    
    # Worm arguments
    wormblue = (bluedimming, pathgen(5, 10, 0, 9), 1, 1, 6)
    wormred = (reddimming, pathgen(1, 14, 1, 8), 1, 1, 2)
    wormgreen = (greendimming, pathgen(2, 13, 2, 7), 1, 1, 3)
    wormcyan = (cyandimming, pathgen(3, 12, 3, 6), 1, 1, 4)
    wormwhite = (whitedimming, pathgen(4, 11, 4, 5), 1, 1, 5)
from WormThreadTest import pathgen

DEBUG = 0

# Configurable values
# spi = spidev.SpiDev()
# note spi.writebytes, spi.xfer2, spi.xfer must take list NOT bytearray or
#   they will fail and terminate program
# Open SPI device
# spi.open(0,0)

driver = DriverVisualizer(160, pixelSize=62, stayTop=True)
#driver = DriverVisualizer(160, pixelSize=31, stayTop=True)

threadedUpdate = True
led = LEDStrip(driver, threadedUpdate=threadedUpdate)

#def dum():
#    pass
#
#led.update = dum


class Worm:
    # colors a list the worm segment (starting with head) colors of 9 bit integers first hi 3 bits red level, next 3 green, next 3 blue
    #   color levels correspond to 0b0,0b1,0b11,0b111,0b1111,0b11111,0b111111,0b1111111
    # path a list of the LED indices over which the worm will travel (from 0 to 159 for 5 m strip)
    # cyclelen controls speed, worm movement only when LED upload cycles == 0 mod cyclelen
    # height (of worm segments) is same length as colors: higher value worms segments go over top of lower value worms
    #    equal value segments are xor'd with LED strip
    def __init__(self,
Exemple #34
0
from bibliopixel.animation import BaseStripAnim
from bibliopixel import LEDStrip
from bibliopixel.drivers.visualizer import DriverVisualizer
from bibliopixel import colors

from penner import OutBounce
import strip_animations as sa

speed = 16.0
led = LEDStrip(DriverVisualizer(32))
anim = sa.BubbleSort(led)

anim.run()
Exemple #35
0
# ### Shell commands to reset spidev

# In[ ]:

from subprocess import call
call(["sudo", "chmod", "a+rw", "/dev/spidev0.0"])


# ### Initial setup

# In[ ]:

numLeds= 10 * 10
driver=DriverLPD8806(numLeds, ChannelOrder.BRG)
led=LEDStrip(driver)

r = (0, 50, 0) # LEDs are GRB; 255 is too bright
g = (50, 0, 0)
b = (0, 0, 50)


# ### Each LED turns on serially
# ####Once done they all flash ON & OFF till user ends the program with CTRL + C

# In[ ]:

led.fillRGB(0,0,0) # turns everything off
led.update()

for i in range (numLeds):
Exemple #36
0
import sys
import time

from bibliopixel import LEDStrip
from bibliopixel.drivers.driver_base import ChannelOrder
from bibliopixel.drivers.LPD8806 import DriverLPD8806

from loader import load
from matrix_animator import MatrixAnimator


FILENAME = 'first.bw'

driver = DriverLPD8806(num=32, c_order=ChannelOrder.BRG)
strip = LEDStrip(driver)


def main(filename):
    
    animator = MatrixAnimator(strip, load(filename), False)
    animator.run(threaded=True)
    return animator

if __name__ == '__main__':
    if len(sys.argv) == 1:
        main(FILENAME)
    else:
        main(sys.argv[1])

    print('Press enter to finish the program')
    raw_input()