4207|1

105

帖子

5566

TA的资源

纯净的硅(初级)

楼主
 

诺基亚5110LCD 驱动 字体放大 [复制链接]

5110LCD邮购回来了,经过一个晚上的研究算是可以点亮了,但是我用的16f84a,程序存储器不是非常大,但是我想显示大一些的字符,没办法只好自己研究了,经过好几个夜晚的调试修改终于可以正常显示了,今天过来显摆下。呵呵!

大家注意第一行的三个大数字其实和下面的小字符所使用的字库是一样大小的

本程序通过对字库点阵信息进行放大处理实现了小字库,大字符的显示节约宝贵的程序存储器




  1. #include
  2. //#include "zk"
  3. //---------------------------------------------
  4. #define uchar unsigned char
  5. #define uint unsigned int
  6. //---------------------------------------------
  7. #define LCD_SCE  RB2
  8. #define LCD_RST  RB3
  9. #define LCD_DC  RB4//0=command,1=data
  10. #define LCD_SDI  RB5
  11. #define LCD_SCL  RB6
  12. #define LCD_ON   RB0
  13. #define LCD_LED  RB7
  14. #define DATA  1
  15. #define CMD    0

  16. __CONFIG(XT&WDTDIS);
  17. //-----------------------------------------------
  18. void Delay_ms(uint t);
  19. void LCD_init(void);
  20. void LCD_send_data(uchar Data ,uchar CMD_DATA);
  21. void LCD_clear(void);
  22. void LCD_set_xy(uchar X,uchar Y);
  23. void LCD_send_char(uchar x,uchar y,uchar indx,uchar type);//0-8*16/1-16*16
  24. const unsigned char zk_asc[][16]=
  25. {
  26. // 0(0) 1(1) 2(2) 3(3) 4(4) 5(5) 6(6) 7(7) 8(8) 9(9)
  27. {0x00,0xF0,0x08,0x04,0x04,0x04,0x08,0xF0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F},//00
  28. {0x00,0x00,0x08,0x08,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00},//11
  29. {0x00,0x18,0x04,0x04,0x04,0x84,0x78,0x00,0x00,0x38,0x24,0x22,0x21,0x20,0x20,0x00},//22
  30. {0x00,0x18,0x84,0x84,0x84,0x84,0x78,0x00,0x00,0x18,0x20,0x20,0x20,0x20,0x1F,0x00},//33
  31. {0x00,0x00,0x00,0xC0,0x30,0x0C,0xFC,0x00,0x00,0x04,0x07,0x04,0x04,0x04,0x3F,0x04},//44
  32. {0x00,0xFC,0x44,0x44,0x44,0x44,0x84,0x00,0x00,0x18,0x20,0x20,0x20,0x20,0x1F,0x00},//55
  33. {0x00,0xF8,0x84,0x84,0x84,0x84,0x18,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00},//66
  34. {0x00,0x04,0x04,0x04,0xC4,0x34,0x0C,0x00,0x00,0x00,0x00,0x3E,0x01,0x00,0x00,0x00},//77
  35. {0x00,0x78,0x84,0x84,0x84,0x84,0x78,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00},//88
  36. {0x00,0xF8,0x04,0x04,0x04,0x04,0xF8,0x00,0x00,0x18,0x21,0x21,0x21,0x21,0x1F,0x00},//99

  37. {0x00,0xFC,0x80,0x40,0x20,0x10,0x08,0x04,0x00,0x3F,0x01,0x02,0x04,0x08,0x10,0x20},//K10
  38. {0x00,0xFC,0x80,0x80,0x80,0x80,0x80,0xFC,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x3F},//H11
  39. {0x00,0x40,0x40,0x40,0x40,0x40,0xC0,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x20,0x00},//z12
  40. {0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F},//m13
  41. {0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00},///14
  42. {0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20},//h15

  43. };
  44. //-----------------------------------------------
  45. void Delay_ms(uint t)
  46. {
  47. uint i;
  48. while(--t)
  49. {
  50.   for(i=0;i<500;i++){}
  51.   }
  52. }
  53. void LCD_init(void)
  54. {
  55. LCD_SCE=1;
  56. LCD_RST=1;
  57. Delay_ms(1);
  58. LCD_RST=0;
  59. Delay_ms(1);
  60. LCD_RST=1;
  61. LCD_send_data(0x21,CMD);   //扩展指令
  62. LCD_send_data(0xc5,CMD);   //设置偏压
  63. LCD_send_data(0x20,CMD);   //标准指令
  64. LCD_send_data(0x0c,CMD);   //标准显示模式
  65. }
  66. void LCD_clear(void)
  67. {
  68. uint i;
  69. LCD_set_xy(0,0);   //set the addr as 0x00
  70. for(i=0;i<504;i++)
  71. {
  72.    LCD_send_data(0x00,DATA);
  73. }
  74. }
  75. void LCD_set_xy(uchar X,uchar Y){
  76. if(Y<6 && X<84)
  77. {
  78.    LCD_send_data(0x80|X,CMD);
  79.    LCD_send_data(0x40|Y,CMD);
  80. }
  81. }
  82. void LCD_send_data(uchar Data ,uchar CMD_DATA)
  83. {
  84. uchar i;
  85. LCD_SCE=0;
  86. LCD_DC=CMD_DATA>0;
  87. if(CMD_DATA==3) Data<<=4;
  88. for(i=0;i<8;i++)
  89. {
  90.    LCD_SCL=0;
  91.    if(Data & 0x80)   //MSB first
  92.      LCD_SDI=1;
  93.     else
  94.      LCD_SDI=0;
  95.    LCD_SCL=1;
  96.    if(CMD_DATA>1)
  97.      {
  98.   LCD_SCL=0;
  99.   LCD_SCL=1;
  100.   i++;
  101.   }
  102.    Data<<=1;
  103. }
  104. //LCD_SCL=0;
  105. LCD_SCE=1;
  106. }
  107. void LCD_send_char(uchar x,uchar y,uchar indx,uchar type)
  108. {
  109. uchar i,j,k,l,m;
  110. if(type%2==0) {k=16;l=8;}
  111. if(type%2==1) {k=16;l=16;}
  112. j=0;
  113. LCD_set_xy(x,y);
  114. for(i=0;i
  115. {
  116.    if(j==l)
  117.     {
  118.      j=0;
  119.      y++;
  120.      if(type>1) y++;
  121.      LCD_set_xy(x,y);
  122.     }
  123.   if(type>1)
  124.      {
  125.      LCD_set_xy(x+j*2,y);
  126.      for(m=0;m<2;m++)
  127.       LCD_send_data(zk_asc[indx][i],3);
  128.      //LCD_send_data(zk_asc[indx][i],3);
  129.     LCD_set_xy(x+j*2,y+1);
  130.     for(m=0;m<2;m++)
  131.      LCD_send_data(zk_asc[indx][i],2);
  132.     //LCD_send_data(zk_asc[indx][i],2);
  133.     }
  134.     else
  135.      LCD_send_data(zk_asc[indx][i],DATA);
  136.    j++;
  137. }
  138. }
  139. //------------------------------------------------

  140. void main(void)
  141. {
  142. uchar i;
  143.    OPTION=0x81;
  144.    TRISA=0B00001110;
  145.    TRISB=0B00000000;
  146.    PORTA=0;
  147.    PORTB=0;
  148.    LCD_ON=1;
  149.    //LCD_LED=1;
  150. LCD_init();
  151. LCD_clear();
  152. LCD_send_char(24,4,10,0);
  153. LCD_send_char(32,4,13,0);
  154. LCD_send_char(40,4,14,0);
  155. LCD_send_char(48,4,15,0);
  156. // LCD_send_data(0x0d,CMD);   //反显
  157. while(1)
  158. {
  159. LCD_send_char(16,0,i/100,2);
  160. LCD_send_char(32,0,i/10%10,2);
  161. LCD_send_char(48,0,i%10,2);
  162. i++;
  163. Delay_ms(100);
  164. }
  165. }


复制代码


转自:http://pic16.com/bbs/dispbbs.asp?BoardID=8&ID=48275&replyID=&skin=1
此帖出自51单片机论坛

最新回复

你这个 液晶好多钱呀??????????????  详情 回复 发表于 2009-11-24 13:30
点赞 关注
 

回复
举报

101

帖子

0

TA的资源

纯净的硅(初级)

沙发
 
你这个 液晶好多钱呀??????????????
此帖出自51单片机论坛
 
 
 

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

查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/9 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表