⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wcg-12232显示字程序_c51.txt

📁 WCG-12232显示字程序_C51,WCG-12232显示字程序_C51
💻 TXT
字号:
//#include <SST89C54.H>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
//#define f_page  0xb8
#define f_row   0xc0
#define f_line  0x00

uchar f_page;
uchar code tab1[]={
/*--  文字:  中  0x00--*/
0x00,0x00,0xFC,0x08,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0x08,0xFC,0x08,0x00,0x00,
0x00,0x00,0x07,0x02,0x02,0x02,0x02,0xFF,0x02,0x02,0x02,0x02,0x07,0x00,0x00,0x00,
/*--  文字:  科  0x20--*/
0x10,0x12,0x92,0x72,0xFE,0x51,0x91,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,
0x04,0x02,0x01,0x00,0xFF,0x00,0x04,0x04,0x04,0x02,0x02,0x02,0xFF,0x01,0x01,0x00,
/*--  文字:  国  0x40--*/
0x00,0xFE,0x02,0x0A,0x8A,0x8A,0x8A,0xFA,0x8A,0x8A,0x8A,0x0A,0x02,0xFE,0x00,0x00,
0x00,0xFF,0x40,0x48,0x48,0x48,0x48,0x4F,0x48,0x49,0x4E,0x48,0x40,0xFF,0x00,0x00,
/*--  文字:  技  0x60--*/
0x08,0x08,0x88,0xFF,0x48,0x28,0x00,0xC8,0x48,0x48,0x7F,0x48,0xC8,0x48,0x08,0x00,
0x01,0x41,0x80,0x7F,0x00,0x40,0x40,0x20,0x13,0x0C,0x0C,0x12,0x21,0x60,0x20,0x00,
/*--  文字:  肇  0x80--*/
0x80,0x60,0x1C,0x95,0x96,0x94,0x9C,0xC8,0xA4,0xAF,0x94,0x94,0x2C,0x44,0x44,0x00,
0x20,0x22,0x2A,0x2A,0x2A,0x2A,0x2A,0xFF,0x2A,0x2A,0x2A,0x2F,0x22,0x22,0x20,0x00,
/*--  文字:  有  0xa0--*/
0x00,0x04,0x84,0x44,0xE4,0x34,0x2C,0x27,0x24,0x24,0x24,0xE4,0x04,0x04,0x04,0x00,
0x02,0x01,0x00,0x00,0xFF,0x09,0x09,0x09,0x29,0x49,0xC9,0x7F,0x00,0x00,0x00,0x00,
/*--  文字:  庆  0xb0--*/
0x00,0x00,0xFC,0x44,0x44,0x44,0x44,0xC5,0x7E,0xC4,0x44,0x44,0x44,0x44,0x44,0x00,
0x40,0x30,0x0F,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x18,0x30,0x60,0x20,0x00,
/*--  文字:  限  0xc0--*/
0xFE,0x02,0x32,0x4E,0x82,0x00,0xFE,0x4A,0xCA,0x4A,0x4A,0x4A,0x7E,0x00,0x00,0x00,
0xFF,0x00,0x02,0x04,0x03,0x00,0xFF,0x40,0x20,0x03,0x0C,0x12,0x21,0x60,0x20,0x00,
/*--  文字:  金  0xd0--*/
0x40,0x40,0x20,0x20,0x50,0x48,0x44,0xC3,0x44,0x48,0x50,0x50,0x20,0x60,0x20,0x00,
0x40,0x40,0x42,0x42,0x4A,0x72,0x42,0x7F,0x42,0x62,0x5A,0x42,0x42,0x40,0x40,0x00,
/*--  文字:  公  0xe0--*/
0x00,0x00,0x80,0x40,0x30,0x0E,0x84,0x00,0x00,0x0E,0x10,0x60,0xC0,0x80,0x80,0x00,
0x00,0x01,0x20,0x70,0x28,0x24,0x23,0x31,0x10,0x10,0x14,0x78,0x30,0x01,0x00,0x00,
/*--  文字:  鹏  --*/
0x00,0xFE,0x12,0xFE,0x00,0xFE,0x12,0xFE,0x00,0xFC,0x0E,0x35,0x44,0x7C,0x00,0x00,
0x20,0x1F,0x21,0x7F,0x20,0x1F,0x41,0x7F,0x08,0x09,0x09,0x29,0x49,0x21,0x1F,0x00,
/*--  文字:  司  --*/
0x00,0x10,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x12,0x02,0x02,0xFE,0x00,0x00,
0x00,0x00,0x1F,0x04,0x04,0x04,0x04,0x04,0x04,0x0F,0x00,0x20,0x40,0x3F,0x00,0x00
};

uchar code tab2[]={
/*--  文字:  8  0x00--*/
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,
/*--  文字:  G  0x10--*/
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,
/*--  文字:  6  0x20--*/
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,
/*--  文字:  o  0x30--*/
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,
/*--  文字:  -  0x40--*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
/*--  文字:  l  0x50--*/
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,
/*--  文字:  7  0x60--*/
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,
};

uchar code tab3[]={
/*--  调入了一幅图像:F:\梁\其它\HOCO12232.bmp  --*/
/*--  宽度x高度=122x32  --*/
0x00,0x00,0x00,0x70,0xF8,0xF8,0xFC,0xFC,0xFE,0xFE,0xFE,0xFE,0xFC,0xFC,0xF0,0xE0,
0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x48,0xD4,0xB4,0x62,0xC2,0x82,0x03,0x02,0x02,
0x02,0x84,0xC4,0xE0,0xA0,0xE0,0x60,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xB0,0xF8,0xF0,0xF0,0xF8,0xFC,0x60,0x60,0x30,
0x18,0x00,0x00,0x00,0x80,0xC0,0xE0,0xE0,0xF0,0xF0,0xF0,0xD8,0x58,0x58,0x58,0x58,
0x58,0xD8,0xD8,0x98,0xB0,0x30,0x70,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
0x07,0x07,0x02,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xFC,0xFC,0xFC,
0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xF8,0xF0,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x01,0x00,0x04,
0x0D,0x1B,0x36,0x6D,0xDB,0xF6,0xED,0xFB,0xFE,0xFE,0xFF,0x7F,0x1F,0x07,0x01,0x00,
0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xFC,0xFE,0xFE,
0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xE0,0xC0,0xC0,0xF8,0xFE,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x3E,0xF8,0x01,0x37,
0x0C,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x60,0xFF,0xC7,0x03,0x03,0x03,0x03,0xE1,
0xFF,0x3F,0x0F,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x0F,0x3F,0x7F,0xFF,0xEF,
0xBF,0x7F,0xFF,0xC7,0x07,0x1F,0xFE,0xF8,0xB0,0x60,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x08,0x10,0x20,0x40,0x40,0x80,0x83,
0xFF,0xFF,0xFF,0xFF,0x83,0x40,0x40,0x20,0x10,0x08,0x04,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x07,0x0F,0x1F,0x3F,0x3F,0x7F,0xFF,
0xFF,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xDF,0x3F,0x3F,0x0F,0x61,0x3F,0x1F,0x2F,0x3F,
0x1F,0x0F,0x00,0x0F,0x07,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x1E,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x60,0x70,0x3C,0x1F,0x07,0x03,0x01,0x01,0x00,0x00,
0x01,0x07,0x07,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x44,0xEC,0x00,
0x7C,0x44,0x7C,0x00,0x7C,0x40,0x40,0x00,0x7C,0x44,0x38,0x00,0x7C,0x14,0x1C,0x00,
0x7C,0x40,0x40,0x00,0x78,0x24,0x78,0x00,0x7C,0x18,0x18,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x10,0x04,0x07,0x00,0x01,0x00,0x00,0x00,0x01,
0x05,0x03,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

/***********************液晶显示模块*******************************/
sfr P0    = 0x80;
sfr P1    = 0x90;
sfr P3    = 0xB0;
sbit Lcdbusy=P0^7; 	//working:1,ready:0
sbit AO=P1^3;
sbit RW=P1^0;
sbit E1=P3^6;
sbit E2=P3^7;

//延时ms
void delayms (unsigned int ms)  
{
  unsigned int i,j;
  for(i=0;i<ms;i++)
  for(j=0;j<463;j++)
  ;
}
//检测LCD左半部是否空闲
void LCD_RDY_L(void)
{
	AO=0;
	RW=1;
	E1=1;
	while(Lcdbusy) {  _nop_();_nop_();_nop_();_nop_();_nop_();}
	E1=0;
}
//检测LCD右半部是否空闲
void LCD_RDY_R(void)
{
	AO=0;
	RW=1;
	E2=1;
	while(Lcdbusy) {  _nop_();_nop_();_nop_();_nop_();_nop_();}
	E2=0;
}
//写LCD左半部命令
void WR_CMDL(uchar cmd)
{
	LCD_RDY_L() ;
	E1=1;
	AO=0;
	RW=0;
	P0=cmd;
	E1=0;
}
//写LCD右半部命令
void WR_CMDR(uchar cmd)
{
	LCD_RDY_R() ;
	E2=1;
	AO=0;
	RW=0;
	P0=cmd;
	E2=0;
}
//写LCD左半部数据
void WR_DATAL(uchar dt)
{
	LCD_RDY_L() ;
	E1=1;
	AO=1;
	RW=0;
	P0=dt;
	E1=0;
}
//写LCD右半部数据
void WR_DATAR(uchar dt)
{
	LCD_RDY_R() ;
	E2=1;
	AO=1;
	RW=0;
	P0=dt;
	E2=0;
}
//清屏
void Lcd_clr()
{
	uchar i,j;
	for(i=0xb8;i<0xbc;i++)
	{
		WR_CMDL(i);		//PAGE(0~3)
		WR_CMDR(i);
		WR_CMDL(0);		//Column Address starts from 0
		WR_CMDR(0);
		for(j=0;j<61;j++)
		{
			WR_DATAL(0);	//The Column address increment ’1’ after read or write.
			WR_DATAR(0);
		}
	}		
}

/*--------------显示汉字(16*16)和字符(8*16)---------------*/
void disphz (uchar code *chn,uint chn_add,uchar lcd_f,bit zf)//chn:字库,chn_add:字在字库中的地址,lcd_f:
{														  //此字在LCD中的显示位置0--121,zf:=1 为字符,=0为汉字
  uchar i,j,s;
  if(zf) s=8;	   //字符
  else s=16;	   //汉字

  if(lcd_f+s<61)				   //如果初始地址+字长<61,写在左半部 0--60
  {
	  for(j=0;j<2;j++)
	  {
	    WR_CMDL(f_page+j);
		WR_CMDL(lcd_f);
		for(i=0;i<s;i++)
		  WR_DATAL(chn[chn_add+i]);
		chn_add+=s;
	  }
  }
  else if(lcd_f>=61)			   //如果大于61,写在右半部   61--121
  {
	  for(j=0;j<2;j++)
	  {
	    WR_CMDR(f_page+j);
		WR_CMDR(lcd_f-61);
		for(i=0;i<s;i++)
		  WR_DATAR(chn[chn_add+i]);
		chn_add+=s;
	  }
  }
  else							  //否则两边都要写
  {
  	  for(j=0;j<2;j++)
	  {
	    WR_CMDL(f_page+j);
		WR_CMDL(lcd_f);
		for(i=0;i<(61-lcd_f);i++) //左半部写到61-lcd_f个字节
		  WR_DATAL(chn[chn_add+i]);
		WR_CMDR(f_page+j);
		WR_CMDR(0x00);
	 	for(i=61-lcd_f;i<s;i++)	  //右半部写剩下的字节
		  WR_DATAR(chn[chn_add+i]);
		chn_add+=s;	
	  }
  }
}
/*----------------画图形-----------------*/
void disptu (uchar code *img)
{
   uchar i,j,img_add;
   img_add=0;
   for(j=0;j<4;j++)
   {
     WR_CMDL(0xb8+j);
	 WR_CMDL(0x00);
     WR_CMDR(0xb8+j);
	 WR_CMDR(0x00);
	 for(i=0;i<122;i++)
	 {
	 	if(i<61) WR_DATAL(img[img_add+i]);
		else 	 WR_DATAR(img[img_add+i]);
	 }
	 img_add+=122;
   }
}
/*--------------写点阵------------------*/
void wrlattice (uchar lattice1,uchar lattice2,uchar lcd_f,uchar lcd_page)//lattice:显示的数,lcd_f:同上,lcd_page:显示的行
{
 if(lcd_f<61)
 {
   WR_CMDL(lcd_page);
   WR_CMDL(lcd_f); 
   WR_DATAL(lattice1);
 }
 else
 {
   WR_CMDR(lcd_page);
   WR_CMDR(lcd_f-61); 
   WR_DATAR(lattice1);
 } 
 if(lcd_f<61)
 {
   WR_CMDL(lcd_page+1);
   WR_CMDL(lcd_f); 
   WR_DATAL(lattice2);
 }
 else
 {
   WR_CMDR(lcd_page+1);
   WR_CMDR(lcd_f-61); 
   WR_DATAR(lattice2);
 } 
}

//-------------------LCD初始化--------------------------
void Lcd_init()
{
	WR_CMDL(0XE2);	//RESET
	WR_CMDR(0XE2);
	delayms(20);
	WR_CMDL(0XA4);	//Normal Display
	WR_CMDR(0XA4);
	WR_CMDL(0XA9);	//DUTYSELECT=1/32
	WR_CMDR(0XA9);
	WR_CMDL(0XA0);	//ADC SELECT=CLOCKWISE OUTPUT
	WR_CMDR(0XA0);
	WR_CMDL(0XAF);	//OPEN DISPLAY
	WR_CMDR(0XAF);
	WR_CMDL(0XC0);	//START FIRST LINE
	WR_CMDR(0XC0);
	Lcd_clr();			//CLEAR LCD
}
/************************液晶显示模块******************************/
void main()
{
    uchar i;
	Lcd_init();
	while(1)
	{
		f_page=0xb8;                 //从哪行开始写,一共4行:0xb8,0xb9,0xba,0xbb
		disphz(tab1,0x40,54,0);		 //国
		delayms(500);
		disphz(tab1,0x60,0x60,0);		 //技
		delayms(500);

		f_page=0xba;                 //从哪行开始写,一共4行:0xb8,0xb9,0xba,0xbb
		disphz(tab2,0x30,0x20,1);		 //o
		delayms(500);
		disphz(tab2,0x60,0x60,1);		 //7
		delayms(500);
		Lcd_clr();							 //图
		disptu(tab3);
		delayms(1000);
		Lcd_clr();

		wrlattice(0xfc,0x3f,0x00,0xba); //|_______________|   从下往上 如fc,则是最上2格不写
		for(i=1;i<121;i++)
	    	wrlattice(0x04,0x20,i,0xba);
		wrlattice(0xfc,0x3f,121,0xba);
		delayms(1000);
		for(i=1;i<121;i++)
	    {delayms(20);	wrlattice(0xfc,0x3f,i,0xba);}

		delayms(1000);
		Lcd_clr();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -