forked from NM-TAFE/civ-ipriot-smiley
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smiley.py
39 lines (33 loc) · 1.01 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
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)
def __init__(self):
# We have encapsulated the SenseHat object
self.sense_hat = SenseHat()
Y = self.YELLOW
O = self.BLANK
self.pixels = [
O, Y, Y, Y, Y, Y, Y, O,
Y, Y, Y, Y, Y, Y, Y, Y,
Y, Y, Y, Y, Y, Y, Y, Y,
Y, Y, Y, Y, Y, Y, Y, Y,
Y, Y, Y, Y, Y, Y, Y, Y,
Y, Y, Y, Y, Y, Y, Y, Y,
Y, Y, Y, Y, Y, Y, Y, Y,
O, Y, Y, Y, Y, Y, Y, 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)