forked from NM-TAFE/civ-ipriot-smiley
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smiley.py
47 lines (40 loc) · 1.22 KB
/
smiley.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
from sense_hat import SenseHat
class Smiley:
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
YELLOW = (255, 255, 0)
BLANK = (0, 0, 0)
BLUE = (0, 0, 255)
def __init__(self, complexion=YELLOW):
# We have encapsulated the SenseHat object
self.sense_hat = SenseHat()
self.my_complexion = complexion
X = self.my_complexion
O = self.BLANK
self.pixels = [
O, X, X, X, X, X, X, O,
X, X, X, X, X, X, X, X,
X, X, X, X, X, X, X, X,
X, X, X, X, X, X, X, X,
X, X, X, X, X, X, X, X,
X, X, X, X, X, X, X, X,
X, X, X, X, X, X, X, X,
O, X, X, X, X, X, X, O,
]
def dim_display(self, dimmed=True):
"""
Set the SenseHat's light intensity to low (True) or high (False)
:param dimmed: Dim the display if True, otherwise don't dim
"""
self.sense_hat.low_light = dimmed
def show(self):
"""
Show the smiley on the screen.
"""
self.sense_hat.set_pixels(self.pixels)
def complexion(self):
"""
:return: Color to be used for the face
"""
return self.my_complexion