📄 lcddriver.lst
字号:
C51 COMPILER V7.20 LCDDRIVER 01/31/2007 10:20:44 PAGE 1
C51 COMPILER V7.20, COMPILATION OF MODULE LCDDRIVER
OBJECT MODULE PLACED IN LCDdriver.OBJ
COMPILER INVOKED BY: D:\Program Files\Keil\C51\BIN\c51.exe LCDdriver.c DB OE
line level source
1 #include "LZK.h"
2 //////////////////////////////////////////////////////////////////////////////
3
4
5
6 void LCD_Cs(void)
7 {
8 1 uint8 data ucTMP;
9 1 SFRPAGE = 0x00;
10 1 EMI0CF = 0x27;
11 1 EMI0TC = 0xff;
12 1
13 1 SFRPAGE = 0x0f;
14 1 ucTMP = ucP4DATA & 0xC0 | 16;
15 1 P4 = ucTMP;
16 1 SFRPAGE = 0x00;
17 1 }
18 void LCD_Reset(void)
19 {
20 1 LCD_RST=0;
21 1 DmS(20);
22 1 LCD_RST=1;
23 1 }
24 void LCD_Wcommand(uint8 t)
25 {
26 1 LCD_COMMAND = t;
27 1 }
28 void LCD_Wdata(uint8 t)
29 {
30 1 LCD_DATA = t;
31 1 }
32 /////////////////////////////////////////////////////////////
33 void LCD_ClearAll()
34 {
35 1 uint16 i;
36 1 LCD_Cs();
37 1 LCD_Wcommand(0XB0); /*SET PAGE ADDRESS*/
38 1 LCD_Wcommand(0X10); /*SET COLUMN ADDRESS MSB(00000000)*/
39 1 LCD_Wcommand(0X00); /*SET COLUMN ADDRESS LSB(00000000)*/
40 1 LCD_Wcommand(0X89); /*SET RAM ADDRESS CONTROL*/
41 1 for(i=0;i<3840;i++)
42 1 LCD_Wdata(0x00);
43 1
44 1 ExInSRAM_Select(0);
45 1 }
46 void LCD_Initialize()
47 {
48 1
49 1
50 1 LCD_Reset();
51 1 DmS(20);
52 1
53 1 /****************************
54 1 *** 240128-052W
55 1 ****************************/
C51 COMPILER V7.20 LCDDRIVER 01/31/2007 10:20:44 PAGE 2
56 1 LCD_Cs(); /* ExSRAM Page 16. */
57 1
58 1 LCD_Wcommand(0xE2); /* System reset*/
59 1 DmS(1);
60 1 LCD_Wcommand(0xEB); /* Set lcd bias ratio: 111010_10 */
61 1 LCD_Wcommand(0x25); /* Set mux rate and temperature compensation*/
62 1 LCD_Wcommand(0x81);
63 1 LCD_Wcommand(0xA5); /* Set gain and potentiometer 1_01_00101 */
64 1 LCD_Wcommand(0x2F); /* Set power control 00101_1_11 */
65 1 LCD_Wcommand(0xAF); /* Display Enable: 1010111_1 */
66 1
67 1 DmS(10);
68 1
69 1 LCD_Wcommand(0x40); /* Set start line: 01_000000 */
70 1 LCD_Wcommand(0xA4); /* Set all pixel on: 1010010_DC[1] */
71 1 LCD_Wcommand(0xA6); /* Set inverse display: 1010011_DC[0] */
72 1 LCD_Wcommand(0x89); /* Set ram address control: 10001_001 */
73 1 LCD_Wcommand(0xC8); /* Set lcd mapping control: 1100_1_0__0 */
74 1
75 1 ExInSRAM_Select(0); //
76 1 }
77 void LCD_WByte(uint8 x,uint8 y,uint8 t)
78 {
79 1 LCD_Cs();
80 1 LCD_Wcommand(176+y);
81 1 LCD_Wcommand(16+x/16);
82 1 LCD_Wcommand(x%16);
83 1 LCD_Wdata(t);
84 1
85 1 ExInSRAM_Select(0);
86 1 }
87 void LCD_WPoint(uint8 x,uint8 y,bit k)
88 {
89 1 LCD_Cs();
90 1 LCD_Wcommand(176+y/8);
91 1 LCD_Wcommand(16+x/16);
92 1 LCD_Wcommand(x%16);
93 1 if(k)
94 1 LCD_Wdata(0x01<<y%8);
95 1 else
96 1 LCD_Wdata(0x00);
97 1
98 1 ExInSRAM_Select(0);
99 1 }
100 /********************************************************************************/
101 void LCD_Chinese(uint8 x,uint8 y,uint8 *str,bit k,bit t)
102 {
103 1 uint8 *OffSet;
104 1 uint8 i;
105 1 uint16 AddOffSet;
106 1
107 1 OffSet=strstr(Index, str);
108 1 AddOffSet=(OffSet-Index)<<4;
109 1 if(!t)
110 1 {
111 2 if(!k)
112 2 {
113 3 for(i=0;i<16;i++)
114 3 LCD_WByte(x+i,y,CAlib[AddOffSet++]);
115 3 for(i=0;i<16;i++)
116 3 LCD_WByte(x+i,y+1,CAlib[AddOffSet++]);
117 3 }
C51 COMPILER V7.20 LCDDRIVER 01/31/2007 10:20:44 PAGE 3
118 2 else
119 2 {
120 3 for(i=0;i<16;i++)
121 3 LCD_WByte(x+i,y,~CAlib[AddOffSet++]);
122 3 for(i=0;i<16;i++)
123 3 LCD_WByte(x+i,y+1,~CAlib[AddOffSet++]);
124 3 }
125 2 }
126 1 else
127 1 {
128 2 if(!k)
129 2 {
130 3 for(i=0;i<16;i++)
131 3 LCD_WByte(x+i,y,FAlib[AddOffSet++]);
132 3 for(i=0;i<16;i++)
133 3 LCD_WByte(x+i,y+1,FAlib[AddOffSet++]);
134 3 }
135 2 else
136 2 {
137 3 for(i=0;i<16;i++)
138 3 LCD_WByte(x+i,y,~FAlib[AddOffSet++]);
139 3 for(i=0;i<16;i++)
140 3 LCD_WByte(x+i,y+1,~FAlib[AddOffSet++]);
141 3 }
142 2 }
143 1 }
144
145 void LCD_Ascii(uint8 x,uint8 y,uint8 *str,bit k)
146 {
147 1 uint8 *OffSet;
148 1 uint8 i;
149 1 uint16 AddOffSet;
150 1
151 1 OffSet=strstr(Index, str);
152 1 AddOffSet=(OffSet-Index)<<4;
153 1 if(!k)
154 1 {
155 2 for(i=0;i<8;i++)
156 2 LCD_WByte(x+i,y,CAlib[AddOffSet++]);
157 2 for(i=0;i<8;i++)
158 2 LCD_WByte(x+i,y+1,CAlib[AddOffSet++]);
159 2 }
160 1 else
161 1 {
162 2 for(i=0;i<8;i++)
163 2 LCD_WByte(x+i,y,~CAlib[AddOffSet++]);
164 2 for(i=0;i<8;i++)
165 2 LCD_WByte(x+i,y+1,~CAlib[AddOffSet++]);
166 2 }
167 1 }
168
169 void LCD_CAstr(uint8 x,uint8 y,uint8 *str,bit k,bit t)
170 {
171 1 uint8 rega[2];
172 1 uint8 regc[3];
173 1 while( *str != 0 )
174 1 {
175 2 if( (uint8)*str < 0xA0 )
176 2 {
177 3 strncpy(rega, str, 1);
178 3 rega[1]=0;
179 3 LCD_Ascii(x,y,rega,k);
C51 COMPILER V7.20 LCDDRIVER 01/31/2007 10:20:44 PAGE 4
180 3 str=str+1;
181 3 x=x+8;
182 3 }
183 2 if( (uint8)*str >= 0xA0 )
184 2 {
185 3 strncpy(regc, str, 2);
186 3 regc[2]=0;
187 3 LCD_Chinese(x,y,regc,k,t);
188 3 str=str+2;
189 3 x=x+16;
190 3 }
191 2 }
192 1 }
193
194 void LCD_math(uint8 x,uint8 y,char t,bit k)
195 {
196 1 uint8 i;
197 1 uint16 AddOffSet;
198 1
199 1 AddOffSet=6048+16*t;
200 1 if(!k)
201 1 {
202 2 for(i=0;i<8;i++)
203 2 LCD_WByte(x+i,y,CAlib[AddOffSet++]);
204 2 for(i=0;i<8;i++)
205 2 LCD_WByte(x+i,y+1,CAlib[AddOffSet++]);
206 2 }
207 1 else
208 1 {
209 2 for(i=0;i<8;i++)
210 2 LCD_WByte(x+i,y,~CAlib[AddOffSet++]);
211 2 for(i=0;i<8;i++)
212 2 LCD_WByte(x+i,y+1,~CAlib[AddOffSet++]);
213 2 }
214 1 }
215
216 void LCD_Num(uint8 x,uint8 y,uint16 t,bit k,uint8 *str)
217 {
218 1 char a,b,c,d;
219 1
220 1 a=(int)t/1000;
221 1 b=(int)t/100-a*10;
222 1 c=(int)t/10-a*100-b*10;
223 1 d=(int)t%10;
224 1
225 1 if(a!=0)
226 1 {
227 2 LCD_math(x,y,a,k);
228 2 LCD_math(x+8,y,b,k);
229 2 LCD_math(x+16,y,c,k);
230 2 LCD_math(x+24,y,d,k);
231 2 LCD_CAstr(x+32,y,str,0,0);
232 2 }
233 1 if(a==0&&b!=0)
234 1 {
235 2 LCD_math(x,y,b,k);
236 2 LCD_math(x+8,y,c,k);
237 2 LCD_math(x+16,y,d,k);
238 2 LCD_CAstr(x+24,y,str,0,0);
239 2 }
240 1 if(a==0&&b==0&&c!=0)
241 1 {
C51 COMPILER V7.20 LCDDRIVER 01/31/2007 10:20:44 PAGE 5
242 2 LCD_math(x,y,c,k);
243 2 LCD_math(x+8,y,d,k);
244 2 LCD_CAstr(x+16,y,str,0,0);
245 2 }
246 1 if(a==0&&b==0&&c==0)
247 1 {
248 2 LCD_math(x,y,d,k);
249 2 LCD_CAstr(x+8,y,str,0,0);
250 2 }
251 1 }
252
253 void LCD_Sum(uint8 x,uint8 y,uint16 t,bit k,uint8 *str)
254 {
255 1 uint8 a,b,c;
256 1 a=(int)t/100;
257 1 b=(int)t/10-a*10;
258 1 c=(int)t%10;
259 1
260 1 if(t<10)
261 1 {
262 2 LCD_CAstr(x,y,"0.",k,0);
263 2 LCD_math(x+16,y,c,k);
264 2 LCD_CAstr(x+24,y,str,0,0);
265 2 }
266 1 else if(t>9&&t<100)
267 1 {
268 2 LCD_math(x,y,b,k);
269 2 LCD_CAstr(x+8,y,".",k,0);
270 2 LCD_math(x+16,y,c,k);
271 2 LCD_CAstr(x+24,y,str,0,0);
272 2 }
273 1 else if(t>100)
274 1 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -