import time
from led import Color, LED
import xbee_leds


if __name__ == '__main__':
    xbees = xbee_leds.get_xbee_list(True)
    if not xbees:
        raise Exception('No XBees found on network') 
    eui = xbees[0]
    
    #initialize ZigBee driver
    xbee_leds.initialize()

    while True:
        for c in (Color(red=0xF), Color(blue=0xF), Color(green=0xf), Color(0xf, 0xf, 0xf)):
            for i in xrange(50):
                bulb = LED(i, c)
                time.sleep(.25)
                xbee_leds.send_leds(bulb.export(), eui)
        
        # make sure we don't try to send too fast
        while xbee_leds.queue_size(eui) > 3:
            time.sleep(0.01)
Exemple #2
0
    #turn off any leftover color
    compact = led.CompactLEDs()
    xbee_leds.send_compact_leds(compact.export(), eui)
    
    leds = []
    twinkles = []
    colors = [led.Color(red=0x0F), #red
              led.Color(green=0x0F), #green
              led.Color(blue=0x0F), #blue
              led.Color(red=0xF, blue=0x0F), #purple
              led.Color(green=0x0F, blue=0xF), #teal
              led.Color(red=0x0F, green=0x8), #yellow/orange
              led.Color(red=0x0E, green=0xE, blue=0xE) #white
              ]
    for color in colors:
        for _ in xrange(5):
            twinkles.append(Twinkle(color))
    while True:
        for twinkle in twinkles:
            response = twinkle.tick()
            if response:
                leds.append(response)
        if leds:
            for i in xrange(0, len(leds), 20):
                # only send up to 20 leds at a time
                xbee_leds.send_leds(''.join(leds[i:i+20]), eui.lower())
            leds = []
        # make sure we don't try to send too fast
        while xbee_leds.queue_size(eui) > 3:
            time.sleep(0.01)
Exemple #3
0
    compact = led.CompactLEDs()
    xbee_leds.send_compact_leds(compact.export(), eui)

    leds = []
    twinkles = []
    colors = [
        led.Color(red=0x0F),  #red
        led.Color(green=0x0F),  #green
        led.Color(blue=0x0F),  #blue
        led.Color(red=0xF, blue=0x0F),  #purple
        led.Color(green=0x0F, blue=0xF),  #teal
        led.Color(red=0x0F, green=0x8),  #yellow/orange
        led.Color(red=0x0E, green=0xE, blue=0xE)  #white
    ]
    for color in colors:
        for _ in range(5):
            twinkles.append(Twinkle(color))
    while True:
        for twinkle in twinkles:
            response = twinkle.tick()
            if response:
                leds.append(response)
        if leds:
            for i in range(0, len(leds), 20):
                # only send up to 20 leds at a time
                xbee_leds.send_leds(b''.join(leds[i:i + 20]), eui.lower())
            leds = []
        # make sure we don't try to send too fast
        while xbee_leds.queue_size(eui) > 3:
            time.sleep(0.01)
import time
from led import Color, LED
import xbee_leds

if __name__ == '__main__':
    xbees = xbee_leds.get_xbee_list(True)
    if not xbees:
        raise Exception('No XBees found on network')
    eui = xbees[0]

    #initialize ZigBee driver
    xbee_leds.initialize()

    while True:
        for c in (Color(red=0xF), Color(blue=0xF), Color(green=0xf),
                  Color(0xf, 0xf, 0xf)):
            for i in xrange(50):
                bulb = LED(i, c)
                time.sleep(.25)
                xbee_leds.send_leds(bulb.export(), eui)

        # make sure we don't try to send too fast
        while xbee_leds.queue_size(eui) > 3:
            time.sleep(0.01)