找回密码
 立即注册

QQ登录

只需一步,快速开始

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

为什么这样写12864显示不正常,从第二行开始就错位

[复制链接]
跳转到指定楼层
楼主
ID:356940 发表于 2018-6-23 19:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit rs=P2^2;
sbit rw=P2^1;
sbit e=P2^0;
sbit cs1=P2^4;
sbit cs2=P2^3;
uchar i;
const char code table[] = {

/* GB2312 16x16点阵字库*/
/* 字串 我你它他她塔呀有  128x16  */
/* GB2312 16x16点阵字库*/
/* 的[0xB5C4]   16x16 */
/* GB2312 16x16点阵字库*/
/* 我[0xCED2]   16x16 */
0x20,0x24,0x24,0x24,0xFE,0x23,0x22,0x20,0xFF,0x20,0x22,0xAC,0x20,0x30,0x20,0x00,
0x00,0x08,0x48,0x84,0x7F,0x02,0x21,0x10,0x09,0x06,0x1A,0x61,0x80,0xE0,0x00,0x00,
/* GB2312 16x16点阵字库*/
/* 爱[0xB0AE]   16x16 */
0x40,0xB0,0x92,0x96,0x9A,0x92,0xF2,0x9E,0x92,0x91,0x99,0x95,0x91,0x50,0x30,0x00,
0x00,0x00,0x40,0x30,0x8C,0x83,0x46,0x2A,0x12,0x2A,0x26,0x42,0xC0,0x40,0x00,0x00,
/* GB2312 16x16点阵字库*/
/* 你[0xC4E3]   16x16 */
0x40,0x20,0xF8,0x07,0x40,0x20,0x18,0x0F,0x08,0xC8,0x08,0x08,0x28,0x18,0x00,0x00,
0x00,0x00,0xFF,0x00,0x00,0x08,0x04,0x43,0x80,0x7F,0x00,0x01,0x06,0x0C,0x00,0x00,

/* GB2312 16x16点阵字库*/
/* 你[0xC4E3]   16x16 */
0x40,0x20,0xF8,0x07,0x40,0x20,0x18,0x0F,0x08,0xC8,0x08,0x08,0x28,0x18,0x00,0x00,
0x00,0x00,0xFF,0x00,0x00,0x08,0x04,0x43,0x80,0x7F,0x00,0x01,0x06,0x0C,0x00,0x00,
/* GB2312 16x16点阵字库*/
/* 它[0xCBFC]   16x16 */
0x10,0x0C,0x04,0x04,0xE4,0x04,0x05,0x06,0x04,0x84,0xC4,0x04,0x04,0x14,0x0C,0x00,
0x00,0x00,0x00,0x00,0x3F,0x42,0x42,0x41,0x41,0x40,0x40,0x40,0x70,0x00,0x00,0x00,
/* GB2312 16x16点阵字库*/
/* 他[0xCBFB]   16x16 */
0x80,0x40,0x20,0xF8,0x87,0x80,0xF0,0x40,0x40,0xFF,0x20,0x20,0xF0,0x20,0x00,0x00,
0x00,0x00,0x00,0xFF,0x00,0x00,0x3F,0x40,0x40,0x5F,0x42,0x44,0x43,0x40,0x70,0x00,
/* GB2312 16x16点阵字库*/
/* 哦[0xC5B6]   16x16 */
0x00,0xFC,0x04,0x04,0xFE,0x24,0x24,0xFC,0x22,0x20,0xFF,0x22,0x24,0x30,0x20,0x00,
0x00,0x3F,0x10,0x10,0x1F,0x44,0x84,0x7F,0x42,0x22,0x11,0x1E,0x64,0x82,0xE0,0x00,
/* GB2312 16x16点阵字库*/
/* 奥[0xB0C2]   16x16 */
0x00,0x00,0x00,0xFC,0x44,0x56,0x45,0xFC,0x44,0x54,0x44,0xFE,0x04,0x00,0x00,0x00,
0x08,0x88,0x88,0x4B,0x48,0x29,0x18,0x0F,0x18,0x29,0x28,0x4B,0xC8,0x4C,0x08,0x00




};

const char code table1[] = {
0x00,0x10,0xF0,0x30,0xF0,0xC0,0x00,0x00,
0x00,0x00,0xC0,0x20,0xF0,0xF0,0x10,0x00,
0x80,0x80,0xFF,0x80,0x80,0x07,0x1E,0xF8,
0x18,0x06,0x01,0x80,0xFF,0xFF,0x80,0x00,  //32

0x00,0x00,0x10,0xF0,0xF0,0x10,0x10,0x10,
0x10,0x20,0x60,0xC0,0x80,0x00,0x00,0x00,
0x00,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,
0x80,0x40,0x60,0x3F,0x1F,0x02,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00    //256

};

const char code table2[] = {
0x00,0x10,0xF0,0x30,0xF0,0xC0,0x00,0x00,
0x00,0x00,0xC0,0x20,0xF0,0xF0,0x10,0x00,
0x80,0x80,0xFF,0x80,0x80,0x07,0x1E,0xF8,
0x18,0x06,0x01,0x80,0xFF,0xFF,0x80,0x00,  //32

0x00,0x00,0x10,0xF0,0xF0,0x10,0x10,0x10,
0x10,0x20,0x60,0xC0,0x80,0x00,0x00,0x00,
0x00,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,
0x80,0x40,0x60,0x3F,0x1F,0x02,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00    //256

};


const char code table3[] = {
0x00,0x10,0xF0,0x30,0xF0,0xC0,0x00,0x00,
0x00,0x00,0xC0,0x20,0xF0,0xF0,0x10,0x00,
0x80,0x80,0xFF,0x80,0x80,0x07,0x1E,0xF8,
0x18,0x06,0x01,0x80,0xFF,0xFF,0x80,0x00,  //32

0x00,0x00,0x10,0xF0,0xF0,0x10,0x10,0x10,
0x10,0x20,0x60,0xC0,0x80,0x00,0x00,0x00,
0x00,0x80,0x80,0xFF,0xFF,0x80,0x80,0x80,
0x80,0x40,0x60,0x3F,0x1F,0x02,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00,

0x00,0x00,0x00,0x80,0xC0,0x20,0x10,0x10,
0x10,0x10,0x20,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x3F,0x7F,0x60,0xC0,0x80,
0x80,0x80,0x40,0x41,0x20,0x00,0x00,0x00    //256

};
void delay(uint x)
{
  uchar i;
  while(x--)
  for(i=0;i<110;i++);
}
void com(uchar com)
{
  rs=0;
  rw=0;
  P0=com;
  delay(5);
  e=1;
  delay(5);
  e=0;
}

void date(uchar date)
{
  rs=1;
  rw=0;
  P0=date;
  delay(5);
  e=1;
  delay(5);
  e=0;
}

void chushihua()
{
  com(0x30);                 //初始化
  delay(5);
  com(0x0c);                                 //显示开关设置 0000 1DCB
  delay(5);                  //D=1整体显示开 C=1游标显示开 B=1游标位置显示反白开
  com(0x01);                 //清屏指令
  delay(5);

}

void weizhi(uchar hang,uchar lie)
{  hang=hang & 0x07;
   hang=hang | 0xb8;   //1011 1xxx 上半部分行
   com(hang);
   hang=hang & 0x3f;
   lie = lie | 0x40;   //01xx xxxx 上半部分列
   com(lie);
}
/*显示1*/
void disp1()
{

  uchar j,k;
  uchar h,l;
  h=0;l=0;
  j=0;k=16;
  while(l<49)
  {
   cs1=0;
   cs2=1;
  weizhi(h,l);
  for(i=j;i<k;i++)
  date(table[i]);


  weizhi(h+1,l);
  for(i=k;i<k+16;i++)
  date(table[i]);


  j=j+32;
  k=k+32;
  l=l+16;
  }


  l=0;
  j=128;k=144;
  while(l<49)
  {

   cs1=1;
   cs2=0;
  weizhi(h,l);
  for(i=j;i<k;i++)
  date(table[i]);
                                    


  weizhi(h+1,l);
  for(i=k;i<k+16;i++)
  date(table[i]);




  j=j+32;
  k=k+32;
  l=l+16;
  }




}


/*显示2*/
void disp2()
{

  uchar j,k;
  uchar h,l;
  h=0;l=0;
  j=0;k=16;
  while(l<49)
  {
   cs1=0;
   cs2=1;
  weizhi(h+2,l);
  for(i=j;i<k;i++)
  date(table[i]);


  weizhi(h+3,l);
  for(i=k;i<k+16;i++)
  date(table[i]);


  j=j+32;
  k=k+32;
  l=l+16;
  }


  l=0;
  j=128;k=144;
  while(l<49)
  {
   cs1=1;
   cs2=0;
  weizhi(h+2,l);
  for(i=j;i<k;i++)
  date(table[i]);
                                    


  weizhi(h+3,l);
  for(i=k;i<k+16;i++)
  date(table[i]);




  j=j+32;
  k=k+32;
  l=l+16;
  }




}

/*显示3*/
void disp3()
{

  uchar j,k;
  uchar h,l;
  h=0;l=0;
  j=0;k=16;
  while(l<49)
  {
   cs1=0;
   cs2=1;
  weizhi(h+4,l);
  for(i=j;i<k;i++)
  date(table[i]);


  weizhi(h+5,l);
  for(i=k;i<k+16;i++)
  date(table[i]);


  j=j+32;
  k=k+32;
  l=l+16;
  }


  l=0;
  j=128;k=144;
  while(l<49)
  {
   cs1=1;
   cs2=0;
  weizhi(h+4,l);
  for(i=j;i<k;i++)
  date(table[i]);
                                    


  weizhi(h+5,l);
  for(i=k;i<k+16;i++)
  date(table[i]);




  j=j+32;
  k=k+32;
  l=l+16;
  }




}


/*显示4*/
void disp4()
{

  uchar j,k;
  uchar h,l;
  h=0;l=0;
  j=0;k=16;
  while(l<49)
  {
   cs1=0;
   cs2=1;
  weizhi(h+6,l);
  for(i=j;i<k;i++)
  date(table[i]);


  weizhi(h+7,l);
  for(i=k;i<k+16;i++)
  date(table[i]);


  j=j+32;
  k=k+32;
  l=l+16;
  }


  l=0;
  j=128;k=144;
  while(l<49)
  {
   cs1=1;
   cs2=0;
  weizhi(h+6,l);
  for(i=j;i<k;i++)
  date(table[i]);
                                    


  weizhi(h+7,l);
  for(i=k;i<k+16;i++)
  date(table[i]);




  j=j+32;
  k=k+32;
  l=l+16;
  }




}

void main()
{
           chushihua();
    disp1();
        delay(5);
        chushihua();
        disp2();
        delay(5);
        chushihua();
        disp3();
        delay(5);
        chushihua();
        disp4();
        delay(5);
    while(1);
}


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

使用道具 举报

沙发
ID:356940 发表于 2018-6-24 09:28 | 只看该作者
解决了解决了,把uchar改成int 就行了,因为uchar只能存储128单位,不够,会溢出,所以用int就可以了
回复

使用道具 举报

板凳
ID:356940 发表于 2018-6-24 09:30 | 只看该作者
解决了,将uchar改成int 就可以显示全屏幕了
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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