lcd.c

来自「Seed1335的LCD控制程序,负责320*240的液晶屏的初始化以及画点函数」· C语言 代码 · 共 115 行

C
115
字号
void Draw8Bit(int x,int y,char c,int n)
{
	int ic1;

	setxy(x,y);
	_outp(0x115,0x42);
    	if(n==1)	ic1 = (c^0xff);
    	else  	ic1=c;
	_outp(0x114,ic1);
}
void drawpoint(int x,int y,int a1)
{
	unsigned int c,c1;
	
	c = 0;
	setxy(x,y);
	_outp(0x115,0x43);
	c = _inp(0x115);
	c1 = (7 - (x%8));
	c1 = 0x01 << c1;
	if(a1 == 0x00){
		c1 = c1^0xff;
		c = c & c1;
	}
	else	c = c | c1;
	setxy(x,y);
	_outp(0x115,0x42);		//0x115命令
	_outp(0x114,c);			//0x114数据
	return;
}
void setxy(int x,int y)
{
	int k,l,xx,yy,zz;

	zz = x/8;
	yy = y+(screenflag-1)*240;	//screenflag屏标
	xx = yy*40 + zz; 
	k = xx&0x00ff;
	l = xx >> 8;
	l = l&0x00ff;
	_outp(0x115,0x46);
	_outp(0x114,k);
	_outp(0x114,l);
	return;
}
void CleanScreen(int n)
{
	int i;

	i=(n-1)*9600;
	_outp(0x115,0x46);
	_outp(0x114,(i&0x00ff));
	_outp(0x114,(i>>8));
	_outp(0x115,0x042);

	for(i = 0;i < 9600;i++){
		_outp(0x114,0x00);
	}
}
void EnableScreen(int n)
{
	_outp(0x115,0x59);
	if(n == 1){
		_outp(0x114,0x04);
		screenflag=1;
	}
	else	if(n == 2){
		_outp(0x114,0x10);
		screenflag=2;
	}
	else	if(n == 3){
		_outp(0x114,0x40);
		screenflag=3;
	}
}
void LcdInit(void)
{
	int i,j;
	int iLcdBufa[8]={0x30,0x87,0x07,0x27,0x42,0xf0,0x28,0x00};
	int iLcdBufb[10]={0x00,0x00,0xf0,0x80,0x25,0xf0,0x00,0x4b,0x00,0x00};
//初始化	
	_outp(0x115,0x40);
	for(i = 0;i < 8;i++)
		_outp(0x114,iLcdBufa[i]);

	_outp(0x115,0x44);
	for(i = 0;i < 10;i++)
		_outp(0x114,iLcdBufb[i]);

	_outp(0x115,0x5a);
	_outp(0x114,0x00);

	_outp(0x115,0x5b);
	_outp(0x114,0x1c);

	_outp(0x115,0x59);
	_outp(0x114,0x00);
	//
	_outp(0x115,0x5d);
	_outp(0x114,0x07);
	_outp(0x114,0x01);
	//光标移动方向 向右
	_outp(0x115,0x4c);
	//光标指针设置
	_outp(0x115,0x46);
	_outp(0x114,0x00);
	_outp(0x114,0x00);
	//清屏
	_outp(0x115,0x42);
	for(j = 0;j < 3;j++)
		for(i = 0;i < 9600;i++){
			_outp(0x114,0x00);
		}
}

⌨️ 快捷键说明

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