1: RGB(210,105,0), 2: 0xFFFF00, 3: 0x00FF00, 4: 0x0000FF, 5: 0xFF00FF } #Fills the unused remainder of the strip with solid color. Just cycles through #the rainbow to give a bit of visual appeal. def fill_time_frame(frame, secs): return [time_colors[secs // 10] for i in range(BlinkyTape.LED_COUNT - len(frame))] + frame blinkyTape = None try: #Create a BlinkyTape client object. blinkyTape = BlinkyTape(SERIAL_ADDRESS) #Initiate the tape's brightness. blinkyTape.setBrightness(BRIGHTNESS) #Main loop. Once a second, get the binary-encoded time and send it to the tape. while True: blinkyTape.setColors(encode_time()) sleep(1) finally: if blinkyTape: #If the program exits the infinite loop controllably (e.g. by #keyboard interrupt exception) politely reset the blinkytape to #its initial state. blinkyTape.reset()
from tkColorChooser import askcolor # You'll need to edit this line to match the # serial address where your blinkytape is actually attached. SERIAL_ADDRESS = "/dev/tty.usbmodem14121" # Blinkytape gets bright! 10 is a pretty good setting # for developing in a dim room without burning your eyes out. BRIGHTNESS = 10 blinkyTape = None root = None try: # Create a BlinkyTape client object. blinkyTape = BlinkyTape(SERIAL_ADDRESS) # Initiate the tape's brightness. blinkyTape.setBrightness(BRIGHTNESS) def getColor(): color = askcolor() print color color = RGB(int(color[0][0]), int(color[0][1]), int(color[0][2])) blinkyTape.setColor(color) Button(text="Select Color", command=getColor).pack() mainloop() finally: if blinkyTape: