自制单片机之七……LCD12864的驱动之源代码

发布者:晴天7777最新更新时间:2016-09-05 来源: eefocus关键字:单片机  LCD12864  驱动 手机看文章 扫描二维码
随时随地手机看文章
今天将LCD12864的源代码发上来。


//LCD12864
//**********************************************************
//连线表: CPU=89C51    SysClock=12MHz                     *
//RS=P1.0   R/W=P1.1    E=P1.2    CS1=P1.3    CS2=P1.4     *
//DB0-DB7=P0.0-P0.7       /Reset=InBoard                   *
//********************************************************** 
#include
#include
#include
#include  
#include
#define uchar unsigned char
#define uint unsigned int
/********************引脚定义********************/ 
#define DataPort P3     //LCD128*64 I/O 信号管脚
sbit    RS =P2^0;      //数据指令
sbit    RW =P2^1;      //读写
sbit    E   =P2^2;      //使能
sbit    CSL =P2^3;      //左片选
sbit    CSR =P2^4;      //右片选 
uchar Page;             //页 地址
uchar Col;              //列 地址 
uchar code BMP1[];      //一幅图
uchar code HZK_12[];    //12×12阵点字模
uchar code ASC_5x7[];   //5×7阵点字模
uchar str[4];

/********************函数定义*******************/
void BusyL(void);          //左屏检测忙
void BusyR(void);          //右屏检测忙
void CheckBusy(void);      //读取忙信号
void Delay(uint MS);       //延时
void Locatexy(void);       //将屏幕横向0-12纵向0-7转换成左、右屏的的X、Y
void WriteCommandL( uchar CommandByte );    //向左屏写入指令
void WriteCommandR( uchar CommandByte );    //向右屏写入指令
uchar ReadData( void );       //读数据
void WriteData( uchar DataByte );    //写数据
void LcmClear( void );       //清屏
void LcmInit( void );        //初始化
void LcmPutBMP( uchar *puts );      //显示一幅图
void LcmReverseBMP( void );         //将整屏反显
void LcmPutHZ_12( uchar x,uchar y,uchar HZcode ); //在屏幕上任意点显示一个12×12汉字
uchar * uchartostr(unsigned char unm);            //将值转成字符串
void LcmPutAsc( uchar asc );     //显示一个5×7的ASC字符
void LcmPutstr( uchar row,uchar y,uchar * str );       //在设定位置显示字符串
void LcmPutpoint( uchar ro,uchar lie,uchar colour );   //在设定位置显示一个点

/***************************/
/*检查Busy                 */
/***************************/
void BusyL(void)
{
        CSL= 1;
        CSR= 0;
        CheckBusy();

void BusyR(void)
{
        CSL= 0;
        CSR= 1;
        CheckBusy();

void CheckBusy(void)
{
        RS = 0;         //指令
        RW = 1;
DataPort= 0xFF;      //输出0xff以便读取正确
        E = 1;
        _nop_();
        while(0); //DataPort & 0x80);    //Status Read Bit7 = BUSY 这地方有点问题,用了while(//DataPort & 0x80)后就一直读不到0了,陷入死循环。当用while(0) 时反而能正常工作,不知道有没有人能解释       
        E = 0;
        _nop_();

/********************************************************/
/*根据设定的坐标数据,定位LCM上的下一个操作单元位置     */
/********************************************************/
void Locatexy(void)
{
        uchar x,y;
        switch (Col&0xc0)       /* col.and.0xC0        */
        {                       /*条件分支执行          */
                case 0:         {BusyL();break;}/*左区 */
                case 0x40:      {BusyR();break;}/*右区 */
        }
        x = Col&0x3F|0x40;      /* col.and.0x3f.or.Set Y Address*/
        y = Page&0x07|0xB8;     /* row.and.0x07.or.set Page     */
        CheckBusy();                /* waitting for enable */
        RS = 0;                 //指令
        RW = 0;                 //写
        DataPort = y;                 //设置页面地址
        E = 1;
        _nop_();
        E = 0;
        _nop_();
        CheckBusy();                /* waitting for enable */
        RS = 0;
        RW = 0;
        DataPort = x;                 //设置列地址
        E = 1;
        _nop_();
        E = 0;
        _nop_();

/***************************/
/*写指令                   */
/***************************/
void WriteCommandL( uchar CommandByte )
{
        BusyL();
        DataPort = CommandByte;
        RS = 0;         //指令
        RW = 0;
        E = 1;
        _nop_();
        E = 0;
        _nop_();

void WriteCommandR( uchar CommandByte )
{
        BusyR();
        DataPort = CommandByte;
        RS = 0;         //指令
        RW = 0;
        E = 1;
        _nop_();
        E = 0;
        _nop_();

/***************************/
/*读数据                   */
/***************************/
uchar ReadData( void )
{
        uchar DataByte;
        Locatexy();     /*坐标定位,返回时保留分区状态不变      */
        RS = 1;         /*数据输出*/
        RW = 1;         /*读入 */
        DataPort = 0xFF;              //输出0xff以便读取正确
        E = 1;         /*读入到LCM*/
        _nop_();
        DataByte = DataPort; /*数据读出到数据口P1 */
        E = 0;
        _nop_();
        return DataByte;

/***************************/
/*写数据                   */
/***************************/
void WriteData( uchar DataByte )
{
        Locatexy();     /*坐标定位,返回时保留分区状态不变      */
        RS = 1;         /*数据输出*/
        RW = 0;         /*写输出 */
        DataPort = DataByte; /*数据输出到数据口 */
        E = 1;         /*写入到LCM*/
        _nop_();
        E = 0;
        _nop_();

void LcmClear( void )
{
        Page = 0;
        Col = 0;
        for(Page=0;Page<8;Page++)
                for(Col=0;Col<128;Col++)
                        WriteData(0);

void LcmInit( void )
{
    Delay(200);     //等待复位
        WriteCommandL(0x3f);    //开显示
        WriteCommandR(0x3f);
        
        WriteCommandL(0xc0);    //设置起始地址=0
        WriteCommandR(0xc0); 
        WriteCommandL(0x3f);    //开显示
        WriteCommandR(0x3f); 
        LcmClear();
        Col = 0;
        Page= 0;
        Locatexy();
}

void LcmPutBMP( uchar *puts )
{
        uint X=0;
        Page = 0;
        Col = 0;
        for(Page=0;Page<8;Page++)
        {
                for(Col=0;Col<128;Col++)
                {
                        WriteData( puts[X] );
                        X++;
                }
        }

void LcmReverseBMP( void )
{
        uchar temp;
        Page = 0;
        Col = 0;
        for(Page=0;Page<8;Page++)
        {
                for(Col=0;Col<128;Col++)
                {
                        temp = ReadData();      //空读一次
                        temp = ReadData();
                        temp = ~temp;
                        WriteData(temp);
                }
        }

void LcmPutHZ_12( uchar x,uchar y,uchar HZcode )
{      
   uchar offset,Rd,Wt,m,tmp,i;
   uint n;
   if(x<117&y<53) //x为横向起始点数0-117,超过117就显示不全一个汉字了。y同理。
    {
    Page=(y & 0x38)>>3; //将竖向的点阵数y转换成页数
   Col=x;                //横向的X就是LCD的列数。
      n = 0x18*HZcode;   //一个汉字24字节(18H),HZcode为字库序号。n就是要显示汉字的起始地址
   offset=y&0x07;    //将显示该页的竖向偏移量。
   if(offset<5)          //如果偏移量小于5,那么在竖向用两个页的范围就可显示出汉字了。
   {

             for(i=12;i>0;i--)
              { 
                 Rd=ReadData();
       Rd=ReadData();            //读出LCD该Page、Col位置的上半个数据。
       m=HZK_12[n];              //读出汉字模第n的数据。
             Wt=Rd&(0xff>>(8-offset))|(m<                  WriteData(Wt);     //再将Wt写回LCD
         Page++;    //页位置移到下半个汉字位置
         n++;
         tmp=m;    //将取得的上半个字模数据交给tmp
         m=HZK_12[n];   //取下半个字模数据
         Rd=ReadData(); //读LCD下半个字模数据
       Rd=ReadData();
         Wt=tmp>>(8-offset)|(m<                  WriteData(Wt);//再写回LCD
                 Col++;//列数增加一
                 Page--;//将页数返回上半个汉字位置。
       n++;
      }
   }
   else      //如果偏移量大于或等于5,竖向就要用3个页的范围来显示一个汉字了。
   {
       for(i=12;i>0;i--)

                 {
                   Rd=ReadData();
       Rd=ReadData();      //读取LCD上汉字上部位置的原来数据。
           m=HZK_12[n];   //读取汉字模数据
               Wt=Rd&(0xff>>(8-offset))|(m<                    WriteData(Wt);   //写回
           Page++;   //到下一页即汉字中部位置
           n++;
           tmp=m;   //上半个字模交给tmp
           m=HZK_12[n];   //读取下半个字模
       Wt=tmp>>(8-offset)|(m<        WriteData(Wt);   //写回
       Page++;   //到下一页即汉字下部位置
       n++;
       Rd=ReadData();
       Rd=ReadData();   //读取LCD上汉字下部位置的原来数据
       Wt=m>>(8-offset)|(Rd&(0xff<<(offset-4))); //嵌入
        WriteData(Wt);   //写回
       Page=Page-2;//恢复位置
       Col++; //修正下一个汉字的起始位置
       }
        }
   }
}

 

uchar * uchartostr(uchar unm)
{
uchar x00,xx,x0,x,n;
x00=unm/100;
xx=unm%100;
x0=xx/10;
x=xx%10;
n=0;
if(x00!=0)
{ str[n]=x00+48; //值加48即为字符
    n++;
}
if(!(x00==0&x0==0))
{ str[n]=x0+48;
    n++;
}
str[n]=x+48;
n++;
str[n]='\0';
   return str;

}
void LcmPutAsc( uchar asc )
{
        uchar j;
        uint x;
        x = 5*(asc-32);
            for(j=0;j<5;j++)
                {
                        WriteData(ASC_5x7[x]);
                        x++;
                        Col++;
                }
            WriteData(0x00); 
            Col++;

}

void LcmPutstr( uchar row,uchar y,uchar * str )
{ unsigned char * x;
   x=str;
Page=row;
Col=y;
while(*x!='\0')
{ LcmPutAsc( *x );
    x++;
}

}


void LcmPutpoint( uchar ro,uchar lie,uchar colour )   //画点函数
{
    if((ro<64)&(lie<128))
   {
        uchar modbyte,outByte;
        uchar offsetbit;
    Col=lie;                  //列等于lie
        Page=(ro & 0x38)>>3;     //页等于行数row与00111000B再右移3位
        offsetbit=ro&0x07;       //偏移量为行数与00000111
        modbyte=1;
    modbyte<<= offsetbit;     //输出位的模00000001左移offsetbit位
    outByte=ReadData();
    outByte=ReadData();
    if(colour==0)
    {
          modbyte=~modbyte;
      outByte=modbyte&outByte;     //输出位不影响其它位
    }
    else outByte=modbyte|ReadData();     //输出位不影响其它位
        WriteData(outByte);
   }
}


void Delay(uint MS)
{
        uchar us,usn;
        while(MS!=0)
        {
                usn = 2;        //for 12M
                while(usn!=0)
                {
                        us=0xf6;
                        while (us!=0){us--;};
                        usn--;
                }
                MS--;
        }

void Main( void )
{
        uchar x,i;
        LcmInit();
        LcmClear();
        while(1)
        {
          LcmClear();
              LcmPutBMP(BMP1);
              Delay(3000);
      LcmClear();
              //LcmReverseBMP();
              Delay(1000);
          //LcmClear();
      x=0;
      for(i=0;i<8;i++)
      {
                LcmPutHZ_12(x,i*7,i);
      x=x+16;
      }
      LcmPutstr( 4,2,"Hello" );
      LcmPutstr( 6,35,"World!" );
              Delay(5000);
       
        }
}

 

unsigned char code BMP1[]={             //字节倒序
//-- 调入了一幅图像:
//宽度x高度=1264

      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x80,0xE0,0xF0,0xFC,0xFE,0xFE,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0x9F,0xCF,0xDF,0x9F,
      0x9E,0x3E,0xFF,0xFE,0xFE,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFA,0xFC,0xF8,0xE0,0xC0,0x80,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x80,0xC0,0xF0,0xF8,0xFC,0xFE,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xDF,0xEF,
      0xCF,0xDF,0x9F,0x0F,0x1F,0x7F,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFE,0xFC,0xF0,0xC0,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0xC0,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x10,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0xFB,0xFF,
      0xFF,0xFF,0xFF,0xFE,0xF8,0xFE,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0x3F,
      0x37,0x37,0x37,0x27,0x63,0x43,0x03,0x03,
      0x03,0x03,0x03,0x07,0x67,0x27,0x0F,0x0F,
      0x1F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0x80,0x80,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x10,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x7F,
      0x7F,0x7F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
      0x3F,0x3F,0x3F,0x3F,0x3F,0x7F,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x80,0xE0,0xFC,0xFE,0xFE,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xDF,0x0F,0x07,0x07,0x03,
      0x03,0x03,0x03,0x02,0xC0,0xAC,0xBF,0xA0,
      0x80,0x00,0x00,0x00,0x02,0x02,0x06,0x06,
      0x04,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xF0,0xE0,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x3F,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xBF,0x3F,0x3F,0x3D,
      0x7D,0xF8,0xF0,0xF0,0xC0,0x00,0x00,0x00,
      0x08,0x8C,0xFC,0xFE,0xEE,0xE6,0xC2,0xC0,
      0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
      0x1F,0x1F,0x87,0x0D,0x7D,0x70,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,
      0xF0,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xE0,0x00,
      0x00,0x00,0x02,0xE7,0xE7,0xE7,0xE7,0xC3,
      0xC3,0xC1,0x82,0x87,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0xE3,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFC,0xF8,0xE0,0xC0,0x80,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
      0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xDF,0x1F,0x1F,0x1F,0x1B,0xF9,
      0xF9,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,
      0x00,0x01,0x01,0x03,0x03,0x83,0x83,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x01,0x03,0x00,0x00,0x00,0x00,
      0xF8,0xFC,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFE,0xFC,0xF8,0xFE,0x8F,0x8F,0x0E,0x06,
      0x0E,0x0C,0x0C,0x00,0x01,0x00,0x00,0x80,
      0xC0,0xF0,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,
      0xF8,0xF0,0xF0,0xE0,0x00,0x00,0x00,0x00,
      0x00,0x03,0x07,0x0F,0x1F,0x1F,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFE,0xFC,0xFC,0xFE,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xDF,0xCF,0xDE,
      0xD4,0xC2,0x82,0x80,0x80,0x83,0xC7,0xC7,
      0x0F,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
      0xC0,0xF4,0xFC,0xFC,0xFC,0xFC,0xF8,0xF8,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0x7F,0x3F,0x1F,0x1F,0xDF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x1E,
      0x1E,0x0E,0x0C,0x04,0x02,0x06,0x1F,0xFF,
      0xFF,0xCF,0x0F,0x0F,0x0F,0x1F,0x3F,0x7F,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0x7F,0x1F,0x1F,0x03,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x80,0xC1,0xE7,
      0xEF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFB,0xFB,
      0xF3,0xF9,0x71,0x31,0x00,0x00,0x00,0x01,
      0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xFF,
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
      0x03,0x07,0x0F,0x1F,0x1F,0x3F,0x3F,0x1F,
      0x1F,0x1F,0x0F,0x4F,0x67,0x27,0x33,0x31,
      0x38,0x38,0x78,0x7C,0x7E,0x7F,0x7F,0x7F,
      0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x7F,0x7F,
      0x7F,0x7F,0x7D,0x79,0x79,0x70,0x70,0x70,
      0x70,0x70,0x70,0x78,0x78,0x3C,0x5E,0x6F,
      0x3F,0x77,0x0F,0x0C,0x7C,0x78,0x78,0x40,
      0x00,0x01,0x01,0x03,0x07,0x0F,0x1F,0x1F,
      0x1F,0x1F,0x1F,0x1F,0x0F,0x07,0x03,0x00,
      0x00,0x00,0x00,0x40,0x60,0x70,0x70,0x78,
      0x78,0x7C,0x7E,0x7F,0x7F,0x7F,0x7F,0x7F,
      0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,
      0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7C,
      0x7C,0x7C,0x78,0x78,0x70,0x58,0x00,0x00,
      0x40,0x70,0x78,0x7C,0x7F,0x7F,0x7F,0x7F,
      0x7F,0x7F,0x07,0x07,0x0F,0x1F,0x3F,0x7F
};

//ASCII字符
unsigned char code ASC_5x7[]={
0x00, 0x00, 0x00, 0x00, 0x00, //
0x00, 0x00, 0x4F, 0x00, 0x00, //
0x00, 0x07, 0x00, 0x07, 0x00, //
0x14, 0x7F, 0x14, 0x7F, 0x14, //
0x24, 0x2A, 0x7F, 0x2A, 0x12, //
0x23, 0x13, 0x08, 0x64, 0x62, //
0x36, 0x49, 0x55, 0x22, 0x50, //
0x00, 0x05, 0x03, 0x00, 0x00, //
0x00, 0x1C, 0x22, 0x41, 0x00, //
0x00, 0x41, 0x22, 0x1C, 0x00, //
0x14, 0x08, 0x3E, 0x08, 0x14, //
0x08, 0x08, 0x3E, 0x08, 0x08, //
0x00, 0x50, 0x30, 0x00, 0x00, //
0x08, 0x08, 0x08, 0x08, 0x00, //
0x00, 0x60, 0x60, 0x00, 0x00, //
0x20, 0x10, 0x08, 0x04, 0x02, //
0x3E, 0x51, 0x49, 0x45, 0x3E, //
0x00, 0x42, 0x7F, 0x40, 0x00, //
0x42, 0x61, 0x51, 0x49, 0x46, //
0x21, 0x41, 0x45, 0x4B, 0x31, //
0x18, 0x14, 0x12, 0x7F, 0x10, //
0x27, 0x45, 0x45, 0x45, 0x39, //
0x3C, 0x4A, 0x49, 0x49, 0x30, //
0x01, 0x01, 0x79, 0x05, 0x03, //
0x36, 0x49, 0x49, 0x49, 0x36, //
0x06, 0x49, 0x49, 0x29, 0x1E, //
0x00, 0x36, 0x36, 0x00, 0x00, //
0x00, 0x56, 0x36, 0x00, 0x00, //
0x08, 0x14, 0x22, 0x41, 0x00, //
0x14, 0x14, 0x14, 0x14, 0x14, //
0x00, 0x41, 0x22, 0x14, 0x08, //
0x02, 0x01, 0x51, 0x09, 0x06, //
0x32, 0x49, 0x79, 0x41, 0x3E, //
0x7E, 0x11, 0x11, 0x11, 0x7E, //
0x41, 0x7F, 0x49, 0x49, 0x36, //
0x3E, 0x41, 0x41, 0x41, 0x22, //
0x41, 0x7F, 0x41, 0x41, 0x3E, //
0x7F, 0x49, 0x49, 0x49, 0x49, //
0x7F, 0x09, 0x09, 0x09, 0x01, //
0x3E, 0x41, 0x41, 0x49, 0x7A, //
0x7F, 0x08, 0x08, 0x08, 0x7F, //
0x00, 0x41, 0x7F, 0x41, 0x00, //
0x20, 0x40, 0x41, 0x3F, 0x01, //
0x7F, 0x08, 0x14, 0x22, 0x41, //
0x7F, 0x40, 0x40, 0x40, 0x40, //
0x7F, 0x02, 0x0C, 0x02, 0x7F, //
0x7F, 0x06, 0x08, 0x30, 0x7F, //
0x3E, 0x41, 0x41, 0x41, 0x3E, //
0x7F, 0x09, 0x09, 0x09, 0x06, //
0x3E, 0x41, 0x51, 0x21, 0x5E, //
0x7F, 0x09, 0x19, 0x29, 0x46, //
0x26, 0x49, 0x49, 0x49, 0x32, //
0x01, 0x01, 0x7F, 0x01, 0x01, //
0x3F, 0x40, 0x40, 0x40, 0x3F, //
0x1F, 0x20, 0x40, 0x20, 0x1F, //
0x7F, 0x20, 0x18, 0x20, 0x7F, //
0x63, 0x14, 0x08, 0x14, 0x63, //
0x07, 0x08, 0x70, 0x08, 0x07, //
0x61, 0x51, 0x49, 0x45, 0x43, //
0x00, 0x7F, 0x41, 0x41, 0x00, //
0x02, 0x04, 0x08, 0x10, 0x20, //
0x00, 0x41, 0x41, 0x7F, 0x00, //
0x04, 0x02, 0x01, 0x02, 0x04, //
0x40, 0x40, 0x00, 0x40, 0x40, //
0x01, 0x02, 0x04, 0x00, 0x00, //
0x20, 0x54, 0x54, 0x54, 0x78, //
0x7F, 0x48, 0x44, 0x44, 0x38, //
0x38, 0x44, 0x44, 0x44, 0x28, //
0x38, 0x44, 0x44, 0x48, 0x7F, //
0x38, 0x54, 0x54, 0x54, 0x18, //
0x00, 0x08, 0x7E, 0x09, 0x02, //
0x0C, 0x52, 0x52, 0x4C, 0x3E, //
0x7F, 0x08, 0x04, 0x04, 0x78, //
0x00, 0x44, 0x7D, 0x40, 0x00, //
0x20, 0x40, 0x44, 0x3D, 0x00, //
0x00, 0x7F, 0x10, 0x28, 0x44, //
0x00, 0x41, 0x7F, 0x40, 0x00, //
0x7C, 0x04, 0x78, 0x04, 0x78, //
0x7C, 0x08, 0x04, 0x04, 0x78, //
0x38, 0x44, 0x44, 0x44, 0x38, //
0x7E, 0x0C, 0x12, 0x12, 0x0C, //
0x0C, 0x12, 0x12, 0x0C, 0x7E, //
0x7C, 0x08, 0x04, 0x04, 0x08, //
0x58, 0x54, 0x54, 0x54, 0x64, //
0x04, 0x3F, 0x44, 0x40, 0x20, //
0x3C, 0x40, 0x40, 0x3C, 0x40, //
0x1C, 0x20, 0x40, 0x20, 0x1C, //
0x3C, 0x40, 0x30, 0x40, 0x3C, //
0x44, 0x28, 0x10, 0x28, 0x44, //
0x1C, 0xA0, 0xA0, 0x90, 0x7C, //
0x44, 0x64, 0x54, 0x4C, 0x44, //
0x00, 0x08, 0x36, 0x41, 0x00, //
0x00, 0x00, 0x77, 0x00, 0x00, //
0x00, 0x41, 0x36, 0x08, 0x00, //
0x02, 0x01, 0x02, 0x04, 0x02, //
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //
};

unsigned char code HZK_12[]={      //字节颠倒

//- 宋体11; 此字体下对应的点阵为:宽x高=11x12
0x42,0x00,0x22,0x00,0x12,0x00,0xFA,0x07,0x4E,0x01,0x4B,0x01,0x4A,0x01,0x4A,0x05,
0xFA,0x07,0x02,0x00,0x02,0x00,0x00,0x00,/*"有",{0}*/

0x42,0x04,0xAE,0x04,0x93,0x04,0x9A,0x02,0xA6,0x01,0xC0,0x00,0xA6,0x04,0x9A,0x04,
0x8A,0x04,0x96,0x03,0x20,0x00,0x00,0x00,/*"努",{1}*/

0x00,0x04,0x08,0x04,0x08,0x02,0x08,0x01,0xC8,0x00,0x3F,0x00,0x08,0x04,0x08,0x04,
0x08,0x04,0xFC,0x03,0x08,0x00,0x00,0x00,/*"力",{2}*/

0x02,0x02,0xFA,0x01,0x4B,0x04,0xCA,0x07,0x7A,0x01,0x02,0x04,0x08,0x03,0xFF,0x00,
0xC8,0x07,0x0E,0x04,0x08,0x07,0x00,0x00,/*"就",{3}*/

0x42,0x00,0x22,0x00,0x12,0x00,0xFA,0x07,0x4E,0x01,0x4B,0x01,0x4A,0x01,0x4A,0x05,
0xFA,0x07,0x02,0x00,0x02,0x00,0x00,0x00,/*"有",{4}*/

0x00,0x04,0xFC,0x03,0x24,0x01,0x24,0x02,0xE4,0x01,0x04,0x04,0x7F,0x02,0x84,0x01,
0x45,0x02,0x36,0x04,0x04,0x07,0x00,0x00,/*"成",{5}*/

0x02,0x01,0x02,0x01,0xFE,0x00,0x82,0x04,0x82,0x04,0x08,0x02,0x88,0x01,0x7F,0x04,
0x08,0x04,0x08,0x04,0xF8,0x03,0x00,0x00,/*"功",{6}*/

0x00,0x00,0x1C,0x00,0x7E,0x03,0x7E,0x03,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00/*"!",{7}*/
};

本程序的实际效果图如下。

8.自制单片机之七……LCD12864的驱动之源代码2 - 哥只是传说 - 我只是一个传说

 

8.自制单片机之七……LCD12864的驱动之源代码2 - 哥只是传说 - 我只是一个传说

关键字:单片机  LCD12864  驱动 引用地址:自制单片机之七……LCD12864的驱动之源代码

上一篇:自制单片机之六……LCD12864的驱动
下一篇:单片机输出PWM脉冲的两种方法

推荐阅读最新更新时间:2024-03-16 15:08

关于单片机程序的执行过程
前言 我们想要理解单片机是如何运行程序的,我们首先需要了解单片机的组成,我们这里以80C51单片机为例来理解程序在单片机中是如何运行的。 单片机的组成 8051单片机的内部硬件结构包括: 中央处理器CPU:它是单片机内部的核心部件,决定了单片机的主要功能特性,由运算器和控制器两大部分组成。 存储器:8051单片机在系统结构上采用了哈佛型,将程序和数据分别存放在两个存储器内,一个称为程序存储器,另一个为数据存储器在物理结构上分程序存储器和数据存储器,有四个物理上相互独立的存储空间,即片内ROM和片外ROM,片内RAM和片外RAM。 定时器/计数器(T/C):8051单片机内有两个16位的定时器/计数器,每个T/C既可以设置成计数
[单片机]
关于<font color='red'>单片机</font>程序的执行过程
stc-52单片机的引脚描述及片外总线结构
9、RST/VPD(9脚) RST复位(高电平复位):当输入的信号连续2个机器周期以上高电平时即为有效,用以完成单片机的复位初始化操作。推荐在此引脚与VSS引脚之间连接一个约8.2k的下拉电阻,与VCC引脚之间连接一个约10 F的电容,以保证可靠地复位。 VPD备用电源:VCC掉电期间,此引脚可接上备用电源,以保证内部RAM的数据不丢失。当VCC主电源下掉到低于规定的电平,而VPD在其规定的电压范围(5 0.5V)内,VPD就向内部RAM提供备用电源。 18、19、时钟引脚 时钟引脚外接晶体与片内的反相放大器构成了一个振荡器,它提供了单片机的时钟控制信号。时钟引脚也可外接晶体振荡器。 (1)X
[单片机]
基于51单片机的智能公交系统
本作品实现小车自动循迹行走,到站停车语音报站,行驶途中将车速等信息通过无线模块发送至站台。站台部分显示车辆速度,距离车站路程,预计到站时间等信息。 中心处理芯片采用AT89S52 ,语音芯片ISD4004,无线模块NRF24L01,测速采用光电开关和测速码盘。 硬件电路: 小车控制部分电路 电机驱动电路 公交站台电路
[单片机]
单段式CrM TRIAC调光LED驱动器设计
  为了促进节能,世界各地的政府机构或规范组织制定了不同LED照明规范,主要体现在对功率因数(PF)的要求方面。如欧盟的国际电工联盟(IEC)规定了功率大于25 W照明应用的总谐波失真性能,某些地区的其它国际标准也适用这规定。   另外,美国能源部制定及发布了针对固态照明灯具的“能源之星”标准。这项自愿性标准包含针对常见住宅和商业照明灯具(如嵌灯、橱柜灯和台灯)的系列要求,涵盖最低流明输出、总体光效、可靠性目标、光色温及一系列其它关键系统级要求。值得注意的是,这个标准中并不直接包含电源能效要求,但包含功率因数要求,即不论是何种功率等级,住宅应用要求的PF大于0.7,商业应用要求的PF大于0.9,而集成LED灯光的要求是PF大于0
[电源管理]
采用MCU控制的蓝牙无线充电系统设计
目前市场上的电子产品层出不穷,各种电子产品的充电器也多种多样,这样既浪费资源,又不利于环保,更重要的是这些充电器不具备通用性,不方便用户的使用。日常生活中,经常会遇到手机、电脑等电量不足,急需充电的情况,而且不可能随时携带充电器,导致手机充电很麻烦。有了无线充电技术就可以在很大程度上减少这种麻烦。因此,设计基于MSP430F149的蓝牙无线充电系统,摆脱以往电线的束缚,解决电子产品充电接口不兼容的问题。该设计具有携带方便、成本低、无需布线等优势,适用于各手持移动设备以及小型用电器,不但环保并且方便了广大的用户。 1 整体方案设计 方案的主要任务是利用MCU MSP430F149 控制蓝牙模块,实现蓝牙手机与蓝牙模块的匹配,或者蓝牙
[单片机]
采用<font color='red'>MCU</font>控制的蓝牙无线充电系统设计
基于51单片机的超声波测距模块设计
超声波测距的模块,51单片机接上12864液晶,HC-SR04超声波模块,就可以了,具体程序没怎么看,超声波模块的硬件也不晓得。 超声波测距51单片机12864液晶显示源程序: #include #include //引脚定义 sbitRX=P1 ^ 1; sbitTX=P1 ^ 2; sbitCS=P3 ^ 3;//片选 高电平有效 单片LCD使用时可固定高电平 sbitSID=P3 ^ 4;//数据 sbitSCLK=P3 ^ 5;//时钟 //Function Definition 函数声明 void Delay(int num); void Init_DS18B20(void); unsigned char ReadO
[单片机]
油井井下高温度和压力测试系统研究与应用
0 引言 在开采石油的过程中,井下的温度和压强是必不可少的测量参数,准确的井下温度和压强测量对于油井监测等都具有重要的作用。油田投入开发后,随着开采时间的增长,油层压力不断下降,地下原油大量脱气,粘度增加,油井产量大大减少,甚至会停喷停产。为了弥补原油采出后所造成的地下亏空,保持或提高油层压力,实现油田高产稳产,利用注水井把水(或者气)注入油层,以补充和保持油层压力。然而采取这些操作时一定要在对井下条件有全面了解之后才能进行。在传统的测量井温过程中,使用了红外测温仪、红外热成像仪、温度传感器阵列等,但由于井下环境对测试仪器产生很大的影响,容易造成测试误差,且对于温度场的测量有很多不足。油井高温高压测量变送仪中温度传感器采用热电偶
[测试测量]
油井井下高温度和压力测试系统研究与应用
AD574与8031单片机及前置电路的一种实用接口电路
  AD574是美国核拟器件公司Analog Devices) 生产的12 位逐次逼近型快速A/D 转换器。其转换35us,转换误差为土0.05%,是前我国应用广泛,价格适中的A/D转换器。其内部含三态电路,可直接与各种微处理器连接,且无须附加逻辑接口电路,便能与CMOS 及TTL 电平兼容。内部配置的高精度参考电压源和时钟电路,使它不需要任何外部电路和时钟信号,就能实现A/D转换功能,应用非常方便。   许多文献有关于AD574与8031单片机接口技术的介绍, 但其控制功能引线基本局限于单一的AD574与8031的连接。由于8031无内部程序存贮器, 其内部数据存贮器也有限, 因而8031构成的测控系统, 往往都需外扩存贮器
[单片机]
AD574与8031<font color='red'>单片机</font>及前置电路的一种实用接口电路
小广播
添点儿料...
无论热点新闻、行业分析、技术干货……
设计资源 培训 开发板 精华推荐

最新单片机文章
何立民专栏 单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

换一换 更多 相关热搜器件
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved