Customizing

You can customize the messages and the colors if you want. All the lines of code to do this are at the top.

Changing Messages

The messages are stored as a tuple of tuples. Yah, that sounds weird, but tuples can contain anything, including other tuples. It's these lines of code at the top:

Download: file
HEART_MESSAGES = (
    ("I LUV", "YOU"),
    ("SAY", "YES"),
    ("HUG", "ME"),
    ("BE", "MINE"),
    ("TEXT","ME"),
    ("OMG","LOL"),
    ("PEACE",""),
)

Each message is a tuple with two text strings - one for each line. You need to specify both, even if you only want one line. See the PEACE message as an example of a single line message. Its second line is blank. You can remove or add more messages as you wish or edit the ones that are there.

NOTE: Line 1 can have up to 9 characters. Line 2 can have up to 5 characters.

Be careful not to forget the trailing comma at the end of each line in the tuple. It is OK if the last line has one as well.

Changing Colors

You can also change the heart and message text colors if you want. These are also defined as tuples, but this time just a straight simple tuple of color values. It's these lines of code at the top:

Download: file
HEART_COLORS = (
    0xEAFF50, # yellow
    0xFFAD50, # orange
    0x9D50FF, # purple
    0x13B0FE, # blue
    0xABFF96, # green
    0xFF96FF, # pink
)
MESSAGE_COLORS = (
    0xFF0000, # red
)

There's a separate tuple for the heart colors, HEART_COLORS, and one for the message colors, MESSAGE_COLORS. Just add/remove entries as you wish. We kept MESSAGE_COLORS to a single value in the default code just because it seemed to look the best. But you can add more if you want.

Changing Interaction

The default code changes messages whenever either of the buttons on the Circuit Playground are pressed. That's done with these lines of code:

Download: file
# wait for button press
while not cp.button_a and not cp.button_b:
    pass
# just a little debounce
time.sleep(0.25)

You could change that to something else if you want. You would replace those lines with something else. Some ideas are tap:

Download: file
# wait for tap
while not cp.tapped:
    pass

shake:

Download: file
# wait for shake
while not cp.shake():
    pass

or a simple timer:

Download: file
# change every 5 seconds
time.sleep(5)

But you could also maybe do sound? Or temperature?

This guide was first published on Feb 09, 2020. It was last updated on Feb 09, 2020.
This page (Customizing) was last updated on May 09, 2020.