BYTE address;
//========= LCM_Clear ============
//[Group] LCM
//[Input]
//[Output]
//[Usage]
// Clear the LCM
//===================================
void LCM_Clear()
{
LCM_LineClear(1);
LCM_LineClear(2);
}
//========= LCM_LineClear ============
//[Group] LCM
//[Input]
// Y_Cnt08:The line need clear,1:first line,2: second line
//[Output]
//[Usage]
// Clear the one line of the LCM
//===================================
void LCM_LineClear(BYTE Y_Cnt08)
{
BYTE i;
BYTE Event08;
BYTE buff[21];
LCM_sSet_Position(0,Y_Cnt08);
buff[0]=0x80;
buff[1]=0x38;
buff[2]=0x80;
buff[3]=address;
buff[4]=0x40;
for(i=0; i<16; i++)
{
buff[5+i]=' ';
}
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 21, &Event08 );
}
//====== LCM_WriteChar =======
//[Group] LCM
//[Input]
// X08:X position; Y08: Y position; DATA08:ASCII
//[Output]
//[Usage] write one char at the set position
void LCM_WriteChar(BYTE X08,BYTE Y08,BYTE DATA08)
{
BYTE Event08;
BYTE buff[6];
LCM_sSet_Position(X08,Y08);
buff[0]=0x80;
buff[1]=0x38;
buff[2]=0x80;
buff[3]=address;
buff[4]=0x40;
buff[5]=DATA08;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 6, &Event08 );
}
//====== LCM_sSet_Position =======
//[Group] LCM
//[Input]
//[Output]
//[Usage]
// Set GRAM Address
//=============================================
void LCM_sSet_Position(BYTE X08,BYTE Y08)
{
if(Y08 == FIRST_LINE)//First-Line
address = 0x80+X08;
else if(Y08 == SECOND_LINE) //Second Line
address = 0xC0+X08;
}
//=========== LCM_sWrite ============
//[Group] LCM
//[Input]
// Mode08 : Command(0) / Data(1)
// Data08 : Data to write to register
//[Usage]
// write command/data to dirive IC
//=====================================
BYTE LCM_sWrite(BYTE Mode08,BYTE Data08)
{
BYTE Event08;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, &Data08, 1, &Event08 );
return 0;
}
//=========== LCM_CharString ============
//[Group] LCM
//[Input]
// X08 : X position
// Y08 : Y position
// String08 : string data
//[Usage]
// write charater or string data to dirive IC
//=====================================
void LCM_CharString(BYTE X08,BYTE Y08,void * String08,BYTE Length)
{
char *str;
BYTE Event08;
BYTE i;
BYTE buff[21];
str = String08;
LCM_sSet_Position(X08,Y08);
buff[0]=0x80;
buff[1]=0x38;
buff[2]=0x80;
buff[3]=address;
buff[4]=0x40;
for(i=0; i<Length; i++)
{
buff[5+i]=*str;
str++;
if(*str == '\0')
break;
}
if(i<16)
{
for(;i<16;i++)
{
buff[5+i+1] = ' ';
}
}
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 21, &Event08 );
}
//=========== LCM_BacklightOnOff ========
//[Group] LCM(Sub-Function)
//[Input] x
//[Output] X
//[Usage]
// BL Control
//======================================
void LCM_BacklightOnOff(BYTE on_off)
{
BYTE BacklightStation=on_off;
if(BacklightStation)
{
GPIO_Write( GPIO_LCM_BL, 1 );
}
else
{
GPIO_Write( GPIO_LCM_BL, 0 );
}
}
//=========== LCM_sPower_On ========
//[Group] LCM(Sub-Function)
//[Input] x
//[Output] X
//[Usage]
// Power up drive IC
//Initialization 16*2characters LCM driver IC.
//======================================
void LCM_sPower_On(void)
{
BYTE Event08;
BYTE buff[2];
GPIO_Write(LCD_RST,1);
SYS_Delay(SYS_UNIT_1MS, 20);
GPIO_Write(LCD_RST,0);
SYS_Delay(SYS_UNIT_1MS, 20);
LCM_BacklightOnOff(1);
buff[0]=0x80;
buff[1]=0x38;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 2, &Event08 );
buff[0]=0x80;
buff[1]=0x06;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 2, &Event08 );
buff[0]=0x80;
buff[1]=0x0C;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 2, &Event08 );
buff[0]=0x80;
buff[1]=0x1C;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 2, &Event08 );
buff[0]=0x80;
buff[1]=0x01;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 2, &Event08 );
SYS_Idle(250);
buff[0]=0x80;
buff[1]=0x39;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 2, &Event08 );
buff[0]=0x80;
buff[1]=0x14;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 2, &Event08 );
buff[0]=0x80;
buff[1]=0x5F;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 2, &Event08 );
buff[0]=0x80;
buff[1]=0x6B;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 2, &Event08 );
buff[0]=0x80;
buff[1]=0x7F;
I2C_Write(0x7C, I2C_DEFAULT_EXT|I2C_IOMODE, buff, 2, &Event08 );
}
//=========== LCM_sPower_Off ========
//[Group] LCM(Sub-Function)
//[Input] x
//[Output] X
//[Usage]
// Power off drive IC
//======================================
void LCM_sPower_Off(void)
{
LCM_sWrite(_CMD_,0x08); //DISPLAY OFF
}