📄 lcd_demo.lst
字号:
300 3 }
301 2 i++;
302 2
303 2 }
304 1 }
305
306
307 /*
308 --------------------------------------------------------------------------------
309
310 调用方式:void clrscr(void)
311 函数说明:清屏
312 --------------------------------------------------------------------------------
313 -*/
314 void clrscr(void)
315 {
316 1 uchar i;
317 1 uchar page;
318 1 for (page=0;page<4;page++)
319 1 {
320 2 SetPage(page,page);
321 2 SetAddress(0,0);
322 2 for (i=0;i<61;i++){PutCharR(0);PutCharL(0);}
ARM COMPILER V2.53, Lcd_Demo 02/08/06 16:25:34 PAGE 6
323 2 }
324 1 }
325
326
327 //-----------------------------------------------------------
328 //图片显示
329 //采用字模2生成或字模3生成的都可以.
330 //-----------------------------------------------------------
331 void DrawBmp1(uint x_add, uchar width,unsigned char const *bmp)
332 {
333 1 uchar x,address,i=0; //address表示显存的物理地址
334 1 uchar page=0; //page表示上下两页
335 1 uchar window=0; //window表示左右两页
336 1 //putcharR //右边
337 1 //putcharL //左边
338 1 for (x=width;x>1;x--)
339 1 {
340 2 if (x_add>60) {window=1;address=x_add%61;}
341 2 else address=x_add;
342 2
343 2
344 2 SetPage(0,0);
345 2 SetAddress(address,address);
346 2 if(window==1)PutCharR(bmp[i]);
347 2 else PutCharL(bmp[i]);
348 2 SetPage(1,1);
349 2 SetAddress(address,address);
350 2 if(window==1)PutCharR(bmp[i+width]);
351 2 else PutCharL(bmp[i+width]);
352 2
353 2
354 2 SetPage(2,2);
355 2 SetAddress(address,address);
356 2 if(window==1)PutCharR(bmp[i+width+width]);
357 2 else PutCharL(bmp[i+width+width]);
358 2 SetPage(3,3);
359 2 SetAddress(address,address);
360 2 if(window==1)PutCharR(bmp[i+width+width+width]);
361 2 else PutCharL(bmp[i+width+width+width]);
362 2 i++;
363 2 x_add++;
364 2
365 2 }
366 1 }
367
368 //---------------------------------------------------------------
369 //---------------------------------------------------------------
370 //采用zimo2 显示汉字,以汉字的显示方式
371 //void Draw_word(uchar d_where,uint x_add,bit layer,uchar width)
372 //d_where表示在码表中第几个汉字,x_add横坐标位置,layer显示的层, width显示的宽度。
373 //---------------------------------------------------------------
374
375
376 void Draw_word(uchar d_where,uint x_add,uchar layer,uchar width)
377 {
378 1 uchar x,i=0,address; //address表示显存的物理地址
379 1 uchar page=0; //page表示上下两页
380 1 uchar window=0; //window表示左右两页
381 1 //putcharR //右边
382 1 //putcharL //左边
383 1 d_where=d_where*32;
384 1
385 1 for (x=width;x>1;x--)
386 1 {
387 2 if (x_add>60) {window=1;address=x_add%61;}
388 2 else address=x_add;
ARM COMPILER V2.53, Lcd_Demo 02/08/06 16:25:34 PAGE 7
389 2
390 2 if(layer==0) //显示一行八个字
391 2 {
392 3
393 3 SetPage(0,0);
394 3 SetAddress(address,address);
395 3 if(window==1)PutCharR(bmp001[d_where]);//右边
396 3 else PutCharL(bmp001[d_where]);//左边
397 3 SetPage(1,1);
398 3 SetAddress(address,address);
399 3 if(window==1)PutCharR(bmp001[d_where+width]);
400 3 else PutCharL(bmp001[d_where+width]);
401 3
402 3 }
403 2 else
404 2 { //显示第二行八个汉字
405 3 SetPage(2,2);
406 3 SetAddress(address,address);
407 3 if(window==1)PutCharR(bmp001[d_where]);//右边
408 3 else PutCharL(bmp001[d_where]);//左边
409 3 SetPage(3,3);
410 3 SetAddress(address,address);
411 3 if(window==1)PutCharR(bmp001[d_where+width]);
412 3 else PutCharL(bmp001[d_where+width]);
413 3
414 3 }
415 2 x_add++;
416 2 d_where++;
417 2 }
418 1 }
419
420 void Draw_a(uchar d_where,uint x_add,uchar layer,uchar width)
421 {
422 1 uchar x,i=0,address; //address表示显存的物理地址
423 1 uchar page=0; //page表示上下两页
424 1 uchar window=0; //window表示左右两页
425 1 //putcharR //右边
426 1 //putcharL //左边
427 1 d_where=d_where*16;
428 1
429 1 for (x=width;x>1;x--)
430 1 {
431 2 if (x_add>60) {window=1;address=x_add%61;}
432 2 else address=x_add;
433 2
434 2 if(layer==0) //显示一行八个字
435 2 {
436 3
437 3 SetPage(0,0);
438 3 SetAddress(address,address);
439 3 if(window==1)PutCharR(bmp009[d_where]);//右边
440 3 else PutCharL(bmp009[d_where]);//左边
441 3 SetPage(1,1);
442 3 SetAddress(address,address);
443 3 if(window==1)PutCharR(bmp009[d_where+width]);
444 3 else PutCharL(bmp009[d_where+width]);
445 3
446 3 }
447 2 else
448 2 { //显示第二行八个汉字
449 3 SetPage(2,2);
450 3 SetAddress(address,address);
451 3 if(window==1)PutCharR(bmp009[d_where]);//右边
452 3 else PutCharL(bmp009[d_where]);//左边
453 3 SetPage(3,3);
454 3 SetAddress(address,address);
ARM COMPILER V2.53, Lcd_Demo 02/08/06 16:25:34 PAGE 8
455 3 if(window==1)PutCharR(bmp009[d_where+width]);
456 3 else PutCharL(bmp009[d_where+width]);
457 3
458 3 }
459 2 x_add++;
460 2 d_where++;
461 2 }
462 1 }
463
464 /****************************************************************************
465
466 蜂明器报警程序
467
468 *****************************************************************************/
469 void Beep_Alarm(uchar time)
470 {
471 1 uchar i;
472 1 for( i=time; i>0;i--){
473 2 Io_Set(BEEP);
474 2 delay1s(2);
475 2 Io_Clr(BEEP);
476 2 delay1s(2);
477 2 }
478 1
479 1 }
480 void IRQ_Timer0(void) __irq
481
482 {
483 1 key_code= Scan_Key();
484 1
485 1 T0IR = 0x01; /* 清除中断标志 */
486 1 VICVectAddr = 0x00; /* 通知VIC中断处理结束 */
487 1 }
488
489
490 void Timer0_init(void)
491 {
492 1
493 1
494 1
495 1 /* 定时器0初始化 */
496 1 T0TC = 0; /* 定时器设置为0 */
497 1 T0PR = 0; /* 时钟不分频 */
498 1 T0MCR = 0x03; /* 设置T0MR0匹配后复位T0TC,并产生中断标志 */
499 1 T0MR0 = Fpclk / 1000; /* 1M秒钟定时 */
500 1 T0TCR = 0x01; /* 启动定时器 */
501 1
502 1 /* 设置定时器0中断IRQ */
503 1 VICIntSelect = 0x00; /* 所有中断通道设置为IRQ中断 */
504 1 VICVectCntl0 = 0x20 | 0x04; /* 设置定时器0中断通道分配最高优先级 */
505 1 VICVectAddr0 = (uint)IRQ_Timer0; /* 设置中断服务程序地址 */
506 1 VICIntEnable = 1 << 0x04; /* 使能定时器0中断 */
507 1 }
508
509
510
511
512 //液晶显示规则
513 // M(左) S(右)
514 // page page
515 // 0 | 0
516 // 1 | 1
517 // 2 | 2
518 // 3 | 3
519
520 void delay1s(unsigned char i)
ARM COMPILER V2.53, Lcd_Demo 02/08/06 16:25:34 PAGE 9
521 {
522 1 while(i>1)
523 1 {
524 2 i--;
525 2 delayms(20);
526 2 }
527 1 }
528
529 //显示动态的等待图标
530 void wait1(unsigned char i)
531 {
532 1 clrscr(); //
533 1 DrawBmp1(0,60,Bmptc); //
534 1 for(;i>1;i--)
535 1 {delay1s(2);
536 2 DrawBmp1(76,19,Bmpt1); //
537 2 delay1s(2);
538 2 DrawBmp1(76,19,Bmpt2); //
539 2 delay1s(2);
540 2
541 2 // DrawBmp1(0,60,Bmptc); //
542 2 DrawBmp1(76,19,Bmpt3); //
543 2 delay1s(2);
544 2
545 2 // DrawBmp1(0,60,Bmptc); //
546 2 DrawBmp1(76,19,Bmpt4); //
547 2 delay1s(2);
548 2
549 2 // DrawBmp1(0,60,Bmptc); //
550 2 DrawBmp1(76,19,Bmpt5); //
551 2 delay1s(2);
552 2
553 2 // DrawBmp1(0,60,Bmptc); //
554 2 DrawBmp1(76,19,Bmpt6); //
555 2 delay1s(2);
556 2
557 2 // DrawBmp1(0,60,Bmptc); //
558 2 DrawBmp1(76,19,Bmpt7); //
559 2 }
560 1
561 1 }
562
563 void init_port(void)
564 {
565 1 //port initialized
566 1 IODIR1=0x00FF0000;
567 1 IODIR0=0x40610010;
568 1
569 1 PINSEL1=1<<24;
-
570 1 }
571
572
573 uchar screen,alarm_hour,alarm_min;
574
575 void Display( uchar data)
576
577 {uint datas;
578 1 uint times;
579 1 uint bak;
580 1
581 1
582 1
583 1 if(data==1)
584 1 { //clrscr(); //
585 2 ReadRTC();
ARM COMPILER V2.53, Lcd_Demo 02/08/06 16:25:34 PAGE 10
586 2 Ad_fun();
587 2
588 2 }
589 1
590 1 if(data==2) //2,3界面一样的!
591 1 { // clrscr(); //clr
592 2
593 2 Draw_word(0,32-8,0,16); //
594 2 Draw_word(1,48-8,0,16); //
595 2 Draw_word(2,64,0,16); //
596 2 Draw_word(3,80,0,16);
597 2
598 2 times=CTIME0;
599 2 datas=CTIME1;
600 2
601 2 bak=(times>>16)&0x1f;
602 2
603 2
604 2
605 2 Draw_a(alarm_hour/10,48-8,1,8);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -