|
/***************************************************************************************
** 函數名稱: void LCD_1602_write_string(unsigned char x,unsigned char y,unsigned char *s)
** 功能描述: 寫入字符串到第x(0-1)行y(0-15)列
** 輸 入: unsigned x 第x(0-1)行;unsigned char y(0-15)列;unsigned char *s要寫ude字符串。
** 輸 出: 無
** 全局變量: 無
** 調用模塊: LCD_Write_Command( ),LCD_Write_DATA()
** 說 明: 未寫下標越界檢查 x,y起點均為0,無論是單字符或字符串均用雙引擴號
****************************************************************************************/
void LCD_1602_write_string(unsigned char x,unsigned char y,unsigned char *s)
{
unsigned char i;
i=15-y;
if(x)
{ //如果是第二行
y+=0xc0; //地址是偏移量y加第二行首地址0xC0
}
else
{ //如果是第一行
y+=0x80; //地址是偏移量y加第一行首地址0x80
LCD_Write_Command(y); //向LCD寫第一行地址命令
while(*s)
{ //直到字符串讀到最后一位
LCD_Write_DATA(*s++); //寫字符數據到LCD
if(y++>=0x8f)
{ //y自加,如果第一行寫完
y=0xc0; //地址y設定為第二行起頭
i=15; //最大寫入次數
break; //如果第一行寫完則強退本次循環
}
}
}
LCD_Write_Command(y);
while(*s)
{
LCD_Write_DATA(*s++);
if(!(i--)) break;
}
}
|
|