/ Activity_Generator / code.py
code.py
1 # SPDX-FileCopyrightText: 2020 Collin Cunningham for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 # 5 """ACTIVITY GENERATOR for Adafruit CLUE""" 6 7 import time 8 import random 9 from adafruit_clue import clue 10 from things import activities 11 from things import subjects 12 13 screen = clue.simple_text_display(text_scale=4, colors=(clue.WHITE,)) 14 15 screen[1].text = "ACTIVITY" 16 screen[2].text = "GENERATOR" 17 screen.show() 18 time.sleep(1.5) 19 20 screen[0].text = "make a" 21 screen[2].text = "about" 22 screen[1].color = clue.RED 23 screen[3].color = clue.GREEN 24 screen[4].color = clue.BLUE 25 26 activity = "???" 27 subject_a = "???" 28 subject_b = "???" 29 two_subjects = True 30 31 def random_pick(items): 32 index = random.randint(0, len(items)-1) 33 return items[index] 34 35 while True: 36 37 if clue.button_a: 38 activity = random_pick(activities) 39 subject_a = random_pick(subjects) 40 subject_b = random_pick(subjects) 41 time.sleep(0.25) 42 if clue.button_b: 43 two_subjects = not two_subjects 44 time.sleep(0.5) 45 46 screen[1].text = activity 47 screen[3].text = subject_a 48 49 if two_subjects: 50 screen[4].text = subject_b 51 else: 52 screen[4].text = "" 53 54 screen.show()