def __init__( self, step, period=0.05, number=80, driver='LPD8806', # 'visualizer', geometry='Strip', anim=None): if driver == 'visualizer': ds = DriverVisualizer(num=number, pixelSize=8) else: ds = DriverSerial(num=number, type=getattr(LEDTYPE, driver)) led = getattr(bibliopixel.led, 'LED' + geometry)(ds) led._internalDelay = period anim_name = 'Base' + (anim or geometry) + 'Anim' self.animation = getattr(bibliopixel.animation, anim_name)(led) self.colors = self.animation._led._colors self.step = step self.animation.step = self.step_function
def main(): parser = ArgumentParser() parser.add_argument("--width", help="Display width", default=8, type=int) parser.add_argument("--height", help="Display height", default=16, type=int) args = parser.parse_args() driver = DriverVisualizer(num=0, width=args.width, height=args.height, pixelSize=15, port=1618, stayTop=True) led = LEDMatrix(driver, serpentine=True, threadedUpdate=False) anim = GenericNetworkReceiver(led, port=3142, interface='0.0.0.0') anim.run(threaded=True) PixelPainter(n_row=args.height, n_col=args.width, display_ip="127.0.0.1", display_port=3142)
from bibliopixel import LEDStrip # from bibliopixel.drivers.LPD8806 import DriverLPD8806, ChannelOrder from bibliopixel.drivers.visualizer import DriverVisualizer, ChannelOrder 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)
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)
nled = rounds * turns 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 if __name__ == '__main__': drivermaster = DriverVisualizer(160, pixelSize=62, stayTop=False) #ledmaster = LEDStrip(drivermaster, threadedUpdate=True) ledmaster = LEDStrip(drivermaster) 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 wormblue = (bluedimming, pathgen(5, 10, 0, 9), 1, 1) wormred = (reddimming, pathgen(1, 14, 1, 8), 1, 1) wormgreen = (greendimming, pathgen(2, 13, 2, 7), 1, 1) wormcyan = (cyandimming, pathgen(3, 12, 3, 6), 1, 1)
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()
class Dummy(BaseMatrixAnim): def __init__(self, led, width=16, height=10, start=0, end=-1): super(Dummy, self).__init__(led, start, end) def step(self, amt=1): pass if __name__ == '__main__': pixelSize = (2, 2) masterBrightness = 200 width = 8 height = 8 driver = DriverVisualizer(width=width, height=height, pixelSize=50, stayTop=True) led = LEDMatrix(driver, pixelSize=pixelSize, masterBrightness=masterBrightness) ri = random.randint tex = [[(ri(0, 255), ri(0, 255), ri(0, 255)) for i in range(width / pixelSize[0])] for j in range(height / pixelSize[1])] dum = Dummy(led) dum._led.setTexture(tex) dum._led.all_off() print "masterBrightness is {}".format(dum._led.masterBrightness) print "Pixel size {}".format(dum._led.pixelSize) print "Numer of scaled pixels {}".format(dum._led.numLEDs) print "set scaled pixel 0,0 to red and scaled pixel 1,0 to green scaled pixel 1,1 to texture"
#Load driver for your hardware, visualizer just for example from bibliopixel.drivers.visualizer import DriverVisualizer driver = DriverVisualizer(num = 10) #load the LEDStrip class from bibliopixel.led import * led = LEDStrip(driver) #load channel test animation from bibliopixel.animation import StripChannelTest anim = StripChannelTest(led) try: anim.run() except KeyboardInterrupt: led.all_off() led.update()
from bibliopixel.led import * from bibliopixel.animation import MatrixCalibrationTest from bibliopixel.animation import StripChannelTest from bibliopixel.drivers.LPD8806 import * from bibliopixel.drivers.visualizer import DriverVisualizer #create driver for a 12x12 grid, use the size of your display #driver = DriverLPD8806(9*9*4) driver = DriverVisualizer(width=9 * 4, height=9, stayTop=True) led = LEDMatrix(driver, rotation=MatrixRotation.ROTATE_0, vert_flip=True) #led = LEDStrip(driver) anim = MatrixCalibrationTest(led) #anim = StripChannelTest(led) anim.run()
from bibliopixel.drivers.network import DriverNetwork from bibliopixel.led import * import bibliopixel.gamma as gamma w = 12 h = 20 print "Pixel Count: {}".format(w*h) parser = argparse.ArgumentParser() group = parser.add_mutually_exclusive_group() parser.add_argument("--visualizer", help="use the visualization driver", action="store_true") parser.add_argument("--network", help="use the network driver", action="store_true") args = parser.parse_args() if args.visualizer: driver = DriverVisualizer(width = w, height = h, stayTop = True) led = LEDMatrix(driver, width = w, height = h) else: driver = DriverNetwork(num=w*h, width=w, height=h, host = "192.168.210.203") #load the LEDMatrix class #change rotation and vert_flip as needed by your display led = LEDMatrix(driver, width = h, height = w, rotation = MatrixRotation.ROTATE_270, vert_flip = True) led.setMasterBrightness(255) import bibliopixel.log as log #log.setLogLevel(log.DEBUG) minFrequency = float(50) # 50 Hz maxFrequency = float(15000) # 15000 HZ