from blinkytape import BlinkyTape import time bb = BlinkyTape('/dev/ttyACM0', 120) #bb = BlinkyTape('COM8') while True: for x in range(60): bb.sendPixel(100, 100, 100) bb.show() time.sleep(.5) for x in range(60): bb.sendPixel(0, 0, 0) bb.show() time.sleep(.5)
dest="ledcount", help="LED count", default=60, type=int) parser.add_option("-s", "--size", dest="size", help="Size of the light wave", default=20, type=int) (options, args) = parser.parse_args() if options.portname is not None: port = options.portname else: print("Usage: python scanline.py -p <port name>") print("(ex.: python scanline.py -p /dev/ttypACM0)") exit() blinky = BlinkyTape(port, options.ledcount) while True: for position in range(-options.size, options.ledcount + options.size): for led in range(options.ledcount): if abs(position - led) < options.size: blinky.sendPixel(255, 0, 200) else: blinky.sendPixel(0, 0, 0) blinky.show() sleep(0.005)
from time import sleep import optparse parser = optparse.OptionParser() parser.add_option("-p", "--port", dest="portname", help="serial port (ex: /dev/ttyUSB0)", default=None) parser.add_option("-c", "--count", dest="ledcount", help="LED count", default=60, type=int) parser.add_option("-s", "--size", dest="size", help="Size of the light wave", default=20, type=int) (options, args) = parser.parse_args() if options.portname is not None: port = options.portname else: print("Usage: python scanline.py -p <port name>") print("(ex.: python scanline.py -p /dev/ttypACM0)") exit() blinky = BlinkyTape(port, options.ledcount) while True: for position in range(-options.size, options.ledcount + options.size): for led in range(options.ledcount): if abs(position - led) < options.size: blinky.sendPixel(255,0,200) else: blinky.sendPixel(0,0,0) blinky.show() sleep(0.005)
for pixel in xrange(2): bt.sendPixel(0, 0, 0) for line in lines: alert = False for status in line['lineStatuses']: # https://api.tfl.gov.uk/line/meta/severity if status['statusSeverity'] != 10: alert = True r, g, b = colours[line['id']] for pixel in xrange(4): if alert: # Flash for delays l = (cycles - pixel) % 2 if line['id'] == "northern": # Because black on black doesn't show up r, g, b = 100, 100, 100 bt.sendPixel(l * r, l * g, l * b) else: bt.sendPixel(r, g, b) for pixel in xrange(2): bt.sendPixel(0, 0, 0) bt.show() sleep(0.5) except: # Blue indicates an error bt.displayColor(0, 0, 100) sleep(120) # wait 2 min pass
from blinkytape import BlinkyTape import time bb = BlinkyTape('/dev/ttyACM0', 120) #bb = BlinkyTape('COM8') while True: for x in range(60): bb.sendPixel(100, 100, 100) bb.show() time.sleep(.5) for x in range(120): bb.sendPixel(0, 0, 0) bb.show() time.sleep(.5)
if args: print("Unknown parameters: " + args) # grab the values provided by user (or defaults) port = options.portname loc = options.location rate = options.update_rate delta = options.delta_latitude n_leds = options.num_leds i_name = options.image_name # Some visual indication that it works, for headless setups (green tape) bt = BlinkyTape(port, n_leds) bt.displayColor(0, 100, 0) bt.show() sleep(2) while True: try: # first, load image im = Image.open(i_name) # Can be many different formats. cols, rows = im.size a = np.asarray(im) # of shape (rows, cols, channels) # map loc latitude to 0-based index latitude_index = min( rows - 1, max(0, (int)(((loc[0] - -90) / (90 - -90)) * (rows - 0) + 0))) longitude_index = min( cols - 1,