예제 #1
0
def send_strip_alert(call):
    """Send the alert to an attached LED strip."""
    touch(timeout_file)
    driver = DriverLPD8806(160, c_order=ChannelOrder.GRB)
    led = LEDStrip(driver)

    units = call['station_units']

    p_animation = ledanimation.PulseAnimation(led)
    animation = ledanimation.ChaseAnimation(led)

    if 'ENGINE' in units and 'SQUAD' in units and 'AMBULANCE' in units:
        color_array = [colors.Red, colors.Green, colors.Orange]
    elif 'ENGINE' in units and 'SQUAD' in units:
        color_array = [colors.Red, colors.Orange]
    elif 'ENGINE' in units and 'AMBULANCE' in units:
        color_array = [colors.Red, colors.Green]
    elif 'SQUAD' in units and 'AMBULANCE' in units:
        color_array = [colors.Orange, colors.Green]
    elif 'ENGINE' in units:
        color_array = [colors.Red]
    elif 'AMBULANCE' in units:
        color_array = [colors.Green]
    elif 'SQUAD' in units:
        color_array = [colors.Orange]
    else:
        color_array = [colors.Green]

    p_animation._color_array = color_array
    animation._color_array = color_array

    p_animation.run(max_steps=1765)
    animation.run(max_steps=4000)

    touch(timeout_file)

    t = threading.Timer(100.0, alert_manager)
    t.start()

    led.all_off()
    led.update()
예제 #2
0
def main(argv):
    """Queue listener daemon."""
    print time.asctime() + ": starting ledAlerter"

    driver = DriverLPD8806(160, c_order=ChannelOrder.GRB)
    led = LEDStrip(driver)
    led.all_off()
    led.update()

    connection = pika.BlockingConnection(pika.ConnectionParameters(
        host=rabbitmq_host))
    channel = connection.channel()

    channel.queue_declare(queue=sub_queue, durable=True)
    channel.queue_bind(exchange=sub_exchange, queue=sub_queue)

    channel.basic_consume(consumer_callback=callback,
                          queue=sub_queue,
                          no_ack=False,
                          )

    channel.start_consuming()
예제 #3
0
6.19.2016
'''

#---initialize---
nLED = 64

import random
from time import sleep
from functools import partial
from bibliopixel.led import LEDStrip
from bibliopixel.drivers.LPD8806 import *
import bibliopixel.colors as Color

#create driver for nLED pixels
driver = DriverLPD8806(nLED, c_order=ChannelOrder.GRB)
led = LEDStrip(driver)


def turn_off():
    global led
    led.all_off()
    led.update()


#---set execs---
'''
combo = pattern + color
two-word phrase / mix-n-match
i.e. "odds white" -> turns all odd pixels white;
'''
예제 #4
0
def main(argv):
    """Main class, used to run animations directly."""
    animation_name = ''
    num_leds = 32
    try:
        opts, args = getopt.getopt(argv, "ha:l:", ["animation=", "leds="])
    except getopt.GetoptError:
        print 'ledanimation.py -a <animation_name>'
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'ledanimation.py -a <animation_name> -l <num_leds>'
            sys.exit()
        elif opt in ("-a", "--animation"):
            animation_name = arg
        elif opt in ("-l", "--leds"):
            num_leds = string.atoi(arg)

    driver = DriverLPD8806(num_leds, c_order=ChannelOrder.GRB)
    led = LEDStrip(driver)

    if 'pulse-redorangegreen' in animation_name:
        # animation = PulseRedOrangeGreen(led)
        animation = PulseAnimation(led)
        animation._color_array = [colors.Red, colors.Orange, colors.Green]
    elif 'pulse-greenorange' in animation_name:
        # animation = PulseGreenOrange(led)
        animation = PulseAnimation(led)
        animation._color_array = [colors.Green, colors.Orange]
    elif 'pulse-greenred' in animation_name:
        # animation = PulseGreenRed(led)
        animation = PulseAnimation(led)
        animation._color_array = [colors.Green, colors.Red]
    elif 'pulse-redorange' in animation_name:
        # animation = PulseRedOrange(led)
        animation = PulseAnimation(led)
        animation._color_array = [colors.Red, colors.Orange]
    elif 'pulse-green' in animation_name:
        # animation = PulseGreen(led)
        animation = PulseAnimation(led)
        animation._color_array = [colors.Green]
    elif 'pulse-orange' in animation_name:
        # animation = PulseOrange(led)
        animation = PulseAnimation(led)
        animation._color_array = [colors.Orange]
    elif 'pulse-red' in animation_name:
        # animation = PulseRed(led)
        animation = PulseAnimation(led)
        animation._color_array = [colors.Red]
    elif 'chase-redgreenorange' in animation_name:
        animation = ChaseAnimation(led)
        animation._color_array = [colors.Red, colors.Green, colors.Orange]
    elif 'chase-redgreen' in animation_name:
        animation = ChaseAnimation(led)
        animation._color_array = [colors.Red, colors.Green]
    elif 'chase' in animation_name:
        animation = ChaseAnimation(led)
        animation._color_array = [colors.Red]
    elif 'alert-redgreenorange' in animation_name:
        p_animation = PulseAnimation(led)
        p_animation._color_array = [colors.Red, colors.Green, colors.Orange]
        p_animation.run(max_steps=765)
        animation = ChaseAnimation(led)
        animation._color_array = [colors.Red, colors.Green, colors.Orange]
    elif 'alert-redgreen' in animation_name:
        p_animation = PulseAnimation(led)
        p_animation._color_array = [colors.Red, colors.Green]
        p_animation.run(max_steps=765)
        animation = ChaseAnimation(led)
        animation._color_array = [colors.Red, colors.Green]
    elif 'alert' in animation_name:
        p_animation = PulseAnimation(led)
        p_animation._color_array = [colors.Red]
        p_animation.run(max_steps=765)
        animation = ChaseAnimation(led)
        animation._color_array = [colors.Red]

    animation.run(max_steps=1000)

    # animation.run(mex_steps=2000, threaded=True, joinThread=True)

    led.all_off()
    led.update()
def turn_off_lights():
    driver = DriverLPD8806(160, c_order=ChannelOrder.GRB)
    led = LEDStrip(driver)
    led.all_off()
    led.update()
from bibliopixel.drivers.network import DriverNetwork
from bibliopixel.led import LEDStrip

#must init with same number of pixels as receiver
driver = DriverNetwork(10, host = "192.168.1.18")
led = LEDStrip(driver)

from bibliopixel.animation import StripChannelTest
anim = StripChannelTest(led)
try:
	anim.run()
except KeyboardInterrupt:
	led.all_off()
	led.update()
예제 #7
0
from bibliopixel.drivers.network import DriverNetwork
from bibliopixel.led import LEDStrip

#must init with same number of pixels as receiver
driver = DriverNetwork(10, host="192.168.1.18")
led = LEDStrip(driver)

from bibliopixel.animation import StripChannelTest
anim = StripChannelTest(led)
try:
    anim.run()
except KeyboardInterrupt:
    led.all_off()
    led.update()