📄 main.lst
字号:
195 1 unsigned char i;
196 1 for(i=x1;i<x2+1;i++)
197 1 Draw_dots(i,(y2-y1)*(i-x1)/(x2-x1)+y1,2);
198 1 }
199 /**********************************
200 画圆:
201 (x,y)为圆心,r为半径
202 ***********************************/
203 void Draw_circle(unsigned char x,y,r)
204 {
205 1 unsigned char i;
206 1 for(i=x-r;i<x+r+1;i++)
207 1 {
208 2 Draw_dots(i,y-sqrt(r*r-(x-i)*(x-i)),2);
209 2 Draw_dots(i,y+sqrt(r*r-(x-i)*(x-i)),2);
210 2 }
211 1 }
212 /**********************************
213 两矩形:
214 (x1,y1)为矩形左上角坐标点
215 (x2,y2)为矩形右上角坐标点
216 ***********************************/
217 void Draw_retic(uchar x1,uchar y1,uchar x2,uchar y2)//画正方形,x1,y1为左上角坐标,x2,y2为右下角坐标
218 {
219 1 uchar i;
220 1 for(i=0;i<=x2-x1;i++)
221 1 {
222 2 Draw_dots(x1+i,y1,2);
223 2 Draw_dots(x1+i,y2,2);
224 2 }
225 1 for(i=0;i<=y2-y1;i++)
226 1 {
227 2 Draw_dots(x1,y1+i,2);
228 2 Draw_dots(x2,y1+i,2);
229 2 }
230 1 }
231
232
233 void Display_ASCII(uchar screen,uchar page,uchar column,uchar *p)
234 {
235 1 uchar i;
236 1 SelectScreen(screen);
237 1 Set_page(page);
238 1 Set_column(column);
239 1 for(i=0;i<8;i++) //显示字符上半部分:8*8
240 1 {
241 2 write_LCD_data(p[i]);
C51 COMPILER V8.02 MAIN 05/08/2012 23:40:12 PAGE 5
242 2 }
243 1 Set_page(page+1); //显示字符下半部分:8*8
244 1 Set_column(column);
245 1 for(i=0;i<8;i++)
246 1 {
247 2 write_LCD_data(p[i+8]);
248 2 }
249 1 }
250 void Display_HZ(uchar screen,uchar page,uchar column,uchar *p)
251 {
252 1 uchar i;
253 1 SelectScreen(screen);
254 1 Set_page(page); //写上半页:16*8
255 1 Set_column(column*16); //控制列
256 1 for(i=0;i<16;i++) //控制16列的数据输出
257 1 {
258 2 write_LCD_data(p[i]); //汉字的上半部分
259 2 }
260 1 Set_page(page+1); //写下半页:16*8
261 1 Set_column(column*16); //控制列
262 1 for(i=0;i<16;i++) //控制16列的数据输出
263 1 {
264 2 write_LCD_data(p[i+16]); //汉字的下半部分
265 2 }
266 1 }
267
268 void Display_picture(uchar a[][64])//显示图形—128*64大小
269 {
270 1 uchar i,j;
271 1
272 1 for(j=0;j<8;j++)
273 1 {
274 2 SelectScreen(1);
275 2 Set_page(j);
276 2 Set_column(0);
277 2 for(i=0;i<64;i++)
278 2 {
279 3 write_LCD_data(a[2*j][i]);//每隔一行取一次数组中的数据
280 3 }
281 2 SelectScreen(2);
282 2 Set_page(j);
283 2 Set_column(0);
284 2 for(i=0;i<64;i++)
285 2 {
286 3 write_LCD_data(a[2*j+1][i]);//每隔一行取一次数组中的数据
287 3 }
288 2 }
289 1 }
290
291 void key_scan(void)
292 {
293 1 uchar i;
294 1 if(KEY1==0) //按键1按下,显示汉字
295 1 {
296 2 delay(5000);
297 2 if(KEY1==0)
298 2 {
299 3 while(!KEY1);
300 3 ClearScreen(0);
301 3 for(i=8;i>0;i--) //滚屏
302 3 {
303 4 Display_HZ(1,0+i,2,huan);
C51 COMPILER V8.02 MAIN 05/08/2012 23:40:12 PAGE 6
304 4 Display_HZ(1,0+i,3,ying);
305 4 Display_HZ(2,0+i,0,fang);
306 4 Display_HZ(2,0+i,1,wen);
307 4 Display_HZ(1,2+i,0,da);
308 4 Display_HZ(1,2+i,1,hai);
309 4 Display_HZ(1,2+i,2,xiang);
310 4 Display_HZ(1,2+i,3,shu);
311 4 Display_HZ(2,2+i,0,bai);
312 4 Display_HZ(2,2+i,1,du);
313 4 Display_HZ(2,2+i,2,kong);
314 4 Display_HZ(2,2+i,3,jian);
315 4 delay(30000);
316 4 ClearScreen(0);
317 4 }
318 3 Display_HZ(1,0+i,2,huan);
319 3 Display_HZ(1,0+i,3,ying);
320 3 Display_HZ(2,0+i,0,fang);
321 3 Display_HZ(2,0+i,1,wen);
322 3 Display_HZ(1,2+i,0,da);
323 3 Display_HZ(1,2+i,1,hai);
324 3 Display_HZ(1,2+i,2,xiang);
325 3 Display_HZ(1,2+i,3,shu);
326 3 Display_HZ(2,2+i,0,bai);
327 3 Display_HZ(2,2+i,1,du);
328 3 Display_HZ(2,2+i,2,kong);
329 3 Display_HZ(2,2+i,3,jian);
330 3 }
331 2 }
332 1
333 1 if(KEY2==0) //按键2按下,显示图片---大海橡树
334 1 {
335 2 delay(5000);
336 2 if(KEY2==0)
337 2 {
338 3 while(!KEY2);
339 3 ClearScreen(0);
340 3 Display_picture(BMP);
341 3 }
342 2 }
343 1
344 1 if(KEY3==0) //按键3按下,显示几何图形
345 1 {
346 2 delay(5000);
347 2 if(KEY3==0)
348 2 {
349 3 while(!KEY3);
350 3 ClearScreen(0);
351 3 Display_HZ(1,0,2,zhi);
352 3 Display_HZ(1,0,3,xian);
353 3
354 3 Display_HZ(2,2,1,ju);
355 3 Display_HZ(2,2,2,xing);
356 3
357 3 Display_HZ(1,4,1,yuan);
358 3
359 3 Draw_line(0,0,127,63);
360 3 Draw_retic(70,0,120,33);
361 3 Draw_circle(30,40,20);
362 3 }
363 2 }
364 1 }
365 void main()
C51 COMPILER V8.02 MAIN 05/08/2012 23:40:12 PAGE 7
366 {
367 1 init_LCD(); //初始12864
368 1 ClearScreen(0); //清屏
369 1 Set_line(0); //显示开始行
370 1 Display_HZ(1,2,1,qing);
371 1 Display_HZ(1,2,2,an);
372 1 Display_HZ(1,2,3,button);
373 1 Display_HZ(2,2,0,xuan);
374 1 Display_HZ(2,2,1,ze);
375 1 Display_HZ(2,2,2,andsoon); //上电显示:“请按键选择…”
376 1 while(1)
377 1 {
378 2
379 2 key_scan();
380 2 }
381 1 }
382
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1788 ----
CONSTANT SIZE = 1760 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 36
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -