找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1983|回复: 0
收起左侧

Nokia5110显示字符或汉字源程序+电路图

[复制链接]
ID:586669 发表于 2019-7-22 19:00 | 显示全部楼层 |阅读模式
Nokia5110驱动程序,篇幅限制,只截取了一段,全部资料在压缩包
0.png
  1. #include <AT89X52.H>
  2. #include "LCD5510_V3.H"
  3. #include "IMG_code.c"


  4. unsigned char code *str1 = {"Nokia 5510 Test, Haha^_^ I am so glad to see you agian! Do you think so?"};
  5. unsigned char code *str2 = {"I Love You AVR"};


  6. /*--------------------------------------------------------------*/
  7. //延时50000+0us 函数定义
  8. void delay50ms(void)
  9. {
  10.     unsigned char i,j,k;
  11.     for(i=167;i>0;i--)
  12.     for(j=60;j>0;j--)
  13.     for(k=1;k>0;k--);
  14. }

  15. //延时200000+0us 函数定义
  16. void delay200ms(void)
  17. {
  18.     unsigned char i,j,k;
  19.     for(i=201;i>0;i--)
  20.     for(j=32;j>0;j--)
  21.     for(k=14;k>0;k--);
  22. }


  23. //延时1000000+1us 函数定义
  24. void delay1s(void)
  25. {
  26.     unsigned char i,j,k;
  27.     for(i=167;i>0;i--)
  28.     for(j=171;j>0;j--)
  29.     for(k=16;k>0;k--);
  30. }


  31. /*--------------------------------------------------------------*/
  32. //主函数
  33. void main(void)
  34. {
  35.         unsigned int i, j, k;
  36.         unsigned char LCD_contrast = 0xc8;        //此值对比度合适
  37.         unsigned char *ptr;

  38.         LCD5510_Init();

  39.         ptr = str1;
  40.         i = 0;
  41.         while(i++ < 641-84)
  42.         {
  43.                 LCD_prints(0, 5, ptr++);
  44.                 LCD_roll_picture(0, 0, 40, &img1[i*5]);// 40/8 = 5
  45.                 if(!(i%72)) ptr -= 72;
  46.                 LCD_clr_row(5);
  47.         }

  48.         i = 0;
  49.         while(*str1)
  50.         {
  51.                 LCD_prints(0, 0, str1++);
  52.                 delay200ms(); i++;
  53.                 LCD_clr_row(0);
  54.         }
  55.         str1 -= i;
  56.         LCD_printsl(0, 0, str1);
  57.         delay1s();
  58.         
  59.         LCD_clr_scr();                //清屏
  60.         delay1s();
  61.         LCD_picture(pic);
  62.         delay1s();        delay1s();
  63.         
  64.         LCD_clr_scr();                //清屏
  65.         delay1s();
  66.         LCD_pos_picture(0, 0, 72, 14, pic1);        
  67.         delay1s();        
  68.         LCD_pos_picture(0, 2, 72, 28, pic2);
  69.         delay1s(); delay1s();
  70.         LCD_clr_scr();                //清屏
  71.         LCD_showsh(0, 0, "我心★永恒");
  72.         delay1s();
  73.         LCD_showsh(0, 1, "永恒★我心");
  74.         delay1s();
  75.         LCD_showsh(0, 2, "永恒之心★");
  76.         delay1s(); delay1s();
  77.         
  78.         
  79.         
  80.         LCD_clr_scr();                //清屏
  81.         for(i = 0; i < 14; i++) {LCD_printc(i, 2, str2[i]); delay200ms();}
  82.         LCD_printn(2, 3, 13140, 5);
  83.         delay1s();
  84.         LCD_prints(0, 4, ">--(*^_^*)--<");
  85.         delay1s();


  86.         LCD_prints(0, 0, "Blank Test ");
  87.         delay1s();
  88.         LCD_show_blank;                //空白测试
  89.         delay1s();
  90.         LCD_prints(0, 0, "Normal Test");
  91.         LCD_show_normal;        //恢复正常
  92.         delay1s();
  93.         LCD_prints(0, 0, "Black Test ");
  94.         delay1s();
  95.         LCD_show_black;                //全黑检测坏点
  96.         delay1s();
  97.         LCD_show_normal;        //恢复正常
  98.         delay1s();
  99.         LCD_prints(0, 0, "Inverse Test");
  100.         LCD_show_inverse;        //反色
  101.         delay1s();
  102.         LCD_prints(0, 0, "Normal again");
  103.         LCD_show_normal;        //恢复正常
  104.         delay1s();
  105.         LCD_clr_scr();                //清屏
  106.         delay1s();
  107.         
  108.         
  109.         i = 0; j = 0; k =0;
  110.         LCD_prints(0, 5, "ASCII Code:");
  111.         while(k++ < 100)        //ASCII字符测试
  112.         {
  113.                 LCD_printc(i, j, k + 32);
  114.                 delay50ms();
  115.                 i++; if(i == 14) {i = 0; j++;}
  116.                 if(j == 5) j = 0;
  117.                 LCD_printn(11, 5, k + 32, 3);                 
  118.         }
  119.         delay1s();
  120.         
  121.         
  122.         LCD_clr_scr();                        //清屏
  123.         LCD_prints(2, 0, "Nokia 5510");
  124.         LCD_prints(2, 2, "Alexi2008");
  125.         LCD_prints(0, 4, "LCD_Contrast:");
  126.         while(1)                                //对比度软件调节
  127.         {
  128.                 for(i = 0; i < 10; i++)
  129.                 {
  130.                         LCD_contrast++;
  131.                         LCD_write_cmd(0x21);//工作模式, 水平寻址, 扩展指令
  132.                         LCD_write_cmd(LCD_contrast);
  133.                         LCD_write_cmd(0x20);//工作模式, 水平寻址, 常规指令
  134.                         LCD_printc(13, 4, 129);
  135.                         LCD_printn(5, 5, LCD_contrast, 3);
  136.                         delay200ms();
  137.                 }
  138.                 for(i = 0; i < 20; i++)
  139.                 {
  140.                         LCD_contrast--;
  141.                         LCD_write_cmd(0x21);//工作模式, 水平寻址, 扩展指令
  142.                         LCD_write_cmd(LCD_contrast);
  143.                         LCD_write_cmd(0x20);//工作模式, 水平寻址, 常规指令
  144.                         LCD_printc(13, 4, 130);
  145.                         LCD_printn(5, 5, LCD_contrast, 3);
  146.                         delay200ms();
  147.                 }
  148.                 for(i = 0; i < 10; i++)
  149.                 {
  150.                         LCD_contrast++;
  151.                         LCD_write_cmd(0x21);//工作模式, 水平寻址, 扩展指令
  152.                         LCD_write_cmd(LCD_contrast);
  153.                         LCD_write_cmd(0x20);//工作模式, 水平寻址, 常规指令
  154.                         LCD_printc(13, 4, 129);
  155.                         LCD_printn(5, 5, LCD_contrast, 3);
  156.                         delay200ms();
  157.                 }
  158.         }
  159. }

复制代码
全部资料51hei下载地址:
Nokia5110.7z (2.79 MB, 下载次数: 30)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表