Analysis of Two Algorithms for LCD Displaying Chinese Characters

1.1. Reason

The original LCD display Chinese character function routine can only display Chinese characters with background, that is to say, if a Chinese character is to be displayed on the picture, a rectangular box will appear, and the background color is the color we set. It is not possible to display Chinese characters separately and not to display background requirements.

Analysis of Two Algorithms for LCD Displaying Chinese Characters

1.2. Code

//x, y character of the upper left corner of a character
/***
pointColor: the color of the character to display
backColor: the background color of the character
*pChineseData : character modulo data
***/
//fontSize : font size
Void LCD_ShowChinese(u16 x,u16 y,u8 fontSize,u16 pointColor,u16 backColor,u8 *pChineseData)
{
U32 i;
U8 j =0;
/************************************************* ****/
LCD_ILI9486_CMD(0x2A); //Set the starting address of the column address
LCD_ILI9486_Parameter(x>>8);
LCD_ILI9486_Parameter(x&(0xFF));
/ / Set the end address of the column address
LCD_ILI9486_Parameter((x+fontSize-1)>>8);
LCD_ILI9486_Parameter((x+fontSize-1)&(0xFF));
/************************************************* ****/
LCD_ILI9486_CMD (0x2B); / / set the starting address of the row address
LCD_ILI9486_Parameter(y>>8);
LCD_ILI9486_Parameter(y&(0xFF));
/ / Set the end address of the row address
LCD_ILI9486_Parameter((y+fontSize-1)>>8);
LCD_ILI9486_Parameter((y+fontSize-1)&(0xFF));
LCD_ILI9486_CMD (0x2C); / / write memory command
For(i=0;i<(fontSize*fontSize);i++)
{
If((*pChineseData)&(1<<(7-j)))
{
LCD_ILI9486_Parameter(pointColor);
}
Else
{
LCD_ILI9486_Parameter(backColor);
}
j = j +1;
If(j ==8)
{
j =0;
pChineseData++;
}
}
}

Analysis of Two Algorithms for LCD Displaying Chinese Characters

1.3. Solution ideas

Referring to the function of displaying characters on the LCD, instead of using one piece of data for continuous transmission, a method of drawing points is used, so that the place where the Chinese characters are not required to be displayed can be selected without the dot, so that the effect of hollowing out Chinese characters can be realized.

By processing the principle of one byte per loop, the coordinates corresponding to each bit of the current byte are calculated, and then the dot is selected or not hit in the corresponding coordinate.

1.4. Code

//x, y character of the upper left corner of a character
/***
pointColor: the color of the character to display
backColor: the background color of the character
*pChineseData : character modulo data
***/
//fontSize : font size: 16 means 16*16 font, 32 means 32*32 font, 64 means 64*64 font,
Void LCD_ShowChinese_fill(u16 x,u16 y,u8 fontSize,u16 pointColor,u16 backColor,u8 *pChineseData)
{
U32 i;
U8 j =0;
U8 k =0; //calculate the current byte is at the position of the line (the first few bytes)
U8 d =0; //calculate the current byte in the first few columns
For(i=0;i<(fontSize*fontSize);i++)
{
If((*pChineseData)&(1<<(7-j)))
{
LCD_Draw_Point(x+j+k*8, y+d, pointColor);
}
Else
{
LCD_Draw_Point(x+j+k*8, y+d, backColor);
}
j = j +1;
If(j ==8)
{
j =0;
pChineseData++;
k++; //calculate where the current byte is at the line if(k>=(fontSize/8))
{
k=0; //calculate where the current byte is at the line
d++; //calculate where the current byte is in the first few columns
}
}
}
}

Analysis of Two Algorithms for LCD Displaying Chinese Characters


Safety Controller

CSRME safety controller is developed for standard GB27607. By monitoring machine tool safety related equipment, the security of machine control system can meet the requirements of GB27607, and its security meets the requirements of ISO13849-1 (PLe) and IEC61508 (SIL3).

With rich interfaces, CSRME has limited programmable function. It can simultaneously replace many different types of safety control modules or safety PLCs, thus greatly simplifying the safety design of machine control systems and reducing cost.

Safety Controller,Modular Safety Controller,Safety Controller,Electrical Safety Controller,Programmable Logic Controller,Banner Safety Controller

Jining KeLi Photoelectronic Industrial Co.,Ltd , https://www.sdkelien.com

Posted on