?? lm3228.lst
字號(hào):
120 #define GRAPHIC_ADDRESS 0x02
121 #define GRAPHIC_WIDTH 0x03
122 void set_display_area(uchar i,uchar dat1,uchar dat2)
123 {
124 1 if(i==0x01||i==0x03)
125 1 dat2=0;
126 1 check_code_data();
127 1 DATA_PORT=dat1;
128 1 check_code_data();
129 1 DATA_PORT=dat2;
130 1 check_code_data();
131 1 COMMAND_PORT=(0x40|i);
132 1 }
133 /********************************************************************************************/
134 //顯示開關(guān)設(shè)置
135 #define CURSORBLINK 0x01
136 #define CURSORON 0x02
137 #define TEXTON 0x04
138 #define GRAPHICON 0x08
139
140 void set_display(uchar displaymode)
141 {
142 1 check_code_data();
143 1 COMMAND_PORT=(displaymode|0x90);
144 1 }
145 /********************************************************************************************/
146 //光標(biāo)形狀設(shè)置
147 //參數(shù)0-7
148 void set_cursor(uchar i)
149 {
150 1 check_code_data();
151 1 COMMAND_PORT=(0xa0|i);
152 1 }
153 /********************************************************************************************/
154 //自動(dòng)讀寫定義
155 #define AUTOREAD 0x00
156 #define AUTOWRITE 0x01
157 #define AUTOSTOP 0x02
158 void set_autoreadwrite(uchar i)
159 {
160 1 check_code_data();
161 1 COMMAND_PORT=(0xb0|i);
162 1 }
163 /********************************************************************************************/
164 //一次讀寫定義
165 #define write_address_add 0x00
166 #define read_address_add 0x01
167 #define write_address_sub 0x02
168 #define read_address_sub 0x03
169 #define write_address_nochange 0x04
170 #define read_address_nochange 0x05
171 void set_once_read_write(uchar i,uchar letter)
C51 COMPILER V8.08 LM3228 06/02/2007 16:43:18 PAGE 5
172 {
173 1 check_code_data();
174 1 DATA_PORT=letter;
175 1 check_code_data();
176 1 COMMAND_PORT=(0xc0|i);
177 1 }
178
179 /********************************************************************************************/
180 //屏讀
181 void screen_read(void)
182 {
183 1 check_code_data();
184 1 COMMAND_PORT=0xe0;
185 1 }
186
187 /********************************************************************************************/
188 //屏拷貝
189 void screen_copy(void)
190 {
191 1 check_code_data();
192 1 COMMAND_PORT=0xe8;
193 1 }
194 /********************************************************************************************/
195 //位操作
196 #define set_bit 0x08
197 #define clear_bit 0x00
198 void bit_operation(uchar op,uchar i)
199 {
200 1 check_code_data();
201 1 COMMAND_PORT=(0xf0|op|i);
202 1 }
203 /********************************************************************************************/
204 void print_lcd(uchar str,uchar x,uchar y)
205 {
206 1 unsigned int addr;
207 1 addr=y*16+x;
208 1
209 1 check_code_data();
210 1 DATA_PORT=addr;
211 1 check_code_data();
212 1 DATA_PORT=addr>>8;
213 1 check_code_data();
214 1 COMMAND_PORT=0x24;
215 1 check_code_data();
216 1 DATA_PORT=str;
217 1 check_code_data();
218 1 COMMAND_PORT=0xc4;
219 1 }
220 /********************************************************************************************/
221 //顯示字符
222 void text_display(uchar num,uchar *str,uchar lowaddr,uchar highaddr)
223 {
224 1 uchar i;
225 1 set_point(SET_ADDRESS_POINTER,lowaddr,highaddr);
226 1 for(i=0;i<num;i++)
227 1 {
228 2 set_once_read_write(write_address_add,str[i]);
229 2 }
230 1 }
231 /********************************************************************************************/
232 //顯示漢字
233 void hanzi_display(uchar *str,uchar num,uchar lowaddr,uchar highaddr)
C51 COMPILER V8.08 LM3228 06/02/2007 16:43:18 PAGE 6
234 {
235 1 uchar i,j,k,laddr,haddr,addr,caddr,m ;
236 1 uint sum=0;
237 1 laddr=lowaddr;
238 1 haddr=highaddr;
239 1 m=0;
240 1 for(k=0;k<num;k++)
241 1 {
242 2
243 2 caddr=laddr+m*2;
244 2 m++;
245 2 if(caddr>0x0e)
246 2 {
247 3 laddr=0x00;
248 3 haddr++;
249 3 caddr=0x00;
250 3 //num=num-k;
251 3 m=0;
252 3
253 3 caddr=laddr+m*2;
254 3 m++;
255 3 }
256 2 for(i=0;i<16;i++)
257 2 {
258 3 addr=caddr+16*i;
259 3
260 3
261 3 set_point(SET_ADDRESS_POINTER,addr,haddr);
262 3 for(j=0;j<2;j++)
263 3 {
264 4 set_once_read_write(write_address_add,str[sum++]);//[k*32+i*2+j]);
265 4 }
266 3 }
267 2 }
268 1 }
269 /********************************************************************************************/
270 //清屏
271 void clrscreen(void)
272 {
273 1
274 1 }
275 /********************************************************************************************/
276 //圖片顯示
277 void picture_display(uchar *str,uint len,uchar lowaddr,uchar highaddr)
278 {
279 1 uint i,sum;
280 1 sum=0;
281 1 set_point(SET_ADDRESS_POINTER,lowaddr,highaddr);
282 1 for(i=0;i<len;i++)
283 1 {
284 2
285 2 set_once_read_write(write_address_add,str[sum++]);
286 2 }
287 1 }
288 /*void display(void)
289 {
290 picture_display(picture2,sizeof(picture2),0x00,0x10);
291 } */
292
293 /********************************************************************************************/
294
295 //初始化lcd
C51 COMPILER V8.08 LM3228 06/02/2007 16:43:18 PAGE 7
296 void init_lcd(void)
297 {
298 1
299 1
300 1 //uint i,j;
301 1 set_display_area(TEXT_ADDRESS,0x00,0x00);
302 1 set_display_area(TEXT_WIDTH,0x10,0x00); //因?yàn)?228是128*64,顯示的字符為16*8,所以字符寬度為16
303 1 set_display_area(GRAPHIC_ADDRESS,0x00,0x10);
304 1 set_display_area(GRAPHIC_WIDTH,0x10,0x00);
305 1 set_display(TEXTON|GRAPHICON);
306 1 //set_point(SET_ADDRESS_POINTER,0x34,0x00);
307 1 //text_display(sizeof(letter),letter);
308 1 //set_point(SET_ADDRESS_POINTER,0x00,0x10);
309 1
310 1
311 1
312 1
313 1
314 1 }
C51 COMPILATION COMPLETE. 0 WARNING(S), 70 ERROR(S)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -