函数名称CD_DispOneMaxChar
功 能://以16*24点阵显示一个字符
参 数:chr: 要显示的字符
xStart: 要显示字符的起始X坐标
yStart: 要显示字符的起始Y坐标
fColor: 字符前景色
bColor: 字符背景色
返 回 值:无
*************************************************************/
void LCD_DispOneMaxChar(unsigned char chr,unsigned int xStart,unsigned int yStart,
unsigned long fColor,unsigned long bColor)
{
unsigned char i,j;
unsigned char nCols;
unsigned char nRows;
unsigned char nBytes;
unsigned int PixelRow;
unsigned int Mask;
unsigned long Word;
unsigned int *pFont;
unsigned int *pChar;
write_reg(0x03,0x0000); //Entry Mode Set.
// get pointer to the beginning of the selected font table
pFont = (unsigned int *)FONT16x24;
// get the nColumns, nRows and nBytes
nCols = *pFont;
nRows = *(pFont + 1);
nBytes = *(pFont + 2);
// get pointer to the first byte of the desired character
pChar = pFont + nBytes*(chr - 0x1F);
//define display window
Lcd_SetBox(xStart,yStart,nCols,nRows,0,0);
// loop on each row, working backwards from the top to the bottom
for (i = 0; i < nRows; i++)
{
// copy pixel row from font table and then increment row
PixelRow = *pChar++;
// loop on each pixel in the row (left to right)
// Note: we do one pixel each loop
Mask = 0x0001;
for (j = 0; j < nCols; j++)
{
// if pixel bit set, use foreground color; else use the background color
if ((PixelRow & Mask) == 0)
Word = bColor;
else
Word = fColor;
Mask = Mask << 1;
rw_data_prepare();
write_data(Word);
}
}
}
/*************************************************************
函数名称CD_DispMaxStr
功 能:以16*24点阵显示字符串
参 数:pStr: 字符串地址
xStart: 要显示字符串的起始X坐标
yStart: 要显示字符串的起始Y坐标
fColor: 字符前景色
bColor: 字符背景色
返 回 值:无
*************************************************************/
void LCD_DispMaxStr(unsigned char *pStr,unsigned int xStart,unsigned int yStart,unsigned long fColor,unsigned long bColor)
{
// loop until null-terminator is seen
while (*pStr != 0x00)
{
// draw the character
LCD_DispOneMaxChar(*pStr++,xStart,yStart,fColor,bColor);
// advance the X position
xStart += 16;
// bail out if X exceeds LCD_HEIGHT
if (xStart > LCD_HEIGHT)
break;
}
} |