import time from led import Color, CompactLEDs 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() # create gradient leds = CompactLEDs() leds.gradients([(0, Color(red=0xF)), (17, Color(green=0xF)), (34, Color(blue=0xF)), (0, Color(red=0xF)) ]) while True: # shift all of the leds by one color = leds.pop() leds.insert(0, color) # send led colors xbee_leds.send_compact_leds(leds.export(), eui) # make sure we don't try to send too fast while xbee_leds.queue_size(eui) > 3: time.sleep(0.01)
values = line.split(',') start = float(values[0].strip()) if values[1]: stop = float(values[1].strip()) else: stop = start + 0.1 scale = float(values[2].strip() or '1.0') thrum = int(values[3].strip() or '0') bell = int(values[4].strip() or '0') warble = int(values[5].strip() or '0') if start and stop: times.append((start, stop, scale, thrum, bell, warble)) except: pass #ignore headers, blank lines, and others strand = CompactLEDs() xbees = xbee_leds.get_xbee_list(True) if not xbees: raise Exception('No XBees found on network') eui = xbees[0] xbee_leds.initialize() if mp3play and os.path.exists(MUSIC_FILE): clip = mp3play.load(MUSIC_FILE) clip.play() start_time = time.time() for start, stop, scale, thrum, bell, warble in times: #prepare LED values set_leds(strand, scale, thrum, bell, warble)
import time from led import Color, CompactLEDs 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() # create gradient leds = CompactLEDs() leds.gradients([(0, Color(red=0xF)), (17, Color(green=0xF)), (34, Color(blue=0xF)), (0, Color(red=0xF))]) while True: # shift all of the leds by one color = leds.pop() leds.insert(0, color) # send led colors xbee_leds.send_compact_leds(leds.export(), eui) # make sure we don't try to send too fast while xbee_leds.queue_size(eui) > 3: time.sleep(0.01)