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

📄 lcd.h

📁 时钟芯片H1380控制程序
💻 H
字号:

static BYTE code Dot32[]={	// ':'
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x0e,0x0e,0x0e,0x00,0x00,
	0x00,0x00,0x00,0x38,0x38,0x38,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static BYTE code Dot32_1[]={	// ':'
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x0e,0x0e,0x0e,0x00,0x00};
static BYTE code Dot32_2[]={0x00,0x00,0x00,0x38,0x38,0x38,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static BYTE code Dot0_1[]={	// ':'
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static BYTE code Dot0_2[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static BYTE code hanzi_1[]={
/*---转换字符 彭 ---*/
0x20,0x04,0x2B,0xC6,0x2A,0xA4,0x2A,0x94,0xFA,0x84,0x2A,0x98,0x2A,0xE8,0x2B,0x88,
0x20,0x08,0x04,0x42,0x08,0x84,0x11,0x08,0x66,0x18,0x22,0x70,0x00,0x20,0x00,0x00};
static BYTE code hanzi_2[]={
/*---转换字符 鹤 ---*/
0x00,0x80,0x31,0x00,0x27,0xFF,0xFA,0x52,0x2B,0xFE,0x26,0x52,0x32,0x52,0x20,0x02,
0x3F,0x90,0x70,0x90,0xAC,0x90,0x20,0x90,0x22,0x92,0x3E,0x81,0x00,0xFE,0x00,0x00};
static BYTE code hanzi_3[]={
/*---转换字符 挺 ---*/
0x10,0x80,0x10,0x82,0x11,0x01,0xFF,0xFE,0x12,0x42,0x31,0x24,0x27,0x18,0x39,0x68,
0x01,0x84,0x22,0x12,0x22,0x12,0x3F,0xF2,0x42,0x12,0x42,0x12,0x42,0x02,0x00,0x00};
static BYTE code hanzi_4[]={
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};

void delay(void)
{
    uchar i,j;
    for (i = 0;i != 0xff;i++)
    for (j = 0;j != 0xff;j++) ;
}

void send2LCM(bit rs,uchar dat )/* rs=0时写入控制指令,rs=1时写入显示数据 */
{
    B_LCD_A0 = rs;
    _CS = 0;
	P0=dat;
    _CS = 1;
    B_LCD_A0 = ~rs;
}

void lcdclear(uchar dat1,uchar dat2)/*写测试数据到LCD全屏*/
{
    uchar i,j;
    for(i = 0xb0;i<0xb8;i++)
    { 
        send2LCM(0,i); //写页地址
        send2LCM(0,0x10); //写初始列地址
        send2LCM(0,0x01);
        for(j = 0x00;j<0x41;j++)
        {
            send2LCM(1,dat1); //写显示数据
            send2LCM(1,dat2);
        }
    }
}
void initlcm(void)    /*初始化LCM*/
{   
	BYTE i;
	_RET = 0; //硬复位
	delay();
    _RET = 1;
	for(i=250;i>0;i--);
	for(i=250;i>0;i--);
	for(i=250;i>0;i--);
	for(i=250;i>0;i--);
    send2LCM(0,0xa2); /*LCD BIAS=1/9*/
    send2LCM(0,0xa0); /*列地址移动方向:ADC=0(SEG1->SEG132)*/
    send2LCM(0,0xc8); /*行扫描方向:SHL=1(COM64->COM1)*/
	for(i=250;i>0;i--);
	for(i=250;i>0;i--);
    send2LCM(0,0x2f); /*电源控制模式:VC,VR,VF=111*/
	for(i=250;i>0;i--);
	for(i=250;i>0;i--);
    send2LCM(0,0x26); /*内部调整电阻比率:R2,R1,R0=111*/
	for(i=250;i>0;i--);
	for(i=250;i>0;i--);
    send2LCM(0,0x81); /*对比度寄存器模式*/
    send2LCM(0,0x00); /*对比度寄存器值  修改这个值就可以调节对比度了*/
    send2LCM(0,0x60); /*起始行*/
    send2LCM(0,0xe0); /*写入数据时列地址自动加1,但读时不变*/
    send2LCM(0,0xaf); /*开显示*/
}

void dishz(uchar x_add,uchar y_add,uint k)/*x_add 页地址 y_add 列地址 */
{
    uchar i,pag,colh,coll,x,y;
	uint p=0;
	p=k*16;
    pag = x_add+0xb0;
    send2LCM(0,colh);
    send2LCM(0,coll);
    send2LCM(0,pag);
    for (y=0;y<8;y++)
    { 
        for(x=0;x<2;x++)
        { 
			i=y_add+y;  
    		colh = i>>4; /*取y_add的高4位*/
    		colh = colh | 0xf0;
			colh = colh & 0x1f;
			coll = i & 0x0f; /*取y_add的低4位*/    
			send2LCM(0,pag+x);
            send2LCM(0,colh);
            send2LCM(0,coll);
	      	send2LCM(1,zimo[p]);
			p++;
    	}
	}
}
void dishzi(uchar x_add,uchar y_add,uint k)
{/*x_add 页地址 y_add 列地址 *p 字模数据地址*/
    uchar i,pag,colh,coll,x,y;
	uint p=0;
	p=k*16;
    pag = x_add+0xb0;
    send2LCM(0,colh);
    send2LCM(0,coll);
    send2LCM(0,pag);
    for (y=0;y<16;y++)
    { 
        for(x=0;x<2;x++)
        { 
			i=y_add+y;  
    		colh = i>>4; /*取y_add的高4位*/
    		colh = colh | 0xf0;
			colh = colh & 0x1f;
			coll = i & 0x0f; /*取y_add的低4位*/    
			send2LCM(0,pag+x);
            send2LCM(0,colh);
            send2LCM(0,coll);
	      	send2LCM(1,zimo[p]);
			p++;
    	}
	}
}
void LCD_open(void)
{
	initlcm();
	lcdclear(0x00,0x00);
}

void showtime(void)
{
	readtime();
	dishz(0,24,xytime[13]);			//year
	dishz(0,32,xytime[12]);
	dishz(0,56,xytime[9]);			//mon
	dishz(0,64,xytime[8]);
	dishz(0,88,xytime[7]);			//day
	dishz(0,96,xytime[6]);
	dishzi(2,64,(2*xytime[10]+16));			//xingqi
	dishz(4,32,xytime[5]);			//hour
	dishz(4,40,xytime[4]);
	dishz(4,56,xytime[3]);			//min
	dishz(4,64,xytime[2]);	
	dishz(4,80,xytime[1]);			//sec
	dishz(4,88,xytime[0]);
	if(xytime[0]%2)
	{
		dishz(4,48,11);			//  :
		dishz(4,72,11);			//	:
	}
	else
	{
		dishz(4,48,42);
		dishz(4,72,42);
	}		
}

void xianshi (void)
{
/*	dishz(4,48,11);			//  :
	dishz(4,72,11);			//	:*/
	dishz(0,8,2);			//	2
	dishz(0,16,0);			//	0
	dishzi(0,38,12);		//	年
	dishzi(0,70,14);		//	月
	dishzi(0,102,16);		//	日
	dishzi(2,32,30);		//	星
	dishzi(2,48,32);		//	期
}

⌨️ 快捷键说明

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