-
Notifications
You must be signed in to change notification settings - Fork 2
/
HD44780_test.py
55 lines (45 loc) · 1.41 KB
/
HD44780_test.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
import time
from HD44780 import HD44780
# initialize the chips
lcd=[]
lcd.append(HD44780(40, 2, 5, 6, 13, 19, -1, -1, -1, -1, 16, 20, -1, 18, backlight=0, pwm=True))
lcd.append(HD44780(40, 2, 5, 6, 13, 19, -1, -1, -1, -1, 16, 21, -1, 18, backlight=0, pwm=True))
# times and euro characters (positions 0 and 1)
customchars=[0x00110A040A110000,0x07081E081E080700]
for i in lcd:
i.definechars(customchars)
# turn on backlight
time.sleep(5)
lcd[0].setbacklight(0.5)
# write the first text
lcd[0].set_cursor(0,0)
lcd[0].text(b' 40 '+chr(0)+' 4 DISPLAY ')
lcd[0].set_cursor(0,1)
lcd[0].text(b' HD44780 CHIP ')
lcd[1].set_cursor(0,0)
lcd[1].text(b' ')
lcd[1].set_cursor(0,1)
lcd[1].text(b' Raspberry Pi 3 ')
time.sleep(1)
# blinking brightness
time.sleep(2)
for i in range(5):
time.sleep(0.5)
lcd[0].setbacklight(0.75)
time.sleep(0.5)
lcd[0].setbacklight(0.5)
# write the second text
lcd[0].set_cursor(0,0)
lcd[0].text(' To learn more about using and ')
lcd[0].set_cursor(0,1)
lcd[0].text(' programming the HD44780 chip ')
lcd[1].set_cursor(0,0)
lcd[1].text(' in Python at Rasbperry Pi, visit ')
lcd[1].set_cursor(0,1)
lcd[1].text(' http://www.pinteric.com/displays.html ')
time.sleep(5)
# turn off backlight
lcd[0].setbacklight(0)
# close the chips
for i in lcd:
i.close()