flake[0] += 1 if flake[0] > 127: flake[0] = 0 flake[1] += 1 if flake[1] > 31: flake[1] = 0 for i in range(0, 30): snowflakes.append([random.randint(0, 127), random.randint(0, 31)]) tick = 0.0 fps = 0.0 while True: counter += 1 display.flush() for flake in snowflakes: moveSnowflakes(flake) color = random.randint(0, 2) if color == 0: color = 'green' if color == 1: color = 'red' if color == 2: color = 'orange' display.setPixel(flake[0], flake[1], color) display.writeTxt("Frame: %s" % str(counter), color='green', xpos=30, ypos=12) if (counter % 10 == 0): now = time.time() fps = 1.0/(now - tick)*10 tick = now display.writeTxt("FPS: %s" % str(fps)[:5], color='green', xpos=30, ypos=20) display.send()
display = LedDisplay(font, lines=DISPLAY_LINES, device=DEVICE) import random counter = 1 snowflakes = [] def moveSnowflakes(flake): flake[0] += 1 if flake[0] > 127: flake[0] = 0 flake[1] += 1 if flake[1] > 31: flake[1] = 0 for i in range(0, 30): snowflakes.append([random.randint(0, 127), random.randint(0, 31)]) while True: counter += 1 display.flush() for flake in snowflakes: moveSnowflakes(flake) color = random.randint(0, 2) if color == 0: color = 'green' if color == 1: color = 'red' if color == 2: color = 'orange' display.setPixel(flake[0], flake[1], color) display.writeTxt("NUCCC 2011", color='red', xpos=30, ypos=13) display.send()
else: display.writeTxt(u'nå', color='red', xpos=116) for j in range(lineNo, lineNo+lineSpan+1): display.send(j) if i % (8*stepSize) == 0: time.sleep(1) def dumpBusList(buses): for bus in buses: print "%s %s (direction=%s) %d min (%d sec)" % (bus['PublishedLineName'], bus['DestinationDisplay'], bus['DirectionRef'], minutesLeft(bus), secondsLeft(bus)) font = LedFont() display = LedDisplay(font, lines=DISPLAY_LINES, device=DEVICE) display.writeTxt("Line 1", xpos=0, ypos=0, color='red') display.writeTxt("Line 2", xpos=0, ypos=8, color='green') display.writeTxt("Line 3", xpos=0, ypos=16, color='orange') display.writeTxt("Line 4", xpos=0, ypos=24, color='green') display.send() time.sleep(1) for i in range(100, -1, -4): display.flush(DISPLAY_LINES-1) display.writeTxt("Scrolling", xpos=i, ypos=(DISPLAY_LINES-1)*8, color='green') display.send(DISPLAY_LINES-1) while True: display.flush() scrollCount = 0 lastRequestTime = time.time() print ""
buses = json.loads(jsonstr) for bus in buses: bus['DestinationDisplay'] = compressName(bus['DestinationDisplay']) bus['AimedArrivalTime'] = dateStrToStruct(bus['AimedArrivalTime']) bus['AimedDepartureTime'] = dateStrToStruct(bus['AimedDepartureTime']) bus['ExpectedArrivalTime'] = dateStrToStruct(bus['ExpectedArrivalTime']) bus['ExpectedDepartureTime'] = dateStrToStruct(bus['ExpectedDepartureTime']) bus['RecordedAtTime'] = dateStrToStruct(bus['RecordedAtTime']) buses = sortBy(buses, 'ExpectedArrivalTime') drawOnLine(0, buses[0]) drawOnLine(1, buses[1]) drawOnLine(2, buses[2]) display.send() for bus in buses[3:]: # print "scrolling bus: " + bus['DestinationDisplay'] text = bus['LineRef'] + ' ' + bus['DestinationDisplay'] + ' ' + str(minutesLeft(bus)) + ' min' for i in range(128, -128, -1): display.flush(line=3) display.writeTxt(text, xpos=i, ypos=8*3) display.send(line=3) except IOError: print "Failed to fetch data" display.flush() display.writeTxt("Offline...", xpos=0, ypos=0, color='red') display.send()
snowflakes = [] def moveSnowflakes(flake): flake[0] += 1 if flake[0] > 127: flake[0] = 0 flake[1] += 1 if flake[1] > 31: flake[1] = 0 for i in range(0, 30): snowflakes.append([random.randint(0, 127), random.randint(0, 31)]) while True: counter += 1 display.flush() for flake in snowflakes: moveSnowflakes(flake) color = random.randint(0, 2) if color == 0: color = "green" if color == 1: color = "red" if color == 2: color = "orange" display.setPixel(flake[0], flake[1], color) display.writeTxt(str(counter), color="green", xpos=60, ypos=13) display.send()
#!/usr/bin/env python # -*- coding: utf-8 -*- import urllib2 import time import json import sys from ledfont import LedFont from leddisplay import LedDisplay import random font = LedFont() display = LedDisplay(font, lines=4, device="/dev/ttyUSB0") color = 'orange' while True: for i in range(0, -107, -1): y = 0 x = i display.flush() display.writeTxt("LL 20 Galgeberg 8min LL 20 Galgeberg 8min", xpos=x, ypos=0+y, color=color) display.writeTxt("LL 20 Galgeberg 8min LL 20 Galgeberg 8min", xpos=x, ypos=8+y, color=color) display.writeTxt("LL 20 Galgeberg 8min LL 20 Galgeberg 8min", xpos=x, ypos=16+y, color=color) display.writeTxt("LL 20 Galgeberg 8min LL 20 Galgeberg 8min", xpos=x, ypos=24+y, color=color) display.send()
#!/usr/bin/env python # -*- coding: utf-8 -*- from leddisplay import LedDisplay from ledfont import LedFont import time font = LedFont() display = LedDisplay(font) for i in range(0, 32) + range(32, 0, -1): display.flush() display.writeTxt('NUCCC 2011', ypos=i, xpos=i) display.send() time.sleep(1)