-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhamsterTempDisplay.py
97 lines (83 loc) · 2.74 KB
/
hamsterTempDisplay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from sense_hat import *
import time
sense = SenseHat()
# def gatherTemp():
temp = (sense.get_temperature() - 18)
# def convertTemp(temp):
floatTemp = float(temp)
roundedTemp = round(temp, 1)
tempMessage = str(roundedTemp) + 'c'
def displayTemp():
#currently not implemented, makes it wait for button press
# activateTemp = sense.stick.wait_for_event(emptybuffer = True)
temp = (sense.get_temperature() - 18)
floatTemp = float(temp)
roundedTemp = round(temp, 1)
tempMessage = str(roundedTemp) + 'c'
while roundedTemp >= 22:
temp = (sense.get_temperature() - 18)
floatTemp = float(temp)
roundedTemp = round(temp, 1)
tempMessage = str(roundedTemp) + 'c'
if roundedTemp >= 22:
sense.show_message('TOO HOT: ' + tempMessage, scroll_speed = (0.05), text_colour = (255,0,0), back_colour = (0, 0, 0))
break
else:
sense.show_message(tempMessage, scroll_speed = (0.09), text_colour = (200,0,200), back_colour = (0, 0, 200))
sense.clear
def displayHamster():
b = (156, 95, 65) #brown
lb = (204, 140, 108) #light brown
p = (255, 120, 140) #pink for ears and nose
lp = (248, 187, 208) #light pink for mouth
w = (255, 255, 255) #white
bl = (0, 0, 0) #black/empty
#Creates the 1st hamster
hamster1 = [
b, b, b, bl, bl, b, b, b,
b, p, b, bl, bl, b, p, b,
b, b, b, b, b, b, b, b,
bl, b, bl, b, b, bl, b, bl,
b, b, bl, b, b, bl, b, b,
b, b, b, b, b, b, b, b,
b, lp, lp, p, p, lp, lp, b,
bl, lp, lp, lp, lp, lp, lp, bl
]
#Creates the 2nd hamster
hamster2 = [
b, b, b, bl, bl, b, b, b,
b, p, b, bl, bl, b, p, b,
b, b, b, b, b, b, b, b,
bl, b, lb, b, b, lb, b, bl,
b, b, bl, b, b, bl, b, b,
b, b, b, b, b, b, b, b,
b, lp, lp, p, p, lp, lp, b,
bl, lp, lp, lp, lp, lp, lp, bl
]
#Creates the 3rd hamster
hamster3 = [
b, b, b, bl, bl, b, b, b,
b, p, b, bl, bl, b, p, b,
b, b, b, b, b, b, b, b,
bl, b, lb, b, b, lb, b, bl,
b, b, bl, b, b, bl, b, b,
b, lp, lp, p, p, lp, lp, b,
b, lp, lp, lp, lp, lp, lp, b,
bl, b, b, b, b, b, b, bl
]
sense.set_pixels(hamster1)
time.sleep(1.5)
sense.set_pixels(hamster2)
time.sleep(1.5)
sense.set_pixels(hamster3)
time.sleep(1.5)
sense.set_pixels(hamster1)
time.sleep(1.5)
while True:
displayHamster()
displayTemp()
#Not currently implemented, this is to change the event to wait for a button press
# event = sense.stick.wait_for_event()
# if event.action == ACTION_PRESSED:
# displayTemp()
# sense.clear()