'''
Valentines Day Project - Final Code
'''
import radio
from codex import *
import random
import ascii_art 

text_colors = [RED, WHITE, PINK, MAGENTA, CYAN]
messages = [
    "Be my friend", 
    "Happy Heart Day!", 
    "Be mine!", 
    "So cute", 
    "Love in the air",
    "Text me"
    ]

my_channel = 6
radio.on()
radio.config(channel=my_channel)

small_heart = '''
/0=WHITE 2=RED .=TRANSPARENT
.......000....000.......
......02220..02220......
......022220022220......
.....02222222222220.....
.....02222222222220.....
.....02222222222220.....
.....02222222222220.....
......022222222220......
......022222222220......
.......0222222220.......
........02222220........
.........022220.........
..........0220..........
...........00...........
'''

# -- Main Program --
display.print("A = send message")
display.print("B = clear")
display.print("D = quit")

while True:
    if buttons.was_pressed(BTN_A):
        v_message = random.choice(messages)
        msg = v_message + "-AB"
        radio.send(msg)

    msg = radio.receive()
    if msg:
        t_color = random.choice(text_colors)
        display.print(msg, scale=2, color=t_color)
        pixels.fill(t_color)
        hx = random.randint(5, 200)
        hy = random.randint(5, 200)
        val_heart = ascii_art.get_images(small_heart, scale=2)
        display.draw_image(val_heart[0], x=hx, y=hy)

    if buttons.was_pressed(BTN_B):
        display.clear()

    if buttons.was_pressed(BTN_D):
        radio.off()
        display.clear()
        pixels.off()
        break


