lcd_display.h

来自「基于51单片机或者ARM2131的电子小车的设计」· C头文件 代码 · 共 67 行

H
67
字号

#define uchar unsigned char
#define uint unsigned int

#define DA_LCDPORT P0	//LCD
sbit busy=P0^7;
sbit RS=P1^5;			
sbit RW=P1^6;
sbit E=P1^7;

void Delay(uchar t, uchar i)
{	for(;t>0;t--)
		{ for(;i>0;i--); }				 	
}

void lcdbusy()
{	RS=0;
	RW=1;
	busy=1;
	while(1)
		{	E=1;
			if(!busy) 	break;
			E=0;
		}	
}


void Lcd_WD(uchar da)
{	lcdbusy();
	RS=1;
	RW=0;
	E=1;
	DA_LCDPORT=da;
	//Delay(1,100);
	E=0;
}

void Lcd_WC(uchar c)
{	lcdbusy();
	RS=0;
	RW=0;
	E=1;
	DA_LCDPORT=c;
	//Delay(1,100);
	E=0;
}

void Lcd_Init()
{	//Delay(15,125);
	Lcd_WC(0x38);
	//Delay(5,125);
	Lcd_WC(0x38);
	//Delay(5,125);
	Lcd_WC(0x38);
	//Delay(5,125);
	Lcd_WC(0x08);
	Lcd_WC(0x01);
	Lcd_WC(0x06);
	Lcd_WC(0x0c);
}

void Lcd_WS(uchar *s,uchar x,uchar y)//字符串由N个单字字符组成
{	for(;*s!=0;s++)
		{	Lcd_WC(0x80+(x++)+0x40*y);//地址
		Lcd_WD(*s);				 //数据		
	 	}			
}

⌨️ 快捷键说明

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