-
Notifications
You must be signed in to change notification settings - Fork 4
/
example.py
189 lines (156 loc) · 2.95 KB
/
example.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
'''
# RPi_I2C_driver - TEST program
# The circuit:
# RaspberryPi - 1602 I2C LCD
# Vcc - Vcc
# GND - GND
# GPIO02 (PIN3/SDA) - SDA
# GPIO03 (PIN5/SCL) - SCL
#
# ※ I2C Enable is required in Raspberry Pi configuration.
# ※ When the voltage of the LCD / I2C board is 5V, use of 3.3V logic level converter is recommended.
# by eleparts (yeon) (https://www.eleparts.co.kr/)
# 2019-06-25
'''
# include the library
import RPi_I2C_driver
from time import *
# make custom characters - eleparts logo:
# https://maxpromer.github.io/LCD-Character-Creator/
eleLogo1 = [
0b00000,
0b00000,
0b00110,
0b01001,
0b10001,
0b10000,
0b10000,
0b01110
]
eleLogo2 = [
0b00011,
0b00100,
0b01001,
0b01010,
0b10010,
0b10001,
0b00000,
0b00000
]
eleLogo3 = [
0b00000,
0b10000,
0b00110,
0b01001,
0b01000,
0b10000,
0b00000,
0b00000
]
eleLogo4 = [
0b00000,
0b00000,
0b00000,
0b00000,
0b10000,
0b01000,
0b01000,
0b10000
]
eleLogo5 = [
0b00010,
0b00100,
0b00100,
0b00010,
0b00001,
0b00000,
0b00000,
0b00000
]
eleLogo6 = [
0b00000,
0b00000,
0b00011,
0b00100,
0b00100,
0b11001,
0b00010,
0b00001
]
eleLogo7 = [
0b00000,
0b00000,
0b00000,
0b10011,
0b10101,
0b00100,
0b01000,
0b10000
]
eleLogo8 = [
0b11000,
0b00100,
0b00010,
0b00010,
0b00100,
0b11000,
0b00000,
0b00000
]
##### START EXAMPLE #####
# RPi_I2C_driver.lcd( I2C address )
lcd = RPi_I2C_driver.lcd(0x27)
# Turn on the cursor:
lcd.cursor()
# Print a message to the LCD.
lcd.print("Hello")
sleep(1)
# At 0.5c second interval " World!!!" Print
lcd.print(" World!!!", 0.5)
sleep(2)
lcd.clear()
# Turn off the cursor:
lcd.noCursor()
lcd.print("eleparts")
# set the cursor position:
lcd.setCursor(5,1)
lcd.print(".co.kr")
# create a new character
lcd.createChar(0, eleLogo1)
lcd.createChar(1, eleLogo2)
lcd.createChar(2, eleLogo3)
lcd.createChar(3, eleLogo4)
lcd.createChar(4, eleLogo5)
lcd.createChar(5, eleLogo6)
lcd.createChar(6, eleLogo7)
lcd.createChar(7, eleLogo8)
lcd.setCursor(12,0)
# print 'createChar'
lcd.write(0)
lcd.write(1)
lcd.write(2)
lcd.write(3)
lcd.setCursor(12,1)
lcd.write(4)
lcd.write(5)
lcd.write(6)
lcd.write(7)
sleep(2)
lcd.setCursor(11,1)
# Turn on the blinking cursor:
lcd.blink()
sleep(3)
# screen moving
for a in range(2):
for i in range(2):
# Move the screen to the right
lcd.scrollDisplayLeft()
sleep(0.4)
for i in range(4):
# Move the screen to the right
lcd.scrollDisplayRight()
sleep(0.4)
for i in range(2):
# Move the screen to the right
lcd.scrollDisplayLeft()
sleep(0.4)