-
Notifications
You must be signed in to change notification settings - Fork 5
/
display.py
42 lines (31 loc) · 931 Bytes
/
display.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
from smbus import SMBus
import math
import time
import backlight
import screen
class Display(object):
backlight = None
screen = None
def __init__(self, bus):
self.backlight = backlight.Backlight(bus, 0x62)
self.screen = screen.Screen(bus, 0x3e)
def write(self, text):
self.screen.write(text)
def color(self, r, g, b):
self.backlight.set_color(r, g, b)
def move(self, col, row):
self.screen.setCursor(col, row)
if __name__ == "__main__":
cnt = 0
d = Display(SMBus(1))
d.move(0, 0)
d.write("Yeah. Nice.")
while True:
r = int((math.sin(cnt) + 1) * 128)
g = int((math.sin(cnt + 0.75 * math.pi) + 1) * 128)
b = int((math.sin(cnt + 1.5 * math.pi) + 1) * 128)
d.color(r, g, b)
# d.move(0, 1)
# d.write("{:>3} {:>3} {:>3}".format(r, g, b))
cnt += 0.01
time.sleep(0.00001)