📄 lcdtest.c
字号:
// Send a string to LCD screen
void SendStr(uint8 *ptString)
{
while((*ptString)!='\0')
{
SendByte(iDat, *ptString++);
DelayMs(20);
}
}
// Move Cursor or display
void Move(uint8 dir)
{
SendByte(iCmd, dir);
}
// Goto specific location
void Gotoxy(uint8 Row, uint8 Col)
{
#if defined(LCD_L2)
switch (Row)
{
case 2:
SendByte(iCmd, LCD_L2 + Col); break;
#if defined(LCD_L3)
case 3:
SendByte(iCmd, LCD_L3 + Col); break;
#endif
#if defined(LCD_L4)
case 4:
SendByte(iCmd, LCD_L4 + Col); break;
#endif
default:
SendByte(iCmd, LCD_L1 + Col); break;
}
#endif
}
// Clear LCD screen
void Clear(void)
{
SendByte(iCmd, LCD_CLS);
DelayUs(2000);
// 2ms delay is Necessary after sending LCD_CLS command !!!
}
// Tile LCD Screen with one data
void Tile(uint8 dByte)
{
uint8 k;
SendByte(iCmd, LCD_L1);
for (k = 0; k < 48; k++)
{
if (k == 16)
{
SendByte(iCmd, LCD_L2);
}
if (k == 32)
{
SendByte(iCmd, LCD_L3);
}
if (k == 48)
{
SendByte(iCmd, LCD_L4);
}
SendByte(iDat, dByte);
}
}
// Fill CGRAM with array CGRAM[]
void FillCGRAM(void)
{
uint8 i;
//SendByte(iCmd, 0x38);
SendByte(iCmd, LCD_CGRAM_ADDR);
for (i = 0; i < LCD_CGMAX; i++)
{
SendByte(iDat, CGRAM[i]);
}
}
// Show All patterns in CGRAM
void ShowCGRAM(void)
{
uint8 i,k;
for (i = 0; i < 8; i++)
{
SendByte(iCmd, LCD_L1);
for (k = 0; k < LCD_CHAR; k++)
{
#if defined(LCD_L2)
switch (k)
{
case LCD_COL:
SendByte(iCmd, LCD_L2); break;
#if defined(LCD_L3)
case LCD_COL*2:
SendByte(iCmd, LCD_L3); break;
#endif
#if defined(LCD_L4)
case LCD_COL*3:
SendByte(iCmd, LCD_L4); break;
#endif
default:
break;
}
#endif
SendByte(iDat, i);
}
delay1s();
delay500ms();
Clear();
}
}
// Call built-in Charactors
void CallBuiltinChar(void)
{
uint8 i, k;
for (i = 0; i < LCD_COL; i += LCD_ROW)
{
SendByte(iCmd, LCD_L1);
for (k = 0; k < LCD_CHAR; k++)
{
#if defined(LCD_L2)
switch (k)
{
case LCD_COL:
SendByte(iCmd, LCD_L2); break;
#if defined(LCD_L3)
case LCD_COL*2:
SendByte(iCmd, LCD_L3); break;
#endif
#if defined(LCD_L4)
case LCD_COL*3:
SendByte(iCmd, LCD_L4); break;
#endif
default:
break;
}
#endif
SendByte(iDat, k + LCD_COL*i);
}
delay1s();
delay500ms();
Clear();
}
}
//===============================================
void test(void)
{
FillCGRAM();
ShowCGRAM();
Gotoxy(2, 1);
SendStr("LCD dispaly OK!");
delay1s();
delay1s();
Clear();
CallBuiltinChar();
/*
while(1)
{
KeyPressHandler();
}
*/
Lcd_Command(0x83); //设置显示位址
SendStr("======@_@======"); //显示字符串
Lcd_Command(0x97); //设置显示位址
SendStr("welcome to vigour"); //显示字符串
DelayMs(1000); //延迟1秒
Lcd_Command(0x01); //清除显示器
Lcd_Command(0x83); //设置显示位址
SendStr("======^_^======"); //显示字符串
Lcd_Command(0x94); //设置显示位址
SendStr("thank you very much"); //显示字符串
DelayMs(1000); //延迟
Lcd_Command(0x01); //清除显示器
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -