def getDevices(): ports = DriverSerial.findSerialDevices(hardwareID="16C0:0483") devs = [] print "Available Devices:" count = 0 for port in ports: id = DriverSerial.getDeviceID(port) devs.append((id, port)) print "{}: {} - ID {}".format(count, port, id) count += 1 return devs
def getPixelArray(pixel_map, dev, rotation, vert_flip): ''' pixel_map -- MultiMap Builder dev -- com port ident string ''' width = len(pixel_map.map[0]) height = len(pixel_map.map) n_pixel = width * height driver = DriverSerial(LEDTYPE.GENERIC, n_pixel, hardwareID="16C0:0483", dev=dev) led = LEDMatrix(driver, width=width, height=height, coordMap=pixel_map.map, rotation=rotation, vert_flip=vert_flip) return led
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 showSelectList(msg, values): print "\n" + msg shift = len(str(len(values))) count = 0 for v in values: print "{}: {}".format(str(count).rjust(shift), v) count += 1 return get_int("Choice: ") try: print "Press Ctrl+C anytime to quit." O("Scanning for devices...") DriverSerial.foundDevices = [] devs = DriverSerial.findSerialDevices() d = "" if len(devs) == 0: I("No devices found! Please connect one and press any key...") raise ValueError() elif len(devs) > 1: d = showSelectList("Select device:", devs) if d < 0 or d >= len(devs): O("Invalid choice!") raise ValueError() d = devs[d] else: d = devs[0] t = showSelectList("Choose LED Type", [v[1] for v in types])
from bibliopixel.drivers.serial_driver import DriverSerial, LEDTYPE from bibliopixel import LEDMatrix, log from BiblioPixelAnimations.matrix.bloom import Bloom log.setLogLevel(log.DEBUG) driver = DriverSerial(LEDTYPE.GENERIC, 64*3, hardwareID="16C0:0483", dev="/dev/ttyACM0") led = LEDMatrix(driver, width=24, height=8) try: anim = Bloom(led, dir=True) anim.run(amt=1, fps=15) except: raise led.all_off() led.update()
import sys from bibliopixel.drivers.serial_driver import DriverSerial run = True print "Press Ctrl+C any time to exit." try: while run: ignored = raw_input( "\nConnect just one Serial device (AllPixel) and press enter...") ports = DriverSerial.findSerialDevices() if len(ports): try: id = DriverSerial.getDeviceID(ports[0]) print "Device ID of {}: {}".format(ports[0], id) newID = raw_input("Input new ID (enter to skip): ") if newID != '': try: newID = int(newID) if newID < 0 or newID > 255: raise ValueError() try: DriverSerial.setDeviceID(ports[0], newID) print "Device ID set to: {}".format( DriverSerial.getDeviceID(ports[0])) except: pass except ValueError: print "Please enter a valid number between 0 and 255." except Exception, e: print e
import sys from bibliopixel.drivers.serial_driver import DriverSerial run = True print "Press Ctrl+C any time to exit." try: while run: ignored = raw_input( "\nConnect just one Serial device (AllPixel) and press enter...") ports = DriverSerial.findSerialDevices() if len(ports): try: id = DriverSerial.getDeviceID(ports[0]) print "Device ID of {}: {}".format(ports[0], id) newID = raw_input("Input new ID (enter to skip): ") if newID != '': try: newID = int(newID) if newID < 0 or newID > 255: raise ValueError() try: DriverSerial.setDeviceID(ports[0], newID) print "Device ID set to: {}".format(DriverSerial.getDeviceID(ports[0])) except: pass except ValueError: print "Please enter a valid number between 0 and 255." except Exception, e: print e else:
from bibliopixel.drivers.serial_driver import DriverSerial, LEDTYPE from bibliopixel import LEDMatrix, log from BiblioPixelAnimations.matrix.bloom import Bloom log.setLogLevel(log.DEBUG) driver = DriverSerial(LEDTYPE.GENERIC, 64, hardwareID="16C0:0483") led = LEDMatrix(driver) try: anim = Bloom(led, dir=True) anim.run(amt=1, fps=15) except: led.all_off() led.update()
raise ValueError() except: print "Invalid choice!" continue dev = devs[choice] print "{} - Current ID: {}".format(dev[1], dev[0]) newID = raw_input("Input new ID: ") if newID != '': try: newID = int(newID) if newID < 0 or newID > 255: raise ValueError() try: DriverSerial.setDeviceID(dev[1], newID) print "Device ID set to: {}".format(DriverSerial.getDeviceID(dev[1])) except: pass except ValueError: print "Please enter a valid number between 0 and 255." except Exception, e: print e else: print "No serial devices found. Please connect one." else: args = sys.argv[1:] if len(args) % 2 != 0: print "Must provide device and ID for each device!" sys.exit(1)