📄 lcd128x64.lst
字号:
C51 COMPILER V7.08 LCD128X64 03/05/2007 16:38:04 PAGE 1
C51 COMPILER V7.08, COMPILATION OF MODULE LCD128X64
OBJECT MODULE PLACED IN lcd128x64.OBJ
COMPILER INVOKED BY: D:\程序\keil c\C51\BIN\C51.EXE lcd128x64.c LARGE INCDIR(c:|keil) DEBUG OBJECTEXTEND
line level source
1 #include <intrins.h> //液晶显示子程序
2 #include <LCD128x64.h>
3 #include <LCD_date_2.h>
4 #include <24C02.h>
5 #include <weight.h>
6 #include <print.h>
7 #include <set.h>
8
9 disp_num_address second_buffer = {0};
10 disp_num_address minute_buffer = {0};
11 disp_num_address hour_buffer = {0};
12
13 disp_num_address day_buffer = {0};
14 disp_num_address month_buffer = {0};
15 disp_num_address year_buffer = {0};
16 disp_num_address week_buffer = {0x20,0};
17
18 disp_num_address_1 save_type_buffer = {0};
19 disp_num_address_2 save_pizhong_buffer = {0};///修改
20
21 void delay3(void)
22 {
23 1 BYTE i,j,k;
24 1 for(i = 0x16; i > 0; i--){
25 2 for(j = 0xFF; j > 0; j--){
26 3 for(k = 0xFF; k > 0; k--);
27 3 }
28 2 }
29 1 }
30
31 void delay2(void)
32 {
33 1 BYTE i,j;
34 1 for(i = 0xC; i > 0; i--){
35 2 for(j = 0x18; j > 0; j--);
36 2 }
37 1 }
38
39 void delay1(void)
40 {
41 1 BYTE i,j;
42 1 for(i = 0x6; i > 0; i--){
43 2 for(j = 0x8; j > 0; j--);
44 2 }
45 1 }
46
47 void delay4(void)
48 {
49 1 BYTE i,j;
50 1 for(i = 200; i > 0; i--){
51 2 for(j = 200; j > 0; j--);
52 2 }
53 1 }
54
55 void delay5(void)
C51 COMPILER V7.08 LCD128X64 03/05/2007 16:38:04 PAGE 2
56 {
57 1 BYTE i,j,k;
58 1 for(i = 0x5; i > 0; i--){
59 2 for(j = 0xFF; j > 0; j--){
60 3 for(k = 0xFF; k > 0; k--);
61 3 }
62 2 }
63 1 }
64
65
66 void lcd_Check_Busy(void)
67 {
68 1 P0 = 0xFF;
69 1 LCD_D_C = 0;
70 1 LCD_R_W = 1;
71 1 LCD_EN = 1;
72 1 _nop_();
73 1 _nop_();
74 1 _nop_();
75 1 _nop_();
76 1 _nop_();
77 1 _nop_();
78 1 _nop_();
79 1 delay2();
80 1 LCD_EN = 0;
81 1 }
82 /*
83 BYTE lcd_Read_Byte(void)
84 {
85 BYTE value;
86
87 lcd_Check_Busy();
88 LCD_D_C = 1;
89 LCD_R_W = 1;
90 LCD_EN = 1;
91 _nop_();
92 value = P0;
93 LCD_EN = 0;
94 return value;
95 }
96 */
97 void lcd_Write_Cmd(BYTE cmd)
98 {
99 1 lcd_Check_Busy();
100 1
101 1 LCD_D_C = 0;
102 1 LCD_R_W = 0;
103 1 LCD_EN = 1;
104 1 _nop_();
105 1 _nop_();
106 1 P0 = cmd;
107 1 _nop_();
108 1 _nop_();
109 1 _nop_();
110 1 _nop_();
111 1 LCD_EN = 0;
112 1 }
113
114
115 void lcd_Write_Dat(BYTE dat)
116 {
117 1 lcd_Check_Busy();
C51 COMPILER V7.08 LCD128X64 03/05/2007 16:38:04 PAGE 3
118 1 LCD_D_C = 1;
119 1 LCD_R_W = 0;
120 1 LCD_EN = 1;
121 1
122 1 P0 = dat;
123 1 _nop_();
124 1 _nop_();
125 1 LCD_EN = 0;
126 1 }
127
128 void lcd_Init(void)
129 { //液晶初始化
130 1 LCD_RST = 0;
131 1 delay4();
132 1 LCD_RST = 1;
133 1 _nop_();
134 1 LCD_P_S = 1;//并口
135 1 P0 = 1;
136 1 lcd_Write_Cmd(0x34); //34H--exp instruction
137 1 lcd_Write_Cmd(0x30); //30H--base instruction
138 1 lcd_Write_Cmd(0x0C); //clear disp
139 1 lcd_Write_Cmd(0x01); //the direction of cursor move
140 1 lcd_Write_Cmd(0x01); //open disp ,close cursor
141 1 }
142
143 void lcd_Disp_Clear(void)
144 { //液晶清屏
145 1 lcd_Write_Cmd(0x01);
146 1 lcd_Write_Cmd(0x34);
147 1 lcd_Write_Cmd(0x30);
148 1 }
149 /*
150 void lcd_Disp_Text_Line_Break(BYTE *str) 显示字符
151 {
152 BYTE COUNT;
153
154 COUNT = 0x40;
155 lcd_Write_Cmd(0x80);
156 //QUSHU
157 for(;COUNT > 0;COUNT--) {
158 lcd_Write_Dat(*str);
159 str++;
160 delay4();
161 }
162 //QUSHU end
163 delay3();
164 flash();
165 }
166 */
167
168 /*manipulate a pointer to a string, give the display address and the string's pointer
169 * use the standard unicode of character,directly send it to the lcd mode.
170 * support four lines and eight columns display ,the address is below:
171 * line1 : 0x80-0x87
172 * line2 : 0x90-0x97
173 * line3 : 0x88-0x8F
174 * line4 : 0x98-0x9F
175 */
176 void lcd_Disp_Text_Line_Order(BYTE startaddress, BYTE *str) //chinese or character display in order
177 {
178 1 //lcd_Disp_Clear();
179 1 lcd_Write_Cmd(startaddress);
C51 COMPILER V7.08 LCD128X64 03/05/2007 16:38:04 PAGE 4
180 1 //for(COUNT = 0x10;COUNT > 0;COUNT--) {//set the address counter 16。
181 1 while(*str != 0){
182 2 lcd_Write_Dat(*str);
183 2 str++;
184 2 //delay4();//delay for debug
185 2 }
186 1 }
187 //dispalu a array just like a photo
188 void lcd_Disp_array(void)
189 {
190 1 BYTE LCD_DATA1,LCD_DATA2,COUNT3,LCD_X,LCD_Y,COUNT2,COUNT1,LCD_DATA;
191 1 BOOL flag;
192 1
193 1 lcd_Disp_Clear();
194 1 LCD_DATA1 = 0xCC;
195 1 LCD_DATA2 = 0xCC;
196 1 COUNT3 = 0x02;
197 1 LCD_X = 0x80;
198 1 for(;COUNT3 > 0;COUNT3--){
199 2 LCD_Y = 0x80;
200 2 flag = 0;
201 2 COUNT2 = 0x20;
202 2 for (;COUNT2 > 0;COUNT2--){
203 3 COUNT1 = 0x10;
204 3 //WR_ZB
205 3 lcd_Write_Cmd(0x34);
206 3 lcd_Write_Cmd(LCD_Y);
207 3 lcd_Write_Cmd(LCD_X);
208 3 lcd_Write_Cmd(0x30);
209 3
210 3 if (flag)
211 3 LCD_DATA = LCD_DATA2;
212 3 else
213 3 LCD_DATA = LCD_DATA1;
214 3
215 3 for(;COUNT1 > 0;COUNT1--)
216 3 lcd_Write_Dat(LCD_DATA);
217 3
218 3 LCD_Y++;
219 3 flag = !flag;
220 3 }
221 2 LCD_X = 0x88;
222 2 }
223 1 lcd_Write_Cmd(0x36);
224 1 lcd_Write_Cmd(0x30);
225 1 }
226
227 /*in graphy mode the lcd is divided into two parts in vertical direction, every part is 32 lines
228 * the first part start address is (0x80,0x80),every line has 16 bytes,has the same address,the
229 * second line address is (0x80,0x81),and so on,the last line address is (0x80,0x80+0x20);
230 * the second part start address is (0x88,0x80),every line has 16 bytes,has the same address,the
231 * last line address is (0x88,0x80+0x20);
232 */
233 void lcd_Disp_Pho(BYTE *value) //显示图形
234 {
235 1 BYTE LCD_X, LCD_Y, COUNT1, COUNT2, COUNT3;
236 1
237 1 LCD_X = 0x80;
238 1 for(COUNT3 = 0x02;COUNT3 > 0;COUNT3--) { //the section is divided into two parts
239 2 LCD_Y = 0x80; // both parts first line Y address
240 2 for(COUNT2 = 0x20;COUNT2 > 0;COUNT2--) { // every part has 32 lines
241 3
C51 COMPILER V7.08 LCD128X64 03/05/2007 16:38:04 PAGE 5
242 3 lcd_Write_Cmd(0x34); // start to give address
243 3 lcd_Write_Cmd(LCD_Y);
244 3 lcd_Write_Cmd(LCD_X);
245 3 lcd_Write_Cmd(0x30);
246 3
247 3 for(COUNT1 = 0x10;COUNT1 > 0;COUNT1--) {//every line has 16 bytes, equate 128 bits
248 4 lcd_Write_Dat(*value);
249 4 value++;
250 4 }
251 3 LCD_Y++; //line Y address add 1
252 3 }
253 2 LCD_X = 0x88; // start the second part
254 2 }
255 1 lcd_Write_Cmd(0x36);
256 1 lcd_Write_Cmd(0x30);
257 1 }
258
259 //display the five corner input char,has no use in the application
260 void lcd_Display_Lib_Char(void) //显示库里的字符
261 {
262 1 BYTE COUNT,TEM;
263 1
264 1 //lcd_Disp_Clear();
265 1 COUNT = 0x40;
266 1 lcd_Write_Cmd(0x80);
267 1 TEM = 0x10;
268 1 for(;COUNT > 0;COUNT--){
269 2 lcd_Write_Dat(TEM);
270 2 TEM++;
271 2 }
272 1 delay3();
273 1 lcd_Disp_Clear();
274 1 }
275
276 /*manipulate the lcd itself char lib,give the display address and the character's code
277 *support four lines and eight columns display ,the address is below:
278 * line1 : 0x80-0x87
279 * line2 : 0x90-0x97
280 * line3 : 0x88-0x8F
281 * line4 : 0x98-0x9F
282 */
283 void lcd_Display_Lib_Chinese(BYTE startaddress, WORD ucode) //0xB9F3 //显示库里的汉字
284 {
285 1 //lcd_Disp_Clear();
286 1 lcd_Write_Cmd(0x80); //use its unicode
287 1 lcd_Write_Cmd(startaddress);//give address
288 1
289 1 lcd_Write_Dat(ucode >> 8); //the high byte
290 1 lcd_Write_Dat(ucode & 0xFF); //the low byte
291 1 }
292
293 void LCD_Flash(void) //闪动
294 {
295 1 lcd_Write_Cmd(0x08);//close disp
296 1 delay5();
297 1 lcd_Write_Cmd(0x0c);//open disp,close cursor
298 1 delay5();
299 1 lcd_Write_Cmd(0x08);//close disp
300 1 delay5();
301 1 lcd_Write_Cmd(0x0c);//open disp,close cursor
302 1 delay5();
303 1 lcd_Write_Cmd(0x08);//close disp
C51 COMPILER V7.08 LCD128X64 03/05/2007 16:38:04 PAGE 6
304 1 delay5();
305 1 }
306
307 void lcd_clear_line(BYTE linenum) //清除某一行
308 {
309 1 BYTE count,start_address;
310 1
311 1 switch (linenum){
312 2 case 0:
313 2 start_address = 0x80;
314 2 break;
315 2 case 1:
316 2 start_address = 0x90;
317 2 break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -