def previous_color(): cpb.stop_tone() cpb.start_tone(300) my_robot.current_color_index = my_robot.current_color_index - 1 if my_robot.current_color_index < 0: my_robot.current_color_index = len(COLOR_LIST) - 1
def next_color(): cpb.stop_tone() cpb.start_tone(400) my_robot.current_color_index = my_robot.current_color_index + 1 if my_robot.current_color_index >= len(COLOR_LIST): my_robot.current_color_index = 0
was_connected = True # start animations animations.animate() # look for packets if uart.in_waiting: try: packet = Packet.from_stream( uart) # Create the packet object. except ValueError: continue # if it's a color packet: if isinstance(packet, ColorPacket): for i in range(12): colors = color[i] notes = note[i] # if the packet matches one of our colors: if packet.color == colors and not tone: # animate with that color animations.color = colors # play matching note cpb.start_tone(notes) tone = True # if it's a button packet aka feather's button has been released: elif isinstance(packet, ButtonPacket) and packet.pressed: if packet.button == ButtonPacket.RIGHT and tone: tone = False # stop playing the note cpb.stop_tone() # turn off the neopixels but keep animation active animations.color = off
def end_color_change(): cpb.stop_tone()