Exemplo n.º 1
0
def connect():
    if config['usbport'] is not None:
        port = config['usbport']
        blinky = BlinkyTape(port)
        blinky.displayColor(0, 0, 0)
        return blinky
    else:
        print "Make sure you have setup your config"
        exit()
                  help="serial port (ex: /dev/ttyACM0)", default="/dev/ttyACM0")
(options, args) = parser.parse_args()

if options.portname is not None:
    port = options.portname
else:
    print "Usage: python Huxley_UK_Rail_Station_Delays.py -p <port name>"
    print "(ex.: python Huxley_UK_Rail_Station_Delays.py -p /dev/ttyACM0)"
    exit()

url = "https://huxley.apphb.com/delays/{}/to/{}/50/{}?accessToken={}".format(crs, filterCrs, trainTime, accessToken)

bt = BlinkyTape(port)

# Some visual indication that it works for headless setups (green tape)
bt.displayColor(0, 100, 0)
sleep(2)
# Tape resets to stored pattern after a couple of seconds of inactivity

while True:
    try:
        print "GET %s" % (url)
        rawHttpResponse = urllib.urlopen(url)
        stationStatus = json.load(rawHttpResponse)

        if not len(stationStatus) or stationStatus is None:
            raise Exception("Error parsing data")

        alert = stationStatus["delays"] # bool

        print "%s to %s - Trains Delayed by over 5 minutes: %s" % (
Exemplo n.º 3
0
    port = options.portname
else:
    print "Usage: python wakeup.py -p <port name>"
    print "(ex.: python wakeup.py -p /dev/ttyACM0)"
    exit()

sense = SenseHat()
bt = BlinkyTape(port)

# wake phase - gradually get brighter, linearly

sleepTime = 18  # 18 sec for 30 min in 100 steps
maxPower = 100  # flickers or cuts out above 100

for y in xrange(maxPower):
    sense.clear(y * 2, y * 2, y * 2)
    for x in xrange(sleepTime):
        bt.displayColor(y, y, y)
        sleep(1)

# on phase - at full brightness for the same time

sense.clear(255, 255, 255)
for z in xrange(maxPower * sleepTime):
    bt.displayColor(maxPower, maxPower, maxPower)
    sleep(1)

# tidy up

sense.clear()
Exemplo n.º 4
0
    print "(ex.: python wakeup.py -p /dev/ttyACM0)"
    exit()

sense = SenseHat()
bt = BlinkyTape(port)


# wake phase - gradually get brighter, linearly

sleepTime = 18  # 18 sec for 30 min in 100 steps
maxPower = 100  # flickers or cuts out above 100

for y in xrange(maxPower):
    sense.clear(y * 2, y * 2, y * 2)
    for x in xrange(sleepTime):
        bt.displayColor(y, y, y)
        sleep(1)


# on phase - at full brightness for the same time

sense.clear(255, 255, 255)
for z in xrange(maxPower * sleepTime):
    bt.displayColor(maxPower, maxPower, maxPower)
    sleep(1)


# tidy up

sense.clear()
Exemplo n.º 5
0
    # only talk if there is movement.  check delta

    if abs(last - mmm) > delta:
        inches = int(mmm * 10 / 254)
        print inches  #mmm

        # check distance and use selected units of measure (metric vs. imperial)

        if (mmm < inrange):
            if (saymetric):
                pass
                #os.system('pico2wave -w /var/local/pico2wave.wav ' + '"' + str(mmm) + '"'  + ' | aplay -q')
            else:
                #os.system('pico2wave -w /var/local/pico2wave.wav ' + '"' + str(inches) + ' inches"' + ' | aplay -q')
                if inches >= 60:
                    bb.displayColor(*green)
                    #print("green")
                    #for x in range(60):
                    #    bb.sendPixel(0,255,0)#green
                elif inches >= 48 and inches < 60:
                    bb.displayColor(*yellow)
                    #print("yellow")
                    #for x in range(60):
                    #    bb.sendPixel(255,255,0)#yellow
                elif inches < 48:
                    bb.displayColor(*red)
                    #print("red")
                    #for x in range(60):
                    #    bb.sendPixel(255,0,0)#red
                else:
                    bb.displayColor(*blue)
Exemplo n.º 6
0
# BlinkyTape port
#port = "/dev/ttyACM0" # RaspPi default
port = "/dev/tty.usbmodem1411" # OSX

# OTHER GLOBALS
active_targets = []

# BlinkyTape
bt = BlinkyTape(port)
color_list = []
brightness_factor = 0.2 # 0 ... 1

# Show that we're alive for headless set-ups
for i in xrange(0, 60):
    color_list.append((0,0,0))
    bt.displayColor(i*3, i*3, i*3)
    time.sleep(0.1)

def insideBBOX(tgt, bbox):
    if tgt[0] >= bbox['llc'][0] and tgt[0] < bbox['urc'][0] and tgt[1] >= bbox['llc'][1] and tgt[1] < bbox['urc'][1]:
        return True
    else:
        return False

def insidePOI(tgt, poi, r):
    d = great_circle(poi, tgt).meters
    if d < r:
        return True
    else:
        return False
Exemplo n.º 7
0
else:
    print "Usage: python Aurora.py -p <port name>"
    print "(ex.: python Aurora.py -p /dev/ttyACM0)"
    exit()

# Documentation: http://aurorawatch.lancs.ac.uk/api_info/
# Code and spec: https://github.com/stevemarple/AuroraWatchNet
url = 'http://aurorawatch.lancs.ac.uk/api/0.1/status.xml'
bt = BlinkyTape(port)

request = urllib2.Request(url)
request.add_header('User-Agent', 'BlinkyTape Aurora Alert unop.uk')
opener = urllib2.build_opener()

# Some visual indication that it works, for headless setups (green tape)
bt.displayColor(0, 100, 0)
sleep(2)

while True:
    try:
        print "GET %s" % (url)
        rawXml = opener.open(request).read()
        tree = ElementTree.fromstring(rawXml)  

        if not len(tree) or tree is None:
            raise Exception("Error loading data")

        currentStateName = tree.find('current').find('state').get('name')
        print currentStateName

        if currentStateName != "red":
Exemplo n.º 8
0
		return [0,255,b]
	elif (temperature <= 15):
		# 10 < t <= 25
		r = increasingColourOffset(temperature - 5)
		return [r,255,0]
	elif (temperature <= 25):
		# 25 < t <= 40
		g = decreasingColourOffset(temperature - 15)
		return [255,g,0]
	else:
		# 40 < t
		return [255,0,0]	

	return [0,0,0]

bb.displayColor(0,0,0)

while True:
	print "start"
	temps = getTemperatures()

	x = 0
	for i in temps:
		if (datetime.utcnow().day != i["timestamp"][0].day or i["timestamp"][0].hour > datetime.utcnow().hour-3):
			colour = convertTemperatureToRgb(i["Temperature"][0])
			bb.sendPixel(colour[0],colour[1],colour[2])
			x = x + 1
	for i in range(x,60):
		bb.sendPixel(0,0,0)

	bb.show()
Exemplo n.º 9
0
(options, args) = parser.parse_args()

if options.portname is not None:
    port = options.portname
else:
    print "Usage: python Huxley_UK_Rail_Station_Delays.py -p <port name>"
    print "(ex.: python Huxley_UK_Rail_Station_Delays.py -p /dev/ttyACM0)"
    exit()

url = "https://huxley.apphb.com/delays/{}/to/{}/50/{}?accessToken={}".format(
    crs, filterCrs, trainTime, accessToken)

bt = BlinkyTape(port)

# Some visual indication that it works for headless setups (green tape)
bt.displayColor(0, 100, 0)
sleep(2)
# Tape resets to stored pattern after a couple of seconds of inactivity

while True:
    try:
        print "GET %s" % (url)
        rawHttpResponse = urllib.urlopen(url)
        stationStatus = json.load(rawHttpResponse)

        if not len(stationStatus) or stationStatus is None:
            raise Exception("Error parsing data")

        alert = stationStatus["delays"]  # bool

        print "%s to %s - Trains Delayed by over 5 minutes: %s" % (
Exemplo n.º 10
0
# BlinkyTape port
#port = "/dev/ttyACM0" # RaspPi default
port = "/dev/tty.usbmodem1411"  # OSX

# OTHER GLOBALS
active_targets = []

# BlinkyTape
bt = BlinkyTape(port)
color_list = []
brightness_factor = 0.2  # 0 ... 1

# Show that we're alive for headless set-ups
for i in xrange(0, 60):
    color_list.append((0, 0, 0))
    bt.displayColor(i * 3, i * 3, i * 3)
    time.sleep(0.1)


def insideBBOX(tgt, bbox):
    if tgt[0] >= bbox['llc'][0] and tgt[0] < bbox['urc'][0] and tgt[1] >= bbox[
            'llc'][1] and tgt[1] < bbox['urc'][1]:
        return True
    else:
        return False


def insidePOI(tgt, poi, r):
    d = great_circle(poi, tgt).meters
    if d < r:
        return True