code.py
1 # SPDX-FileCopyrightText: 2021 Eva Herrada for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 import random 6 from adafruit_clue import clue 7 import displayio 8 from adafruit_display_text import label, wrap_text_to_pixels 9 from adafruit_bitmap_font import bitmap_font 10 import board 11 12 column_1 = [ 13 "Champ, ", 14 "Fact: ", 15 "Everybody says ", 16 "Dang... ", 17 "Check it: ", 18 "Just saying... ", 19 "Superstar, ", 20 "Tiger, ", 21 "Self, ", 22 "Know this: ", 23 "News alert: ", 24 "Girl, ", 25 "Ace, ", 26 "Excuse me but ", 27 "Experts agree: ", 28 "In my opinion, ", 29 "Hear ye, hear ye: ", 30 "Okay, listen up: ", 31 ] 32 33 column_2 = [ 34 "the mere idea of you ", 35 "your soul ", 36 "your hair today ", 37 "everything you do ", 38 "your personal style ", 39 "every thought you have ", 40 "that sparkle in your eye ", 41 "your presence here ", 42 "what you got going on ", 43 "the essential you ", 44 "your life's journey ", 45 "that saucy personality ", 46 "your DNA ", 47 "that brain of yours ", 48 "your choice of attire ", 49 "the way you roll ", 50 "whatever your secret is ", 51 "all of y'all ", 52 ] 53 54 column_3 = [ 55 "has serious game, ", 56 "rains magic, ", 57 "deserves the Nobel Prize, ", 58 "raises the roof, ", 59 "breeds miracles, ", 60 "is paying off big time, ", 61 "shows mad skills, ", 62 "just shimmers, ", 63 "is a national treasure, ", 64 "gets the party hopping, ", 65 "is the next big thing, ", 66 "roars like a lion, ", 67 "is a rainbow factory, ", 68 "is made of diamonds, ", 69 "makes birds sing, ", 70 "should be taught in school, ", 71 "makes my world go 'round, ", 72 "is 100% legit, ", 73 ] 74 75 column_4 = [ 76 "24/7.", 77 "can I get an amen?", 78 "and that's a fact.", 79 "so treat yourself.", 80 "you feel me?", 81 "that's just science.", 82 "would I lie?", 83 "for reals.", 84 "mic drop.", 85 "you hidden gem.", 86 "snuggle bear.", 87 "period.", 88 "can I get an amen?", 89 "now let's dance.", 90 "high five.", 91 "say it again!", 92 "according to CNN.", 93 "so get used to it.", 94 ] 95 96 arial18 = bitmap_font.load_font("/fonts/Arial-18.bdf") 97 arial12 = bitmap_font.load_font("/fonts/Arial-12.bdf") 98 99 arial18.load_glyphs( 100 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789;,./?><=+[{]}-_" 101 ) 102 arial12.load_glyphs( 103 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789;,./?><=+[{]}-_" 104 ) 105 106 display = board.DISPLAY 107 clue_group = displayio.Group() 108 109 bitmap_file = open("bmps/background.bmp", "rb") 110 bitmap1 = displayio.OnDiskBitmap(bitmap_file) 111 tile_grid = displayio.TileGrid( 112 bitmap1, pixel_shader=getattr(bitmap1, "pixel_shader", displayio.ColorConverter()) 113 ) 114 clue_group.append(tile_grid) 115 116 text = "\n".join( 117 wrap_text_to_pixels( 118 random.choice(column_1) 119 + random.choice(column_2) 120 + random.choice(column_3) 121 + random.choice(column_4), 122 180, 123 arial18, 124 ) 125 ) 126 pep = label.Label( 127 font=arial18, 128 text=text, 129 anchor_point=(0.5, 0.5), 130 anchored_position=(120, 115), 131 line_spacing=0.8, 132 color=0x000000, 133 ) 134 clue_group.append(pep) 135 136 title = label.Label( 137 font=arial12, 138 text="Pep talk generator", 139 anchor_point=(0.5, 0.5), 140 anchored_position=(120, 231), 141 color=0x000000, 142 ) 143 clue_group.append(title) 144 145 display.show(clue_group) 146 147 while True: 148 if clue.button_a or clue.button_b: 149 pep.text = "\n".join( 150 wrap_text_to_pixels( 151 random.choice(column_1) 152 + random.choice(column_2) 153 + random.choice(column_3) 154 + random.choice(column_4), 155 180, 156 arial18, 157 ) 158 )