📄 ra8803.c
字号:
//==============================================================================
//Subroutine: Align On
//Function:
//==============================================================================
void LCD_AlignOn(void)
{
uchar temp;
temp = LCD_CmdRead(WCCR);
temp |= 0x40; //cSetb6;
LCD_CmdWrite(WCCR, temp);
}
void LCD_AlignOff(void)
{
uchar temp;
temp = LCD_CmdRead(WCCR);
temp &= 0xbf; //cClrb6;
LCD_CmdWrite(WCCR, temp);
}
//==============================================================================
//Subroutine: Auto Fill
//Function:
//==============================================================================
void LCD_FillOn(void)
{
uchar temp;
temp = LCD_CmdRead(FNCR);
temp |= 0x08; //cSetb3;
LCD_CmdWrite(FNCR, temp);
}
//==============================================================================
//Subroutine: Cursor Blink On
//Function:
//==============================================================================
void LCD_CurBlk(void)
{
uchar temp;
temp = LCD_CmdRead(WCCR);
temp |= 0x02; //cSetb1;
LCD_CmdWrite(WCCR, temp);
}
void LCD_NoCurBlk(void)
{
uchar temp;
temp = LCD_CmdRead(WCCR);
temp &= 0xfd; //cClrb1;
LCD_CmdWrite(WCCR, temp);
}
//==============================================================================
//Subroutine: Cursor Height
//Function:
//==============================================================================
void LCD_CurHei(uchar buf)
{
uchar temp;
buf = buf << 4;
buf = buf & 0xF0;
temp = LCD_CmdRead(DLCH);
temp = (temp & 0x0F) | buf;
LCD_CmdWrite(DLCH, temp);
}
//==============================================================================
//Subroutine: Line Distance
//Function:
//==============================================================================
void LCD_LineDis(uchar buf)
{
uchar temp;
buf = buf & 0x0F;
temp = LCD_CmdRead(DLCH);
temp = (temp & 0xF0) | buf;
LCD_CmdWrite(DLCH, temp);
}
//==============================================================================
//Subroutine: Font Size
//Function:
//==============================================================================
void LCD_FontSize(uchar buf)
{
uchar temp;
buf = buf << 4;
temp = (buf & 0xF0) | (0x0F);
LCD_CmdWrite(FVHT, temp);
}
//==============================================================================
//Subroutine: Software Reset
//Function:
//==============================================================================
void LCD_SWRst(void)
{
uchar temp;
temp = LCD_CmdRead(WLCR);
temp |= 0x20; //cSetb5;
LCD_CmdWrite(WLCR, temp);
}
//==============================================================================
//Subroutine: LCD_Clear
//Function: Clear LCD DDRAM
//==============================================================================
void LCD_Clear(void)
{
LCD_CmdWrite(PNTR, 0x00);
LCD_FillOn();
Delay_1ms(100);
}
//==============================================================================
//Subroutine: ADC On/Off
//Function:
//==============================================================================
#define ADC_On() LCD_CmdWrite(TPCR, 0xC0)
#define ADC_Off() LCD_CmdWrite(TPCR, 0x10)
//==============================================================================
//Subroutine: Get Panel Touch
//Function:
//==============================================================================
uchar ADC_Touch(void)
{
uchar temp, tempT;
temp = LCD_CmdRead(TPCR);
temp &= 0xfe; //cClrb0;
temp &= 0xfd; //cClrb1;
temp &= 0xfb; //cClrb2;
temp |= 0x08; //cSetb3;
LCD_CmdWrite(TPCR, temp);
Delay_1ms(2);
tempT=LCD_CmdRead(TPSR);
temp &= 0xf7; //cClrb3;
LCD_CmdWrite(TPCR, temp);
tempT = tempT & 0x40;
if(tempT == 0x40) return 0x01;
else return 0x00;
}
//==============================================================================
//Subroutine: Get ADC X/Y
//Function:
//==============================================================================
uchar ADC_X(void)
{
uchar temp, tempX;
temp = LCD_CmdRead(TPCR);
temp &= 0xfe; //cClrb0;
LCD_CmdWrite(TPCR, temp);
temp &= 0xfd; //cClrb1;
LCD_CmdWrite(TPCR, temp);
temp |= 0x04; //cSetb2;
LCD_CmdWrite(TPCR, temp);
temp |= 0x08; //cSetb3;
LCD_CmdWrite(TPCR, temp);
Delay_1ms(1);
tempX=LCD_CmdRead(TPXR);
return tempX;
}
uchar ADC_Y(void)
{
uchar temp, tempY;
temp = LCD_CmdRead(TPCR);
temp &= 0xfb; //cClrb2;
LCD_CmdWrite(TPCR, temp);
temp &= 0xf7; //cClrb3;
LCD_CmdWrite(TPCR, temp);
temp |= 0x01; //cSetb0;
LCD_CmdWrite(TPCR, temp);
temp |= 0x02; //cSetb1;
LCD_CmdWrite(TPCR, temp);
Delay_1ms(1);
tempY=LCD_CmdRead(TPYR);
return tempY;
}
//*******************************************************************************//
// *** Key_scan 的判断子程序 ****************************************************//
//*******************************************************************************//
uchar Key_TP_ststus(void) small
{
unsigned char temp;
temp = LCD_CmdRead(0xA0); // 读取缓存器[0xA0],并判断Bit7 是否为”1”
temp &= 0x80;
LCD_CmdWrite(0xA1,0xF1); //设定缓存器(Kscr)
// delay(5000); //延迟时间
if(temp) return 1; // 若缓存器[0xA0]-Bit7 = 1,表示有按键输入
else return 0; // 若缓存器[0xA0]-Bit7 = 0,表示无按键输入
}
//*******************************************************************************//
// *** 取得按键输入的值子程序 ****************************************************//
//*******************************************************************************//
unsigned char FindKey(void)
{
unsigned char Key_Out;
unsigned char Key_In;
unsigned char Key_Number;
Key_Out = LCD_CmdRead(0xa2); //读取按键输出缓存器
Key_In = LCD_CmdRead(0xa3); //读取按键输入缓存器
switch(Key_Out) //扫描判断方式,并设定相对应的按键数值
{
case 0xfe: Key_Number = 1; break;
case 0xfd: Key_Number = 9; break;
case 0xfb: Key_Number = 17; break;
case 0xf7: Key_Number = 25; break;
case 0xef: Key_Number = 33; break;
case 0xdf: Key_Number = 41; break;
case 0xbf: Key_Number = 49; break;
case 0x7f: Key_Number = 57; break;
default: break;
}
switch(Key_In) //扫描判断方式,并设定相对应的按键数值
{
case 0xfe: Key_Number += 0; break;
case 0xfd: Key_Number += 1; break;
case 0xfb: Key_Number += 2; break;
case 0xf7: Key_Number += 3; break;
case 0xef: Key_Number += 4; break;
case 0xdf: Key_Number += 5; break;
case 0xbf: Key_Number += 6; break;
case 0x7f: Key_Number += 7; break;
default: break;
}
return Key_Number; // 回传输入按键的数值
}
//==============================================================================
//Subroutine: Show Hex
//Function:
//==============================================================================
void Print_Hex(uchar buf)
{
uchar temp;
temp = buf;
temp = (temp >>4) & 0x0F;
if(temp < 0x0A) temp |= 0x30;
else temp += 0x37;
LCD_DataWrite(temp);
temp = buf;
temp = temp & 0x0F;
if(temp < 0x0A) temp |= 0x30;
else temp += 0x37;
LCD_DataWrite(temp);
}
//==============================================================================
//Subroutine: LCD_PrintStr 1
//Function:
//==============================================================================
void LCD_PrintStrD100ms(uchar *ptr, uchar x, uchar y, uchar time)
{
LCD_GotoXY(x, y);
while(*ptr != 0)
{
LCD_DataWrite(*ptr);
ptr++;
Delay_1ms(time);
}
}
//==============================================================================
//Subroutine: LCD_PrintStr 2
//Function:
//==============================================================================
void LCD_PrintStr(uchar *ptr, uchar XSize)
{
uchar temp;
for(temp=0 ; temp<XSize ; temp++)
{
LCD_DataWrite(*ptr);
ptr++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -