# Connor Skorge: MAKE ART PROJECT
import board
import neopixel
import time
import digitalio
import touchio

#import lines needed to play sound files
from audiopwmio import PWMAudioOut as AudioOut
from audiocore import WaveFile
'''
#set up the speaker the speaker
speaker = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker.direction = digitalio.Direction.OUTPUT
speaker.value = True
'''
audio = AudioOut(board.AUDIO)

# set path where sound files can be found
path = "shoeSounds/"

from adafruit_led_animation.color import (
    AMBER, #(255, 100, 0)
    AQUA, # (50, 255, 255)
    BLACK, #OFF (0, 0, 0)
    BLUE, # (0, 0, 255)
    CYAN, # (0, 255, 255)
    GOLD, # (255, 222, 30)
    GREEN, # (0, 255, 0)
    JADE, # (0, 255, 40)
    MAGENTA, #(255, 0, 20)
    OLD_LACE, # (253, 245, 230)
    ORANGE, # (255, 40, 0)
    PINK, # (242, 90, 255)
    PURPLE, # (180, 0, 255)
    RED, # (255, 0, 0)
    TEAL, # (0, 255, 120)
    WHITE, # (255, 255, 255)
    YELLOW, # (255, 150, 0)
    RAINBOW # a list of colors to cycle through
    # RAINBOW is RED, ORANGE, YELLOW, GREEN, BLUE, and PURPLE ((255, 0, 0), (255, 40, 0), (255, 150, 0), (0, 255, 0), (0, 0, 255), (180, 0, 255))
)

INDIGO = (63, 0, 255)
VIOLET = (127, 0, 255)

colors = [RED, MAGENTA, ORANGE, YELLOW, GREEN, JADE, BLUE, INDIGO, VIOLET, PURPLE, BLACK]

pixels_pin = board.NEOPIXEL
pixels_num_of_lights = 10
pixels = neopixel.NeoPixel(pixels_pin, pixels_num_of_lights, brightness = 0.5, auto_write=True)


#set up touchpads A1, A2, A3, A4, A5
touchpad_A1 = touchio.TouchIn(board.A1)
touchpad_A2 = touchio.TouchIn(board.A2)
touchpad_A3 = touchio.TouchIn(board.A3)
touchpad_A4 = touchio.TouchIn(board.A4)
touchpad_A5 = touchio.TouchIn(board.A5)

def play_sound(filename):
    with open(path + filename, "rb") as wave_file:
        wave = WaveFile(wave_file)
        audio.play(wave)
        while audio.playing:
            pass

while True:
    if touchpad_A1.value:
        play_sound("jordan_1.wav")
        pixels.fill(BLACK)
    if touchpad_A2.value:
        play_sound("jordan_4.wav")
        pixels.fill(BLACK)
    if touchpad_A3.value:
        play_sound("jordan_7.wav")
        pixels.fill(BLACK)
    if touchpad_A4.value:
        play_sound("jordan_10.wav")
        pixels.fill(BLACK)
    if touchpad_A5.value:
        play_sound("jordan_11.wav")
        pixels.fill(BLACK)
