# Import everything from the hifive library
from hifive import *
import neopixel
import music
import neopixel
from random import randint
np = neopixel.NeoPixel(pin1, 8)
colour=(0,255,0)

music.set_tempo(ticks=4, bpm=120)
# play Jingle Bells - (c) James Peirpont 1857.
jingle = [
    'e:2','e:2','e:4',
    'e:2','e:2','e:4',
    'e:2','g:2','c','d',
    'e:8',
    'f:2','f:2','f:3',
    'f:1','f:2','e:2',
    'e:2','e:1','e:1',
    'e:2','d:2','d:2',
    'e:2','d:4','g:4',
    'e:2','e:2','e:4',
    'e:2','e:2','e:4',
    'e:2','g:2','c','d',
    'e:8','f:2','f:2','f:2',
    'f:2','f:2','e:2',
    'e:2','e:1','e:1',
    'g:2','g:2','f:2',
    'd:2', 'c:4'
 
]

def showText(colour):
    display.color(colour)
    display.scroll("Merry Christmas Everyone", loop=True,wait = False)

showText(colour)

while True:
    R=randint(0,255)
    G=randint(0,255)
    B=randint(0,255)

    if button_a.is_pressed():
        music.play(jingle, wait = False)

    if button_b.is_pressed():
        colour=(R,G,B)
        showText(colour)
    

    for pixel_id in range(0, len(np)):
        np[pixel_id] = (R, G, B)
        np.show()
        sleep(50)
    
    



