Skip to content

Commit 928fb05

Browse files
authored
Merge branch 'master' into wearable-ble-temperature-sensor
2 parents 363df34 + 96a3d09 commit 928fb05

27 files changed

+31264
-33
lines changed

Activity_Generator/code.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""ACTIVITY GENERATOR for Adafruit CLUE"""
2+
3+
import time
4+
import random
5+
from adafruit_clue import clue
6+
from things import activities
7+
from things import subjects
8+
9+
screen = clue.simple_text_display(text_scale=4, colors=(clue.WHITE,))
10+
11+
screen[1].text = "ACTIVITY"
12+
screen[2].text = "GENERATOR"
13+
screen.show()
14+
time.sleep(1.5)
15+
16+
screen[0].text = "make a"
17+
screen[2].text = "about"
18+
screen[1].color = clue.RED
19+
screen[3].color = clue.GREEN
20+
screen[4].color = clue.BLUE
21+
22+
activity = "???"
23+
subject_a = "???"
24+
subject_b = "???"
25+
two_subjects = True
26+
27+
def random_pick(items):
28+
index = random.randint(0, len(items)-1)
29+
return items[index]
30+
31+
while True:
32+
33+
if clue.button_a:
34+
activity = random_pick(activities)
35+
subject_a = random_pick(subjects)
36+
subject_b = random_pick(subjects)
37+
time.sleep(0.25)
38+
if clue.button_b:
39+
two_subjects = not two_subjects
40+
time.sleep(0.5)
41+
42+
screen[1].text = activity
43+
screen[3].text = subject_a
44+
45+
if two_subjects:
46+
screen[4].text = subject_b
47+
else:
48+
screen[4].text = ""
49+
50+
screen.show()

Activity_Generator/things.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
activities = [
2+
"DRAWING",
3+
"SONG",
4+
"STORY",
5+
"VIDEO",
6+
]
7+
8+
subjects = [
9+
"COMPUTER",
10+
"ALIEN",
11+
"LASER",
12+
"FOOD",
13+
"TREE",
14+
"DREAM",
15+
"WEATHER",
16+
"DOG",
17+
"CAT",
18+
"BIRD",
19+
"HORSE",
20+
"BLANKET",
21+
"TIME",
22+
"PLANT",
23+
"LEAF",
24+
"EAR",
25+
"HAND",
26+
"FEET",
27+
"TEETH",
28+
"PHONE",
29+
"SPACE",
30+
"ROBOT",
31+
"GHOST",
32+
"FUTURE",
33+
"PROBLEM",
34+
"MUSIC",
35+
"NOISE",
36+
"METAL",
37+
"ROCK",
38+
"AIR",
39+
"HOPE",
40+
"FEAR",
41+
"LOVE",
42+
"DANGER",
43+
"COOKIE",
44+
"BREAD",
45+
"WATER",
46+
"HAT",
47+
"ROUND",
48+
"SQUARE",
49+
"SUCCESS",
50+
"LIGHT",
51+
"RUNNING",
52+
"TALKING",
53+
"SLEEPING",
54+
"FLYING",
55+
"SINGING",
56+
"ACTING",
57+
]
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
"""
2+
Start a 20 second hand washing timer via proximity sensor.
3+
Countdown the seconds with text and beeps.
4+
Display a bitmaps for waiting and washing modes.
5+
"""
6+
7+
import time
8+
import board
9+
from adafruit_clue import clue
10+
from adafruit_display_text import label
11+
from adafruit_bitmap_font import bitmap_font
12+
import displayio
13+
import pulseio
14+
15+
clue.display.brightness = 0.8
16+
clue_display = displayio.Group(max_size=4)
17+
18+
# draw the background image
19+
wash_on_file = open("wash_on.bmp", "rb")
20+
wash_on_bmp = displayio.OnDiskBitmap(wash_on_file)
21+
wash_on_sprite = displayio.TileGrid(wash_on_bmp, pixel_shader=displayio.ColorConverter())
22+
clue_display.append(wash_on_sprite)
23+
24+
# draw the foreground image
25+
wash_off_file = open("wash_off.bmp", "rb")
26+
wash_off_bmp = displayio.OnDiskBitmap(wash_off_file)
27+
wash_off_sprite = displayio.TileGrid(wash_off_bmp, pixel_shader=displayio.ColorConverter())
28+
clue_display.append(wash_off_sprite)
29+
30+
31+
# Create text
32+
# first create the group
33+
text_group = displayio.Group(max_size=5, scale=1)
34+
# Make a label
35+
title_font = bitmap_font.load_font("/font/RacingSansOne-Regular-38.bdf")
36+
title_font.load_glyphs("HandWashTimer".encode('utf-8'))
37+
title_label = label.Label(title_font, text="Hand Wash", color=0x001122)
38+
# Position the label
39+
title_label.x = 10
40+
title_label.y = 16
41+
# Append label to group
42+
text_group.append(title_label)
43+
44+
title2_label = label.Label(title_font, text="Timer", color=0x001122)
45+
# Position the label
46+
title2_label.x = 6
47+
title2_label.y = 52
48+
# Append label to group
49+
text_group.append(title2_label)
50+
51+
timer_font = bitmap_font.load_font("/font/RacingSansOne-Regular-29.bdf")
52+
timer_font.load_glyphs("0123456789ADSWabcdefghijklmnopqrstuvwxyz:!".encode('utf-8'))
53+
timer_label = label.Label(timer_font, text="Wave to start", color=0x4f3ab1, max_glyphs=15)
54+
timer_label.x = 24
55+
timer_label.y = 100
56+
text_group.append(timer_label)
57+
58+
clue_display.append(text_group)
59+
clue.display.show(clue_display)
60+
61+
def countdown(seconds):
62+
for i in range(seconds):
63+
buzzer.duty_cycle = 2**15
64+
timer_label.text = ("Scrub time: {}".format(seconds-i))
65+
buzzer.duty_cycle = 0
66+
time.sleep(1)
67+
timer_label.text = ("Done!")
68+
wash_off_sprite.x = 0
69+
buzzer.duty_cycle = 2**15
70+
time.sleep(0.3)
71+
buzzer.duty_cycle = 0
72+
timer_label.x = 24
73+
timer_label.y = 100
74+
timer_label.text = ("Wave to start")
75+
76+
# setup buzzer
77+
buzzer = pulseio.PWMOut(board.SPEAKER, variable_frequency=True)
78+
buzzer.frequency = 1000
79+
80+
while True:
81+
# print("Distance: {}".format(clue.proximity)) # use to test the sensor
82+
if clue.proximity > 1:
83+
timer_label.x = 12
84+
timer_label.y = 226
85+
timer_label.text = "Scrub Away!"
86+
wash_off_sprite.x = 300
87+
time.sleep(2)
88+
countdown(20)

0 commit comments

Comments
 (0)