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

📄 lpc_lib_lcd.c

📁 使用embest IDE开发工具开发的基于LPC2294 的触摸屏开发
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
**********************************************************************************************
*
*     		  Embest Info&Tech Co., Ltd.  All rights reserved.
*                   		  www.embedinfo.com
*			
*file:     		lpc_lib_LCD.c 
*author:   		z.x.q. embest 
*establish: 	2006.xx.xx
*modify:		xx
*notes:			xx
**********************************************************************************************
*/

/*
**********************************************************************************************
*                                       include files
**********************************************************************************************
*/
#include 	"..\..\com\lpc_lib_LCD\lpc_lib_LCD.h"
/*
**********************************************************************************************
*                               extern function/variable declare
**********************************************************************************************
*/

/*
**********************************************************************************************
*                                  global variable define 
**********************************************************************************************
*/
INT8U glineth=0;		//line number	
INT8U gcolth=0;			//column number
INT16U gfore_clr=0x0;	//fore color
INT16U gback_clr=0x07ff;//back color
/*
**********************************************************************************************
* name:		function name
* func:		effect
* para:		form parameter
* ret:		return value description
* modify:
* comment:		
**********************************************************************************************
*/	
/*
**********************************************************************************************
* name:		LCD_init
* func:		initialize LCD screen
* para:		none
* ret:		none
* modify:
* comment:		
**********************************************************************************************
*/		
void LCD_init(void)
{	      
/*------standby_off -------------- */
	LCD_wrcom(0x2C);
	Delayms(1);

/*------set OTP mode off---------*/
	LCD_wrcom(0xEA);
	Delayms(1);
	
/*------set internal osc on---------*/
	LCD_wrcom(0x02);
	LCD_wrcom(0x01);
	Delayms(20);
	
/*------booster1 on---------------*/
	LCD_wrcom(0x20);
	LCD_wrcom(0x08);      //DC-DC step-up: *2.0
        Delayms(30);   
         
/*------booster1 on---------------*/
	LCD_wrcom(0x26);
	LCD_wrcom(0x01);
        Delayms(30);    

/*------booster1 on and amp on---------*/
	LCD_wrcom(0x26);
	LCD_wrcom(0x09);
	Delayms(30);  

/*------booster2 on-------------*/
	LCD_wrcom(0x26);
	LCD_wrcom(0x0b);
	Delayms(30);         

/*------booster3 on-------------*/
	LCD_wrcom(0x26);
	LCD_wrcom(0x0f);
	Delayms(30);

/*------temp compsation ratio -0.05%------*/
	LCD_wrcom(0x28);
	LCD_wrcom(0x01);
	
/*------ram skip area set no skip------*/
	LCD_wrcom(0x45);
	LCD_wrcom(0x00);

/*------normal display---------*/
	LCD_wrcom(0x53);
	LCD_wrcom(0x00);

/*------set sdir=0,duty=1/132 swap=0-----*/
	LCD_wrcom(0x10);
    LCD_wrcom(0x03);		//Duty=1/132,RGB

/*------set clock fpck=fose/32(Normal)-------*/
	LCD_wrcom(0x24);
	LCD_wrcom(0x03);

/*------GSM=0:65K color,DSG=0,SGF=1,SGP=00,SGM=1-----*/
	LCD_wrcom(0x30);
	LCD_wrcom(0x09);//09

/*------row vector type=Diagonal ,INC=111-----*/
	LCD_wrcom(0x32);
	LCD_wrcom(0x0E);//0e

/*------entry mode set : x addr increce, read modify write off--*/
	LCD_wrcom(0x40);
	LCD_wrcom(0x00);

/*------x address set from 00 to 127--------*/
	LCD_wrcom(0x43);
	LCD_wrcom(0x00);
	LCD_wrcom(0x7F);		

/*------y address set from 00 to 127--------*/
	LCD_wrcom(0x42);
	LCD_wrcom(0x00);
	LCD_wrcom(0x7F);		

/*------frame set FIM=ON,FIP=1FRAME,N-BLOCK=9-F-----*/
	LCD_wrcom(0x34);
	LCD_wrcom(0xCd);

/*------contrast1 set,Range:2.8--4v*/
	LCD_wrcom(0x2a);
	LCD_wrcom(0x48);		/*partial display mode 0*/

	
/*------contrast2 set --------*/
	LCD_wrcom(0x2b);
	LCD_wrcom(0x48);		/*partial display mode 1*/


/*------partial display mode off-------*/
	LCD_wrcom(0x55);
	LCD_wrcom(0x00);
	
/*------Low frequency set off-------*/
	LCD_wrcom(0x36);
	LCD_wrcom(0x00);

/*------display on set--------*/
    Delayms(10);
	LCD_wrcom(0x51);	
	
	Delayms(30);
	
	cls();	
}
/*
**********************************************************************************************
* name:		LCD_wrcom
* func:		write command
* para:		command data
* ret:		none
* modify:
* comment:		
**********************************************************************************************
*/		
void LCD_wrcom(INT16U comd)
{
	ADDR_COM=comd;
}
/*
**********************************************************************************************
* name:		wrdata
* func:		effect
* para:		form parameter
* ret:		return value description
* modify:
* comment:		
**********************************************************************************************
*/		
void LCD_wrdata(INT16U data)
{
	ADDR_DATA=data;
}
/*
**********************************************************************************************
* name:		LCD_BL_cn
* func:		back light onoff control
* para:		onoff: 0: on  1:off
* ret:		none
* modify:
* comment:		
**********************************************************************************************
*/
void LCD_BL_con(INT8U onoff)
{
	if(onoff==0)
		spi_extend_set(0,module_c_LCM_EN);
	else
		spi_extend_set(1,module_c_LCM_EN);		
}
/*
**********************************************************************************************
* name:		LCD_reset
* func:		reset LCD 
* para:		none
* ret:		none
* modify:
* comment:		
**********************************************************************************************
*/
void LCD_reset(void)
{
	spi_extend_set(0,module_c_LCM_RESET_EN);
	time_dly(50);
	spi_extend_set(1,module_c_LCM_RESET_EN);

}
/*
**********************************************************************************************
* name:		Delayms
* func:		delay time in ms 
* para:		value: delayed value ,unit:ms
* ret:		none
* modify:
* comment:		
**********************************************************************************************
*/
void Delayms(INT32U value)
{
	INT32U i;
	for(;value>0;value--)
		for(i=0;i<500;i++);
}
//set x address
void LCD_Xaddr(INT8U startx,INT8U endx)
{
	LCD_wrcom(0x43);
	LCD_wrcom(startx);
	LCD_wrcom(endx); 
}
//set y address
void LCD_Yaddr(INT8U starty,INT8U endy)
{
	LCD_wrcom(0x42);
	LCD_wrcom(starty);
	LCD_wrcom(endy); 
}

/*
**********************************************************************************************
* name:		LCD_sendch
* func:		display a char in LCD
* para:		the displaying data
* ret:		none
* modify:
* comment:	there are 14 ascii chars in every line, 7 lines in all.
			dscription about one ascii char:8*16 dots. 
			so LCD panel: x: 8*14+X_SPACE0+X_SPACE1=128
						  y: 16*7+Y_SPACE0+Y_SPACE1=130		
**********************************************************************************************
*/
void LCD_sendch(INT8U data)
{
	INT32U i,j,k;
	INT8U xaddr,yaddr;
	INT8U data1,dmask;
	if(data=='\n')
	{
		glineth++;
		gcolth=0;
	}
	else if(data=='\r')
		gcolth=0;
	else if((data>=0x20)&&(data<=0x7e))
	{
		xaddr=gcolth*8+X_SPACE0;
		yaddr=glineth*16+Y_SPACE0;
		LCD_Xaddr(xaddr,0x7f);
		LCD_Yaddr(yaddr,0x81);

⌨️ 快捷键说明

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