在学校的创新实践活动中,我通过参考 mini LCD12864 的51单片机驱动程序,编写了适用于树莓派的该显示屏的C语言和Python语言驱动演示程序。下面两个程序的硬件连接和运行效果完全相同,可使显示屏在两个不同的显示内容间不断转换。
下面是C语言的驱动演示程序: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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244//LCD 树莓派(WiringPi接口编码)
//7 4
//8 5
//9 5V
//10 GND
//11 3.3V
//12 2
//13 3
//14 6
/******************************************************************/
//12864 ,芯片7565p
//环境:51 单片机,11.0592 晶振。P2 口做数据线。
//图片取模方式:字模 III 增强版 V3.91,参数:纵向取模,字节倒序
//采用软件调节对比度方式
/******************************************************************/
#include <wiringPi.h>
/******************************************************************/
#define a0 6 //pin14
#define cs1 2 //pin12
#define rst 3 //pin13
#define sclk 4 //pin7
#define di 5 //pin8
#define nop() delayMicroseconds(1) /*定义空指令asm("nop")*/
unsigned char niu[1024]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xC0,0x40,0x60,0x20,0x30,0x18,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x08,0x38,0xF0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xE0,0xE0,0xD0,0x30,0x70,0x60,0x30,0x70,
0x70,0x00,0x00,0x40,0xE0,0xF0,0xF0,0xE0,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF0,0xF8,0xF8,
0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xE0,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1E,0x06,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xC0,0x00,0x00,
0x00,0xE0,0x80,0x00,0x00,0x1C,0xFC,0x70,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xE0,0x80,0x00,0x00,0x00,0x03,0x0F,0x3E,0x7C,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0F,0x1F,0xFD,0xE9,0x01,0x00,0x00,0x00,0x00,0x38,0x00,
0x00,0x30,0x30,0x00,0x00,0x00,0x06,0xFF,0x1D,0x0E,0x06,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xF8,0xFE,0xFF,0x1F,0x0F,0x03,0x03,0x01,0x01,0x01,0x00,
0x00,0x00,0x00,0x01,0x01,0x01,0x03,0x03,0x07,0x07,0x07,0x0F,0x3F,0x7F,0xFF,0xFF,
0xFC,0xF0,0xE0,0x81,0x01,0x01,0x01,0x00,0xF0,0xFC,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x0C,0xF8,0xF8,0x30,0x60,0x7F,0x43,0x47,0x5C,
0xF8,0xFF,0x0F,0x1E,0x38,0x70,0xC7,0xFC,0x81,0x83,0x8E,0x5C,0x78,0x70,0xE0,0xC0,
0xC0,0x8F,0xFF,0xFE,0xF8,0xE0,0xC0,0xC0,0xE0,0xF8,0xFF,0x00,0x00,0xC0,0xE0,0x60,
0x70,0x70,0x30,0xF0,0xF8,0xFC,0x06,0x03,0x01,0x01,0x01,0x41,0x73,0x32,0x86,0xFC,
0x7C,0x8E,0x02,0x73,0x41,0x41,0x01,0x01,0x02,0x06,0xFC,0x78,0x70,0x70,0x60,0x60,
0xE0,0xE0,0xC0,0x00,0x00,0xFF,0xFF,0xFF,0xFC,0xE4,0xC2,0x02,0x81,0xC1,0xE0,0xE2,
0xC0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0xE1,0xF1,
0xF3,0xFF,0x7F,0x3F,0x7F,0x7C,0xF8,0xF0,0xE1,0xC7,0x9F,0xBF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0x7C,0xFC,0x78,0x70,0xC1,0xCF,0xFE,0xE0,0x8E,0x10,0x1D,0x33,
0x3F,0x1E,0x1C,0x80,0x00,0x00,0x00,0x01,0x01,0x1C,0x02,0x2F,0x33,0x3F,0x3F,0x1F,
0x0F,0x07,0x87,0xEF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x67,0xC7,0x8F,0xFE,0x1E,0x06,0x26,0xC6,0x82,0x03,0x01,0x00,
0x00,0x01,0x83,0xC2,0x66,0x06,0x06,0xFE,0x9E,0x8F,0xC7,0x6F,0x3E,0x08,0x00,0x00,
0x00,0x01,0x01,0x00,0x00,0x07,0x07,0x8F,0xFF,0xFF,0x07,0x0F,0x0F,0x67,0xEF,0xFF,
0xF0,0xF8,0x3F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,0x07,0x3F,
0x67,0x67,0x7F,0x7E,0x7F,0x5F,0x00,0x00,0x01,0x03,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x03,0x07,0x3F,0xFE,0xF8,0xE0,
0xC0,0x80,0x00,0x01,0x12,0x70,0x70,0x70,0x10,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,
0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x0F,0x3C,0xE0,0x80,0x00,0x07,0x1F,0x3F,0x3E,
0x3F,0x3F,0x0F,0x03,0x80,0xE0,0x38,0x0F,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xF0,0xC0,0x80,0x81,0x01,
0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xF0,0xFC,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,
0x07,0x07,0x03,0x02,0x06,0x06,0x06,0x06,0x06,0x06,0x07,0x03,0x03,0x07,0x07,0x07,
0x07,0x07,0x07,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x0F,0x06,0x06,0x04,0x0C,0x0C,
0x04,0x06,0x06,0x07,0x0D,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
0x06,0x04,0x04,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x03,0x03,0x01,0x01,0x00,
0x00,0x00,0x00,0x04,0x06,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
unsigned char hello[1024]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,
0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0x00,0x00,
0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xE0,0xE0,0xE0,0x00,0x00,0x00,0xC0,0xC0,0xC0,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xFF,0xFF,0xFF,
0x00,0x00,0xC0,0xE0,0xF0,0x78,0x18,0x18,0x18,0x78,0xF0,0xF0,0xC0,0x00,0x00,0xFF,
0xFF,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x80,0xE0,0xF0,0xF0,0x38,0x38,0x18,
0x38,0x78,0xF0,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x7F,0xFF,0xFF,0xE0,
0x00,0x00,0xE0,0xFF,0xFF,0x1F,0xFF,0xFF,0xF8,0x00,0x00,0xC0,0xFE,0xFF,0x7F,0x07,
0x80,0xE0,0xF0,0xF0,0x38,0x38,0x18,0x38,0x78,0xF0,0xF0,0xE0,0x00,0x00,0xF8,0xF8,
0xF8,0xF0,0x70,0x38,0x38,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x80,0xE0,0xF0,0xF8,0x78,
0x38,0x18,0x38,0x70,0xFF,0xFF,0xFF,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0xFF,
0x00,0x0E,0x7F,0xFF,0xFF,0xE6,0xC6,0x86,0x86,0x86,0x87,0x87,0x87,0x00,0x00,0xFF,
0xFF,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x1F,0x7F,0xFF,0xF9,0xC0,0x80,0x80,
0xC0,0xE0,0xFF,0xFF,0x7F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,
0xFC,0xFE,0xFF,0x1F,0x01,0x00,0x00,0x1F,0xFF,0xFF,0xFC,0xFF,0x7F,0x07,0x00,0x00,
0x1F,0x7F,0xFF,0xF9,0xC0,0x80,0x80,0xC0,0xE0,0xFF,0xFF,0x7F,0x0F,0x00,0xFF,0xFF,
0xFF,0xFF,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x1F,0x7F,0xFF,0xF9,0xC0,
0x80,0x80,0xC0,0xE0,0xFF,0xFF,0xFF,0x00,0x00,0x00,0xC7,0xE7,0xE7,0xC0,0x00,0x00,
0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x01,
0x01,0x01,0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,
0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x01,
0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,
0x01,0x01,0x01,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
//串行模式发送数据
void data_send(unsigned char dat)
{
unsigned char s,temp;
int i;
digitalWrite(sclk,LOW);
s=dat;
for(i=8;i>0;i--){
digitalWrite(sclk,LOW);
nop();
nop();
temp=s & 0x80;
if(temp)
{digitalWrite(di,HIGH);}
else {digitalWrite(di,LOW);}
digitalWrite(sclk,HIGH);
s=s<<1;
}
}
/*************************************************/
//写命令,串行模式
/*************************************************/
void w_coms(unsigned char x)
{
digitalWrite(a0,LOW);
digitalWrite(cs1,LOW);
data_send(x);
}
/*************************************************/
//写数据,串行模式
/*************************************************/
void wdatas(unsigned char dat)
{
digitalWrite(a0,HIGH);
digitalWrite(cs1,LOW);
data_send(dat);
}
void display_map(unsigned char *p)//P 是图片数据的首地址
{
unsigned char seg;
unsigned char page;
for(page=0xb0;page<0xb8;page++) //写页地址共8 页 0xb0----0xb7
{
w_coms(page);
w_coms(0x10); //列地址,高低字节两次写入,从第0 列开始
w_coms(0x00);
for(seg=0;seg<128;seg++)//写128 列
{
wdatas(*p++);
}
}
}
//主程序
int main(void)
{
wiringPiSetup();
pinMode (a0, OUTPUT);
pinMode (cs1, OUTPUT);
pinMode (rst, OUTPUT);
pinMode (sclk, OUTPUT);
pinMode (di, OUTPUT);
digitalWrite(rst,LOW);
nop();
nop();
digitalWrite(rst,HIGH);
w_coms(0xaf); //ON DISPLAY
w_coms(0x40); //STAR DISPLAY
w_coms(0xa0); //ADC NORMAL
w_coms(0xa6); //
w_coms(0xa4); //CLEAR
w_coms(0xa2); //1/9BIAS
w_coms(0xc8); //COMMON OUTPUT DIRECTION
w_coms(0x2f); //POWER CONTROL
w_coms(0x24); //RESISTER RATIO
w_coms(0x81); //VOLUM MODE SET
w_coms(0x24); //RESISTER RATIO
//*********************************************************************
while(1) //START
{
display_map(niu); //显示一副SCH 图案
delay(1000);
display_map(hello);
delay(1000);
}
}
下面是Python的驱动演示程序: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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240#!/usr/bin/env python
# -*- coding: utf-8 -*-
#LCD 树莓派(WiringPi接口编码)
#7 4
#8 5
#9 5V
#10 GND
#11 3.3V
#12 2
#13 3
#14 6
#******************************************************************
#12864 ,芯片7565p
#环境:51 单片机,11.0592 晶振。P2 口做数据线。
#图片取模方式:字模 III 增强版 V3.91,参数:纵向取模,字节倒序
#采用软件调节对比度方式
#******************************************************************
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
a0 = 22
cs1 = 13
rst = 15
sclk = 16
di = 18
def nop():
pass
niu = (\
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xC0,0x40,0x60,0x20,0x30,0x18,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x08,0x38,0xF0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xE0,0xE0,0xD0,0x30,0x70,0x60,0x30,0x70,
0x70,0x00,0x00,0x40,0xE0,0xF0,0xF0,0xE0,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,0xF0,0xF8,0xF8,
0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xE0,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1E,0x06,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xC0,0x00,0x00,
0x00,0xE0,0x80,0x00,0x00,0x1C,0xFC,0x70,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xE0,0x80,0x00,0x00,0x00,0x03,0x0F,0x3E,0x7C,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0F,0x1F,0xFD,0xE9,0x01,0x00,0x00,0x00,0x00,0x38,0x00,
0x00,0x30,0x30,0x00,0x00,0x00,0x06,0xFF,0x1D,0x0E,0x06,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xF8,0xFE,0xFF,0x1F,0x0F,0x03,0x03,0x01,0x01,0x01,0x00,
0x00,0x00,0x00,0x01,0x01,0x01,0x03,0x03,0x07,0x07,0x07,0x0F,0x3F,0x7F,0xFF,0xFF,
0xFC,0xF0,0xE0,0x81,0x01,0x01,0x01,0x00,0xF0,0xFC,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x0C,0xF8,0xF8,0x30,0x60,0x7F,0x43,0x47,0x5C,
0xF8,0xFF,0x0F,0x1E,0x38,0x70,0xC7,0xFC,0x81,0x83,0x8E,0x5C,0x78,0x70,0xE0,0xC0,
0xC0,0x8F,0xFF,0xFE,0xF8,0xE0,0xC0,0xC0,0xE0,0xF8,0xFF,0x00,0x00,0xC0,0xE0,0x60,
0x70,0x70,0x30,0xF0,0xF8,0xFC,0x06,0x03,0x01,0x01,0x01,0x41,0x73,0x32,0x86,0xFC,
0x7C,0x8E,0x02,0x73,0x41,0x41,0x01,0x01,0x02,0x06,0xFC,0x78,0x70,0x70,0x60,0x60,
0xE0,0xE0,0xC0,0x00,0x00,0xFF,0xFF,0xFF,0xFC,0xE4,0xC2,0x02,0x81,0xC1,0xE0,0xE2,
0xC0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0xE1,0xF1,
0xF3,0xFF,0x7F,0x3F,0x7F,0x7C,0xF8,0xF0,0xE1,0xC7,0x9F,0xBF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0x7C,0xFC,0x78,0x70,0xC1,0xCF,0xFE,0xE0,0x8E,0x10,0x1D,0x33,
0x3F,0x1E,0x1C,0x80,0x00,0x00,0x00,0x01,0x01,0x1C,0x02,0x2F,0x33,0x3F,0x3F,0x1F,
0x0F,0x07,0x87,0xEF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x67,0xC7,0x8F,0xFE,0x1E,0x06,0x26,0xC6,0x82,0x03,0x01,0x00,
0x00,0x01,0x83,0xC2,0x66,0x06,0x06,0xFE,0x9E,0x8F,0xC7,0x6F,0x3E,0x08,0x00,0x00,
0x00,0x01,0x01,0x00,0x00,0x07,0x07,0x8F,0xFF,0xFF,0x07,0x0F,0x0F,0x67,0xEF,0xFF,
0xF0,0xF8,0x3F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,0x07,0x3F,
0x67,0x67,0x7F,0x7E,0x7F,0x5F,0x00,0x00,0x01,0x03,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x03,0x07,0x3F,0xFE,0xF8,0xE0,
0xC0,0x80,0x00,0x01,0x12,0x70,0x70,0x70,0x10,0x00,0x00,0x00,0x80,0xC0,0xE0,0xF0,
0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x01,0x07,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x0F,0x3C,0xE0,0x80,0x00,0x07,0x1F,0x3F,0x3E,
0x3F,0x3F,0x0F,0x03,0x80,0xE0,0x38,0x0F,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xF0,0xC0,0x80,0x81,0x01,
0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xF0,0xFC,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,
0x07,0x07,0x03,0x02,0x06,0x06,0x06,0x06,0x06,0x06,0x07,0x03,0x03,0x07,0x07,0x07,
0x07,0x07,0x07,0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x0F,0x06,0x06,0x04,0x0C,0x0C,
0x04,0x06,0x06,0x07,0x0D,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
0x06,0x04,0x04,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x03,0x03,0x01,0x01,0x00,
0x00,0x00,0x00,0x04,0x06,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00)
hello = (\
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,
0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0x00,0x00,
0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xE0,0xE0,0xE0,0x00,0x00,0x00,0xC0,0xC0,0xC0,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xFF,0xFF,0xFF,
0x00,0x00,0xC0,0xE0,0xF0,0x78,0x18,0x18,0x18,0x78,0xF0,0xF0,0xC0,0x00,0x00,0xFF,
0xFF,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x80,0xE0,0xF0,0xF0,0x38,0x38,0x18,
0x38,0x78,0xF0,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x7F,0xFF,0xFF,0xE0,
0x00,0x00,0xE0,0xFF,0xFF,0x1F,0xFF,0xFF,0xF8,0x00,0x00,0xC0,0xFE,0xFF,0x7F,0x07,
0x80,0xE0,0xF0,0xF0,0x38,0x38,0x18,0x38,0x78,0xF0,0xF0,0xE0,0x00,0x00,0xF8,0xF8,
0xF8,0xF0,0x70,0x38,0x38,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x80,0xE0,0xF0,0xF8,0x78,
0x38,0x18,0x38,0x70,0xFF,0xFF,0xFF,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0xFF,
0x00,0x0E,0x7F,0xFF,0xFF,0xE6,0xC6,0x86,0x86,0x86,0x87,0x87,0x87,0x00,0x00,0xFF,
0xFF,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x1F,0x7F,0xFF,0xF9,0xC0,0x80,0x80,
0xC0,0xE0,0xFF,0xFF,0x7F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,
0xFC,0xFE,0xFF,0x1F,0x01,0x00,0x00,0x1F,0xFF,0xFF,0xFC,0xFF,0x7F,0x07,0x00,0x00,
0x1F,0x7F,0xFF,0xF9,0xC0,0x80,0x80,0xC0,0xE0,0xFF,0xFF,0x7F,0x0F,0x00,0xFF,0xFF,
0xFF,0xFF,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x1F,0x7F,0xFF,0xF9,0xC0,
0x80,0x80,0xC0,0xE0,0xFF,0xFF,0xFF,0x00,0x00,0x00,0xC7,0xE7,0xE7,0xC0,0x00,0x00,
0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x01,
0x01,0x01,0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,
0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x01,
0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,
0x01,0x01,0x01,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00)
#串行模式发送数据
def data_send(dat):
s = ''
temp = ''
i = 0
GPIO.output(sclk, GPIO.LOW)
s = dat
for i in range(0,8):
GPIO.output(sclk, GPIO.LOW)
nop()
nop()
temp = s & 0x80
if temp:
GPIO.output(di, GPIO.HIGH)
else:
GPIO.output(di, GPIO.LOW)
GPIO.output(sclk, GPIO.HIGH)
s = s<<1;
#*************************************************
#写命令,串行模式
#*************************************************
def w_coms(x):
GPIO.output(a0, GPIO.LOW)
GPIO.output(cs1, GPIO.LOW)
data_send(x)
#*************************************************
#写数据,串行模式
#*************************************************
def wdatas(dat):
GPIO.output(a0, GPIO.HIGH)
GPIO.output(cs1, GPIO.LOW)
data_send(dat)
def display_map(p):
i = 0
for page in range(0xb0,0xb8):
w_coms(page)
w_coms(0x10)
w_coms(0x00)
for seg in range(128):
wdatas(p[i])
i += 1
while True:
GPIO.setup(a0, GPIO.OUT)
GPIO.setup(cs1, GPIO.OUT)
GPIO.setup(rst, GPIO.OUT)
GPIO.setup(sclk, GPIO.OUT)
GPIO.setup(di, GPIO.OUT)
GPIO.output(rst, GPIO.LOW)
nop()
nop()
GPIO.output(rst, GPIO.HIGH)
w_coms(0xaf)
w_coms(0x40)
w_coms(0xa0)
w_coms(0xa6)
w_coms(0xa4)
w_coms(0xa2)
w_coms(0xc8)
w_coms(0x2f)
w_coms(0x24)
w_coms(0x81)
w_coms(0x24)
while True:
display_map(niu)
time.sleep(1)
display_map(hello)
time.sleep(1)