import tkinter from tkinter import colorchooser #You'll need to edit this line to match the #serial address where your blinkytape is actually attached. SERIAL_ADDRESS = "COM5" #Blinkytape gets bright! 10 is a pretty good setting #for developing in a dim room without burning your eyes out. BRIGHTNESS = 50 blinkyTape = None root = None try: #Create a BlinkyTape client object. blinkyTape = BlinkyTape(SERIAL_ADDRESS) root = tkinter.Tk() #Initiate the tape's brightness. blinkyTape.setBrightness(BRIGHTNESS) while True: color = colorchooser.askcolor()[0] if not color: break color = RGB(int(color[0]), int(color[1]), int(color[2])) blinkyTape.setColor(color); finally: if root: root.destroy() if blinkyTape:
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()) blinkyTape.setColorAt(0, RGB(200,200,200)); #Just making sure this gets exercised 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()