找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5513|回复: 10
打印 上一主题 下一主题
收起左侧

C51单片机+LCD12864二维码图形和字体混合显示Proteus仿真+程序

  [复制链接]
跳转到指定楼层
楼主
程序通过输出直接Printf_lcd 打印就可以显示,附件包含有字模取模和图片取模方式!
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)


单片机源程序如下:
  1. /*
  2. 取模软件 液晶汉字字模提取
  3. // 汉字字模表                                                          //
  4. // 汉字库: 宋体16.dot 纵向取模下高位,数据排列:从左到右从上到下 输出大小设置128*64  然后输入字符串
  5. */
  6. #include<reg51.h> //包含头文件,一般情况不需要改动,头文件包含特殊功能寄存器的定义
  7. #include<stdio.h>
  8. #include "delay.h"
  9. #include "math.h"
  10. #include "string.h"
  11. #include "ascii_hz.h"
  12. #include "12864.h"

  13. #define uchar unsigned char
  14. #define uint unsigned int
  15. sbit JIESHOU=P3^7;
  16. sbit led=P1^4;

  17. unsigned char uart_rx_finish=0;  
  18. unsigned char uart_rx_cnt=0;
  19. unsigned char uart_rx_cnt_before=0;
  20. //char dis0[32];                   //串口数据显示
  21. unsigned char dis2[17];                   //串口数据显示
  22. unsigned char dis3[17];                   //去掉后缀0x0d 0x0a
  23. unsigned long time_20ms=0;           //定时器计数


  24. void Init_Timer0(void);                   //函数声明
  25. void SendStr(unsigned char *s,unsigned char length);
  26. void UART_Init(void);
  27. void SendByte(unsigned char dat);
  28. void puts_to_SerialPort(uchar *s);

  29. void main (void)
  30. {     
  31.     uchar i=0;
  32.         Init_Timer0();        //定时器0初始化
  33.         UART_Init();
  34.             
  35.         InitLcd();           //初始化液晶


  36.         puts_to_SerialPort("Receiving From 8051...\r\n");
  37.         lcd12864_write_one(0,0,"二维码测试系统");
  38.         lcd12864_write_one(2,0,"接收我二维码: ");

  39. //        InitLcd();           //初始化液晶
  40. //        tupiandisplay();
  41. //         DelayS(5);
  42.         while (1)         //主循环
  43.         {

  44.         
  45.                    if(JIESHOU==0){
  46.                       tupiandisplay();
  47.                         }
  48.                                 if(uart_rx_finish==1){        

  49.                            uart_rx_finish=0;

  50. //                            lcd12864_write_one(2,0,"                 ");//显示
  51. //                            lcd12864_write(4,0,dis2,"","");//显示


  52.                             uart_rx_cnt_before=uart_rx_cnt;
  53.                            uart_rx_cnt=0;
  54. //                           memset(dis2,' ',sizeof(dis2));
  55.                         }

  56. //                        if(tx_send==0){
  57. //                                  DelayMs(20);
  58. //                                 if(tx_send==0) {
  59. //                                    puts_to_SerialPort("PC Receiving From 8051...\r\n");
  60. //                                 while(!tx_send);
  61. //                                }
  62. //                        }

  63.         }

  64. }

  65. void Init_Timer0(void)
  66. {
  67.         TMOD |= 0x01;          //使用模式1,16位定时器,使用"|"符号可以在使用多个定时器时不受影响                     
  68.         TH0=(65536-20000)/256;                  //重新赋值 20ms
  69.         TL0=(65536-20000)%256;
  70.         EA=1;            //总中断打开
  71.         ET0=1;           //定时器中断打开
  72.         TR0=1;           //定时器开关打开

  73. }

  74. void Timer0_isr(void) interrupt 1
  75. {
  76.         TH0=(65536-20000)/256;                  //重新赋值 20ms
  77.         TL0=(65536-20000)%256;
  78.         
  79.         time_20ms++;
  80.         if(time_20ms%50==0)                  //1s时间发蓝牙
  81.         {
  82.                 led=~led;
  83.         }
  84. }


  85. void UART_Init(void)
  86. {
  87.     SCON  = 0x50;                        // SCON: 模式 1, 8-bit UART, 使能接收  
  88.     TMOD |= 0x20;               // TMOD: timer 1, mode 2, 8-bit 重装
  89.         PCON = 0x00;
  90.     TH1   = 0xFD;               // TH1:  重装值 9600 波特率 晶振 11.0592MHz
  91.         TL1 = TH1;  
  92.     TR1   = 1;                  // TR1:  timer 1 打开                        
  93.     EA    = 1;                  //打开总中断
  94.     ES    = 1;                  //打开串口中断
  95. }

  96. void SendByte(unsigned char dat)//串口发送单字节数据
  97. {
  98.         unsigned char time_out;
  99.         time_out=0x00;
  100.         SBUF = dat;                          //将数据放入SBUF中
  101.         while((!TI)&&(time_out<100))  //检测是否发送出去
  102.         {time_out++;DelayUs2x(10);}        //未发送出去 进行短暂延时
  103.         TI = 0;                                                //清除ti标志
  104. }

  105. void SendStr(unsigned char *s,unsigned char length)           //发送定长度字符串
  106. {
  107.         unsigned char NUM;
  108.         NUM=0x00;
  109.         while(NUM<length)        //发送长度对比
  110.         {
  111.                 SendByte(*s);  //放松单字节数据
  112.                 s++;                  //指针++
  113.                 NUM++;                  //下一个++
  114.            }
  115. }
  116. void puts_to_SerialPort(uchar *s)
  117. {
  118.          while(*s != '\0')
  119.         {
  120.                  SendByte(*s);
  121.                 s++;
  122.                 DelayMs(5);        
  123.         }
  124. }
  125. void UART_SER (void) interrupt 4         //串行中断服务程序
  126. {
  127.          uchar c;
  128.         if(RI)                        //判断是接收中断产生
  129.         {
  130.                 c  = SBUF;
  131.              if(c=='\n') {
  132.                 uart_rx_finish=1;  
  133.                 dis2[uart_rx_cnt]='\0';        
  134. ……………………

  135. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
二维码显示C51_V2图片.rar (8.66 MB, 下载次数: 223)


评分

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

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏5 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:15020 发表于 2019-6-28 09:38 | 只看该作者
此帖仅作者可见

使用道具 举报

板凳
ID:548850 发表于 2019-12-8 22:35 | 只看该作者
此帖仅作者可见

使用道具 举报

地板
ID:558751 发表于 2019-12-10 13:28 | 只看该作者
此帖仅作者可见

使用道具 举报

5#
ID:97678 发表于 2019-12-19 09:10 | 只看该作者
此帖仅作者可见

使用道具 举报

6#
ID:97678 发表于 2019-12-23 13:44 | 只看该作者
此帖仅作者可见

使用道具 举报

7#
ID:684590 发表于 2020-2-16 20:42 | 只看该作者
此帖仅作者可见

使用道具 举报

8#
ID:684590 发表于 2020-2-16 20:42 | 只看该作者
此帖仅作者可见

使用道具 举报

9#
ID:229211 发表于 2020-4-13 08:33 | 只看该作者
此帖仅作者可见

使用道具 举报

10#
ID:956087 发表于 2022-2-28 19:58 | 只看该作者
此帖仅作者可见

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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