www.pudn.com > hx711_LCD5110.rar > 5110.c, change:2015-07-03,size:11668b


#include <STC12C5A60S2.H> 
#include "5110.h" 
 
 
 
unsigned char code hanzi[]; 
unsigned char code shuzi[]; 
/*******************************************************************  
*函数名称: void Delay(unsigned int x)  
*入口参数: x:延时长度  
*出口参数:  
*函数说明: 不精确的延时  
********************************************************************  
void Delay(unsigned int x)  
{   
   unsigned int y;  
   for(;x>0;x--)  
    for(y=10;y>0;y--);  
}  
*/ 
 
 
void delay_1ms(void)//1ms延时函数 
{ 
	unsigned int i; 
	for (i=0;i<500;i++)	  ; 
 
} 
 
/*-------------------------------------------- 
LCD_write_byte: 使用SPI接口写数据到LCD 
输入参数:dt:写入的数据; 
command :写数据/命令选择; 
编写日期:20080918  
----------------------------------------------*/ 
void LCD_write_byte(unsigned char dt, unsigned char command) 
{ 
	unsigned char i;  
	sce=0;	 
	dc=command;	 
	for(i=0;i<8;i++) 
	{  
		if(dt&0x80) 
			sdin=1; 
		else 
			sdin=0; 
		dt=dt<<1;		 
		sclk=0; 		 
		sclk=1;  
	}	 
	dc=1;	 
	sce=1;	 
	sdin=1; 
} 
/*--------------------------------------- 
LCD_init: 3310LCD初始化 
编写日期:20080918  
-----------------------------------------  */ 
void LCD_init() 
{ 
	res=0;  	 
  	delay_1ms(); 
  	res=1;   
	LCD_write_byte(0x21,0);//初始化Lcd,功能设定使用扩充指令 
	LCD_write_byte(0xc0,0);//设定液晶偏置电压 
	LCD_write_byte(0x20,0);//使用基本指令 
	LCD_write_byte(0x0C,0);//设定显示模式,正常显示 
} 
/*------------------------------------------- 
LCD_set_XY: 设置LCD坐标函数 
输入参数:X:0-83  Y:0-5 
编写日期:20080918  
---------------------------------------------*/ 
void LCD_set_XY(unsigned char X, unsigned char Y) 
{ 
	LCD_write_byte(0x40 | Y, 0);// column 
	LCD_write_byte(0x80 | X, 0);// row 
}  
/*------------------------------------------ 
LCD_clear: LCD清屏函数 
编写日期:20080918  
--------------------------------------------*/ 
void LCD_clear(void) 
{ 
	unsigned char t; 
	unsigned char k; 
	LCD_set_XY(0,0); 
	for(t=0;t<6;t++) 
	{  
		for(k=0;k<84;k++) 
		{  
			LCD_write_byte(0x00,1); 
				 
		}  
	} 
} 
/*--------------------------------------------- 
LCD_write_shu: 显示8(宽)*16(高)点阵列数字字母符号等半角类 
输入参数:c:显示的字符; 
编写日期:20080918  
-----------------------------------------------*/ 
void LCD_write_shu(unsigned char row, unsigned char page,unsigned char c) //row:列 page:页 dd:字符 
{ 
	unsigned char i;  	 
	 
	LCD_set_XY(row*8, page);// 列,页  
	for(i=0; i<8;i++)  
	{ 
		LCD_write_byte(shuzi[c*16+i],1);  
	} 
	 
    LCD_set_XY(row*8, page+1);// 列,页  
	for(i=8; i<16;i++)  
	{ 
		LCD_write_byte(shuzi[c*16+i],1); 
	}	 	 
} 
/*--------------------------------------------- 
LCD_write_hanzi: 显示16(宽)*16(高)点阵列汉字等半角类 
输入参数:c:显示的字符; 
编写日期:20080918  
-----------------------------------------------*/ 
void LCD_write_hanzi(unsigned char row, unsigned char page,unsigned char c) //row:列 page:页 dd:字符 
{ 
	unsigned char i;  	 
	 
	LCD_set_XY(row*8, page);// 列,页  
	for(i=0; i<16;i++)  
	{ 
		LCD_write_byte(hanzi[c*32+i],1);  
	} 
	 
    LCD_set_XY(row*8, page+1);// 列,页  
	for(i=16; i<32;i++)  
	{ 
		LCD_write_byte(hanzi[c*32+i],1); 
	}	 
} 
 
 
unsigned char code shuzi[]={ 
/*--  文字:  0  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00, 
 
/*--  文字:  1  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, 
 
/*--  文字:  2  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00, 
 
/*--  文字:  3  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00, 
 
/*--  文字:  4  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00, 
 
/*--  文字:  5  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00, 
 
/*--  文字:  6  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00, 
 
/*--  文字:  7  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, 
 
/*--  文字:  8  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00, 
 
/*--  文字:  9  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00, 
 
/*--  文字:  a  --10*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20, 
 
/*--  文字:  b  --11*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00, 
 
/*--  文字:  c  --12*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00, 
 
/*--  文字:  d  --13*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20, 
 
/*--  文字:  e  --14*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00, 
 
/*--  文字:  f  --15*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, 
 
/*--  文字:  g  --16*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00, 
 
/*--  文字:  h  --17*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20, 
 
/*--  文字:  i  --18*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, 
 
/*--  文字:  j  --19*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00, 
 
/*--  文字:  k  --20*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00, 
 
/*--  文字:  l  --21*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, 
 
/*--  文字:  m  --22*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F, 
 
/*--  文字:  n  --23*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20, 
 
/*--  文字:  o  --24*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00, 
 
/*--  文字:  p  --25*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00, 
 
/*--  文字:  q  --26*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80, 
 
/*--  文字:  r  --27*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00, 
																			    
/*--  文字:  s  --28*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00, 
 
/*--  文字:  t  --29*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00, 
 
/*--  文字:  u  --30*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20, 
 
/*--  文字:  v  --31*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00, 
 
/*--  文字:  w  --32*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00, 
 
/*--  文字:  x  --33*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00, 
 
/*--  文字:  y  --34*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00, 
 
/*--  文字:  z  --35*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00, 
 
/*--  文字:  -  --36*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 
 
/*--  文字:  =  --37*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00, 
 
/*--  文字:  \  --38*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00, 
 
/*--  文字:     --39*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
 
/*--  文字:  [  --40*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00, 
 
/*--  文字:  ]  --41*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00, 
 
/*--  文字:  ;  --42*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00, 
 
/*--  文字:  '  --43*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 
 
/*--  文字:  ,  --44*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00, 
 
/*--  文字:  .  --45*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00, 
 
/*--  文字:  /  --46*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00, 
	 
}; 
 
unsigned char code maohao[]={ 
/*--  文字:  :  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/ 
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00 
 
 
}; 
 
 
unsigned char code hanzi[]= 
{ 
/*--  文字:  星  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/ 
0x00,0x00,0x00,0xBE,0x2A,0x2A,0x2A,0xEA,0x2A,0x2A,0x2A,0x2A,0x3E,0x00,0x00,0x00, 
0x00,0x48,0x46,0x41,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x49,0x49,0x41,0x40,0x00, 
 
/*--  文字:  期  --*/ 
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/ 
0x00,0x04,0xFF,0x54,0x54,0x54,0xFF,0x04,0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00, 
0x42,0x22,0x1B,0x02,0x02,0x0A,0x33,0x62,0x18,0x07,0x02,0x22,0x42,0x3F,0x00,0x00, 
 
 
//字体选择小四; 
};