Difference between revisions of "Chinese and English display modulo settings"

From LCD wiki
Jump to: navigation, search
(Created page with "== Molding software configuration == The font modulo software used in the test example is PCtoLCD2002. For detailed instructions on its use, see the following document: [http...")
 
 
(41 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Molding software configuration ==
+
== <font color="blue">Molding software configuration</font> ==
 
The font modulo software used in the test example is PCtoLCD2002. For detailed instructions on its use, see the following document:
 
The font modulo software used in the test example is PCtoLCD2002. For detailed instructions on its use, see the following document:
  
[http://www.lcdwiki.com/res/PublicFile/PCtoLCD2002_Use_Illustration_CN.pdf '''PCtoLCD2002 Instructions for use''']
+
[http://www.lcdwiki.com/res/PublicFile/PCtoLCD2002_Use_Illustration_EN.pdf '''PCtoLCD2002 Instructions for use''']
  
 
The PCtoLCD2002 software is specifically set as follows:
 
The PCtoLCD2002 software is specifically set as follows:
 +
*'''Font and size selection'''
 +
:[[File:MSP130W-002.jpg|750px]]
 +
:Mode needs to select '''字符模式'''
 +
:Fonts can be selected according to needs, such as selection '''宋体''' 
 +
:The word width and word height can be selected according to the needs. The font sizes commonly used in Chinese and English are as follows:
 +
:Chinese (word width x word height):'''16x16、24x24、32x32、48x48'''
 +
:English (character x word height):'''6x8、6x12、8x16、12x24、16x32、24x48('''The corresponding font size needs to be set to respectively'''12x8、12x12、16x16、24x24、32x32、48x48)'''
 +
:Modify the dot matrix size can be set according to requirements, generally set to '''0'''
  
Font selection '''宋体''', the dot size offset is '''0'''
+
*'''Font option setting'''
 
+
:There are many situations in the Chinese and English font option setting. Different settings and different code processing methods.
Word width and word height are selected: '''12x8, 16x16, 24x24, 32x32''' (English corresponds to '''6x8, 8x16, 12x24, 16x32''')
+
:Here is an example of the following settings, the subsequent function code is written based on this setting.
 +
:[[File:MSP130W-001.jpg|750px]]
 +
:Dot matrix format select '''阴码'''
 +
:Modal mode select '''逐行式'''
 +
:Molding trend select '''顺向(高位在前)'''
 +
:Output number system select '''十六进制数'''
 +
:Custom format select '''C51格式'''
  
[[File:MSP130W-001.jpg|750px]]
+
== <font color="blue">Bottom support function</font> ==
 
+
*'''LCD_SetWindows'''
Dot matrix format select '''阴码'''
+
:The function implementation differs depending on the driver IC (different drive ICs set coordinate values with different commands and principles),
 
+
:but the principle is basically the same, setting the start and end coordinates and setting a display area.
Modal mode select '''逐行式'''
+
:Examples are as follows (ILI9341 as an example)
 
 
Molding trend select '''顺向(高位在前)'''
 
 
 
Output number system select '''十六进制数'''
 
 
 
Custom format select '''C51格式'''
 
 
 
Other by default
 
 
 
[[File:MSP130W-002.jpg|750px]]
 
 
 
== 底层支撑函数 ==
 
'''*LCD_SetWindows'''
 
 
 
该函数实现因驱动IC而异(不同的驱动IC设置坐标值命令和原理有差异),但是原理基本一样,都是设置起始坐标和结束坐标,设置一块显示区域
 
 
 
举例如下(ILI9341为例)
 
 
{{code|1=
 
{{code|1=
 
void LCD_SetWindows(u16 xStar, u16 yStar,u16 xEnd,u16 yEnd)
 
void LCD_SetWindows(u16 xStar, u16 yStar,u16 xEnd,u16 yEnd)
Line 47: Line 44:
 
LCD_WR_DATA(0x00FF&yEnd);
 
LCD_WR_DATA(0x00FF&yEnd);
  
LCD_WriteRAM_Prepare(); //开始写入GRAM
+
LCD_WriteRAM_Prepare(); //Start writing to GRAM
 
}   
 
}   
  
 
}}
 
}}
  
'''*Lcd_WriteData_16Bit'''
+
*'''Lcd_WriteData_16Bit'''
 
+
:This function is to set the pixel color value into GRAM, and then display it
该函数就是往GRAM里面设置像素颜色值,然后显示出来
+
:Examples are as follows (ILI9341 as an example)
 
 
举例如下(ILI9341为例)
 
 
{{code|1=
 
{{code|1=
 
void Lcd_WriteData_16Bit(u16 Data)
 
void Lcd_WriteData_16Bit(u16 Data)
Line 68: Line 63:
 
}}
 
}}
  
'''*LCD_DrawPoint'''
+
*'''LCD_DrawPoint'''
 
+
:In fact, the LCD_SetWindows function and the Lcd_WriteData_16Bit function are used to display a pixel.
其实就是利用LCD_SetWindows函数和Lcd_WriteData_16Bit函数显示一个像素点
+
:Examples are as follows (ILI9341 as an example)
 
 
举例如下(ILI9341为例)
 
 
{{code|1=
 
{{code|1=
 
void LCD_DrawPoint(u16 x,u16 y)
 
void LCD_DrawPoint(u16 x,u16 y)
 
{
 
{
LCD_SetCursor(x,y);//设置光标位置
+
LCD_SetCursor(x,y);//Set the cursor position
 
Lcd_WriteData_16Bit(POINT_COLOR);  
 
Lcd_WriteData_16Bit(POINT_COLOR);  
 
}
 
}
 
}}
 
}}
  
== 英文取模 ==
+
== <font color="blue">English character modulo</font> ==
 
+
*'''[[#English character modulo|Important note]]'''
函数定义如下:
+
:1.Because in the program, the English characters that need to be displayed are searched according to the ASCII offset,
 +
::so the entire set of ASCII characters needs to be modeled.
 +
:2.'''If you do not need to use a character, you can set the modulo data of the character to {0}''',
 +
::as shown in the following example (take 6x8 size characters as an example)
 
{{code|1=
 
{{code|1=
void LCD_ShowChar(u16 x,u16 y,u16 fc, u16 bc, u8 num,u8 size,u8 mode)
+
const unsigned char asc2_0806[95][8]={
{
+
   ...  //This example is omitted, the actual application needs to be added
   u8 temp;
+
{0},/*"2",18*/ Do not use number 2
  u8 pos,t;
+
{0x00,0x00,0x78,0xB0,0x08,0x88,0x70,0x00},/*"3",19*/
  u16 colortemp=POINT_COLOR;
+
{0x00,0x00,0x30,0x50,0x90,0x78,0x10,0x00},/*"4",20*/
  num=num-' ';//得到偏移后的值
+
{0},/*"5",21*/ Do not use number 5
  LCD_SetWindows(x,y,x+size/2-1,y+size-1);//设置单个文字显示窗口
+
{0x00,0x00,0x70,0x80,0xF8,0x88,0x70,0x00},/*"6",22*/
  if(!mode) //非叠加方式
+
{0},/*"7",23*/ Do not use number 7
  {
+
{0x00,0x00,0xF8,0x88,0x70,0x88,0x78,0x00},/*"8",24*/
      for(pos=0;pos<size;pos++)
+
{0},/*"9",25*/ Do not use number 9
      {
+
   ..//This example is omitted, the actual application needs to be added
  if(size==12)
+
<nowiki>}</nowiki>
          {
 
              temp=asc2_1206[num][pos];//调用1206字体
 
  }
 
          else
 
          {
 
              temp=asc2_1608[num][pos]; //调用1608字体
 
          }
 
  for(t=0;t<size/2;t++)
 
          {                
 
              if(temp&(0x80>>t))
 
              {
 
                Lcd_WriteData_16Bit(fc);
 
              }  
 
      else
 
              {
 
                Lcd_WriteData_16Bit(bc);
 
      }
 
          }
 
      }
 
  }
 
  else//叠加方式
 
  {
 
      for(pos=0;pos<size;pos++)
 
      {
 
  if(size==12)
 
          {
 
              temp=asc2_1206[num][pos];// 调用1206字体
 
  }
 
          else
 
          {
 
              temp=asc2_1608[num][pos]; //调用1608字体
 
  }
 
  for(t=0;t<size/2;t++)
 
          { 
 
      POINT_COLOR=fc;             
 
      if(temp&(0x80>>t))
 
              {
 
                LCD_DrawPoint(x+t,y+pos);//画一个点 
 
      }
 
          }
 
      }
 
   }
 
  POINT_COLOR=colortemp;
 
  LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复窗口为全屏   
 
}
 
 
}}
 
}}
 +
:3.The ASCII characters are as follows (the first space is also included):
 +
::ASCII characters: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
 +
:4.The English modulo data fonts are all '''Default'''
  
此函数包含了12x6和16x8两种英文字体设置。
+
*'''The different sizes of English character modulo description'''
 +
:*[http://www.lcdwiki.com/6x8_English_font_modulo_description '''6x8 English font modulo description''']
 +
:*[http://www.lcdwiki.com/6x12_English_font_modulo_description '''6x12 English font modulo description''']
 +
:*[http://www.lcdwiki.com/8x16_English_font_modulo_description '''8x16 English font modulo description''']
 +
:*[http://www.lcdwiki.com/12x24_English_font_modulo_description '''12x24 English font modulo description''']
 +
:*[http://www.lcdwiki.com/16x32_English_font_modulo_description '''16x32 English font modulo description''']
 +
:*[http://www.lcdwiki.com/24x48_English_font_modulo_description '''24x48 English font modulo description''']
 +
:*[http://www.lcdwiki.com/32x64_English_font_modulo_description '''32x64 English font modulo description''']
 +
:*[http://www.lcdwiki.com/48x96_English_font_modulo_description '''48x96 English font modulo description''']
 +
:*[http://www.lcdwiki.com/64x128_English_font_modulo_description '''64x128 English font modulo description''']
  
包含了两种显示模式:叠加模式和非叠加模式。
 
  
叠加模式:字体不带背景色,直接叠加显示到原来显示的内容上
+
== <font color="blue">Chinese character modulo</font> ==
 
+
*'''[[#Chinese character modulo|Important note]]'''
非叠加模式:字体带有背景色,显示时会将原来显示的内容覆盖掉
+
:1.When displaying Chinese characters, the modulo data is obtained by querying the GBK code that needs to display Chinese characters;
 +
:2.After the Chinese character is successfully modulo, the corresponding relationship between the Chinese character GBK code and the modulo data is saved through an array of structures.
 +
:3.The structure is defined as follows:
 +
{{code|1=
 +
//16x16 Chinese font structure definition
 +
typedef struct
 +
{
 +
      unsigned char Index[2]; //Store Chinese character GBK code
 +
      char Msk[32]; //Store Chinese character modulo data
 +
}typFNT_GB16;  //Structure name can be defined by yourself
  
== 中文取模 ==
+
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'''A、16x16中文字体显示函数定义如下:'''
+
//24x24 Chinese font structure definition
{{code|1=
+
typedef struct
void GUI_DrawFont16(u16 x, u16 y, u16 fc, u16 bc, u8 *s,u8 mode)
 
 
{
 
{
  u8 i,j;
+
       unsigned char Index[2]; //Store Chinese character GBK code
  u16 k;
+
      char Msk[72]; //Store Chinese character modulo data
  u16 HZnum;
+
}typFNT_GB24;  //Structure name can be defined by yourself
  u16 x0=x;
 
  HZnum=sizeof(tfont16)/sizeof(typFNT_GB16); //自动统计汉字数目
 
  for (k=0;k<HZnum;k++)
 
  {
 
       if((tfont16[k].Index[0]==*(s))&&(tfont16[k].Index[1]==*(s+1)))
 
      {
 
          LCD_SetWindows(x,y,x+16-1,y+16-1);
 
  for(i=0;i<16*2;i++)
 
          {
 
for(j=0;j<8;j++)
 
{
 
    if(!mode) //非叠加方式
 
    {
 
  if(tfont16[k].Msk[i]&(0x80>>j))
 
                          {
 
                              Lcd_WriteData_16Bit(fc);
 
                          }  
 
                          else
 
                          {
 
                              Lcd_WriteData_16Bit(bc);
 
  }
 
    }
 
    else
 
    {
 
  POINT_COLOR=fc;
 
  if(tfont16[k].Msk[i]&(0x80>>j))
 
                          {
 
                              LCD_DrawPoint(x,y);//画一个点
 
  }
 
  x++;
 
  if((x-x0)==16)
 
  {
 
      x=x0;
 
      y++;
 
      break;
 
  }
 
    }
 
        }
 
    }
 
}  
 
continue;  //找到对应点阵字库立即退出,防止多个汉字重复取模带来影响
 
    }
 
    LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复窗口为全屏
 
}
 
}}
 
  
'''B、24x24中文字体显示函数定义如下:'''
+
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
{{code|1=
+
//32x32 Chinese font structure definition
void GUI_DrawFont24(u16 x, u16 y, u16 fc, u16 bc, u8 *s,u8 mode)
+
typedef struct
 
{
 
{
    u8 i,j;
+
      unsigned char Index[2]; //Store Chinese character GBK code
    u16 k;
+
      char Msk[128]; //Store Chinese character modulo data
    u16 HZnum;
+
}typFNT_GB32;  //Structure name can be defined by yourself
    u16 x0=x;
 
    HZnum=sizeof(tfont24)/sizeof(typFNT_GB24); //自动统计汉字数目
 
    for (k=0;k<HZnum;k++)
 
    {
 
        if((tfont24[k].Index[0]==*(s))&&(tfont24[k].Index[1]==*(s+1)))
 
        {
 
            LCD_SetWindows(x,y,x+24-1,y+24-1);
 
    for(i=0;i<24*3;i++)
 
    {
 
  for(j=0;j<8;j++)
 
  {
 
if(!mode) //非叠加方式
 
{
 
                              if(tfont24[k].Msk[i]&(0x80>>j))
 
                              {
 
                                  Lcd_WriteData_16Bit(fc);
 
      }
 
                              else
 
                              {
 
                                  Lcd_WriteData_16Bit(bc);
 
      }
 
                        }
 
        else
 
        {
 
      POINT_COLOR=fc;
 
      if(tfont24[k].Msk[i]&(0x80>>j))
 
                              {
 
                                  LCD_DrawPoint(x,y);// 画一个点
 
      }
 
                              x++;
 
      if((x-x0)==24)
 
      {
 
  x=x0;
 
  y++;
 
  break;
 
      }
 
        }
 
  }
 
      }
 
}  
 
continue;  //找到对应点阵字库立即退出,防止多个汉字重复取模带来影响
 
    }
 
    LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);// 恢复窗口为全屏
 
}
 
}}
 
  
'''C、32x32中文字体显示函数定义如下:'''
+
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
{{code|1=
+
//48x48 Chinese font structure definition
void GUI_DrawFont32(u16 x, u16 y, u16 fc, u16 bc, u8 *s,u8 mode)
+
typedef struct
 
{
 
{
    u8 i,j;
+
      unsigned char Index[2]; //Store Chinese character GBK code
    u16 k;
+
      char Msk[288]; //Store Chinese character modulo data
    u16 HZnum;
+
}typFNT_GB48; //Structure name can be defined by yourself
    u16 x0=x;
 
    HZnum=sizeof(tfont32)/sizeof(typFNT_GB32); //自动统计汉字数目
 
    for (k=0;k<HZnum;k++)
 
    {
 
if ((tfont32[k].Index[0]==*(s))&&(tfont32[k].Index[1]==*(s+1)))
 
{
 
              LCD_SetWindows(x,y,x+32-1,y+32-1);
 
      for(i=0;i<32*4;i++)
 
      {
 
    for(j=0;j<8;j++)
 
            {
 
  if(!mode) //非叠加方式
 
  {
 
if(tfont32[k].Msk[i]&(0x80>>j))
 
                                {
 
      Lcd_WriteData_16Bit(fc);
 
                                }
 
else
 
                                {
 
                                      Lcd_WriteData_16Bit(bc);
 
}
 
                          }
 
  else
 
  {
 
POINT_COLOR=fc;
 
        if(tfont32[k].Msk[i]&(0x80>>j))
 
                                {
 
                                      LCD_DrawPoint(x,y);// 画一个点
 
}
 
                x++;
 
if((x-x0)==32)
 
{
 
      x=x0;
 
      y++;
 
      break;
 
}
 
  }
 
      }
 
}
 
  }  
 
  continue;  //找到对应点阵字库立即退出,防止多个汉字重复取模带来影响
 
    }
 
    LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);// 恢复窗口为全屏
 
}
 
 
}}
 
}}
  
以上三个函数分别是对16x16、24x24、32x32汉字进行显示设置。
+
*'''The different sizes of Chinese modulo description'''
 
+
:*[http://www.lcdwiki.com/16x16_Chinese_font_modulo_description '''16x16 Chinese font modulo description''']
包含了两种显示模式:叠加模式和非叠加模式。
+
:*[http://www.lcdwiki.com/24x24_Chinese_font_modulo_description '''24x24 Chinese font modulo description''']
 
+
:*[http://www.lcdwiki.com/32x32_Chinese_font_modulo_description '''32x32 Chinese font modulo description''']
叠加模式:字体不带背景色,直接叠加显示到原来显示的内容上
+
:*[http://www.lcdwiki.com/48x48_Chinese_font_modulo_description '''48x48 Chinese font modulo description''']
 
 
非叠加模式:字体带有背景色,显示时会将原来显示的内容覆盖掉
 
  
 
[[#top|BACK TO TOP]]
 
[[#top|BACK TO TOP]]

Latest revision as of 14:05, 12 June 2023

Molding software configuration

The font modulo software used in the test example is PCtoLCD2002. For detailed instructions on its use, see the following document:

PCtoLCD2002 Instructions for use

The PCtoLCD2002 software is specifically set as follows:

  • Font and size selection
MSP130W-002.jpg
Mode needs to select 字符模式
Fonts can be selected according to needs, such as selection 宋体
The word width and word height can be selected according to the needs. The font sizes commonly used in Chinese and English are as follows:
Chinese (word width x word height):16x16、24x24、32x32、48x48
English (character x word height):6x8、6x12、8x16、12x24、16x32、24x48(The corresponding font size needs to be set to respectively12x8、12x12、16x16、24x24、32x32、48x48)
Modify the dot matrix size can be set according to requirements, generally set to 0
  • Font option setting
There are many situations in the Chinese and English font option setting. Different settings and different code processing methods.
Here is an example of the following settings, the subsequent function code is written based on this setting.
MSP130W-001.jpg
Dot matrix format select 阴码
Modal mode select 逐行式
Molding trend select 顺向(高位在前)
Output number system select 十六进制数
Custom format select C51格式

Bottom support function

  • LCD_SetWindows
The function implementation differs depending on the driver IC (different drive ICs set coordinate values with different commands and principles),
but the principle is basically the same, setting the start and end coordinates and setting a display area.
Examples are as follows (ILI9341 as an example)
void LCD_SetWindows(u16 xStar, u16 yStar,u16 xEnd,u16 yEnd)
{	
	LCD_WR_REG(lcddev.setxcmd);	
	LCD_WR_DATA(xStar>>8);
	LCD_WR_DATA(0x00FF&xStar);		
	LCD_WR_DATA(xEnd>>8);
	LCD_WR_DATA(0x00FF&xEnd);

	LCD_WR_REG(lcddev.setycmd);	
	LCD_WR_DATA(yStar>>8);
	LCD_WR_DATA(0x00FF&yStar);		
	LCD_WR_DATA(yEnd>>8);
	LCD_WR_DATA(0x00FF&yEnd);

	LCD_WriteRAM_Prepare();	//Start writing to GRAM		
}
  • Lcd_WriteData_16Bit
This function is to set the pixel color value into GRAM, and then display it
Examples are as follows (ILI9341 as an example)
void Lcd_WriteData_16Bit(u16 Data)
{	
      LCD_CS_CLR;
      LCD_RS_SET;  
      SPI_WriteByte(SPI2,Data>>8);
      SPI_WriteByte(SPI2,Data);
      LCD_CS_SET;
}
  • LCD_DrawPoint
In fact, the LCD_SetWindows function and the Lcd_WriteData_16Bit function are used to display a pixel.
Examples are as follows (ILI9341 as an example)
void LCD_DrawPoint(u16 x,u16 y)
{
	LCD_SetCursor(x,y);//Set the cursor position
	Lcd_WriteData_16Bit(POINT_COLOR); 
}

English character modulo

1.Because in the program, the English characters that need to be displayed are searched according to the ASCII offset,
so the entire set of ASCII characters needs to be modeled.
2.If you do not need to use a character, you can set the modulo data of the character to {0},
as shown in the following example (take 6x8 size characters as an example)
const unsigned char asc2_0806[95][8]={
   ...  //This example is omitted, the actual application needs to be added
{0},/*"2",18*/ Do not use number 2
{0x00,0x00,0x78,0xB0,0x08,0x88,0x70,0x00},/*"3",19*/
{0x00,0x00,0x30,0x50,0x90,0x78,0x10,0x00},/*"4",20*/
{0},/*"5",21*/ Do not use number 5
{0x00,0x00,0x70,0x80,0xF8,0x88,0x70,0x00},/*"6",22*/
{0},/*"7",23*/ Do not use number 7
{0x00,0x00,0xF8,0x88,0x70,0x88,0x78,0x00},/*"8",24*/
{0},/*"9",25*/ Do not use number 9
   ...  //This example is omitted, the actual application needs to be added
}
3.The ASCII characters are as follows (the first space is also included):
ASCII characters: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
4.The English modulo data fonts are all Default
  • The different sizes of English character modulo description


Chinese character modulo

1.When displaying Chinese characters, the modulo data is obtained by querying the GBK code that needs to display Chinese characters;
2.After the Chinese character is successfully modulo, the corresponding relationship between the Chinese character GBK code and the modulo data is saved through an array of structures.
3.The structure is defined as follows:
//16x16 Chinese font structure definition
typedef struct 
{
       unsigned char Index[2];	//Store Chinese character GBK code
       char Msk[32]; //Store Chinese character modulo data
}typFNT_GB16;  //Structure name can be defined by yourself

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//24x24 Chinese font structure definition
typedef struct 
{
       unsigned char Index[2];	//Store Chinese character GBK code
       char Msk[72]; //Store Chinese character modulo data
}typFNT_GB24;  //Structure name can be defined by yourself

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//32x32 Chinese font structure definition
typedef struct 
{
       unsigned char Index[2];	//Store Chinese character GBK code
       char Msk[128]; //Store Chinese character modulo data
}typFNT_GB32;  //Structure name can be defined by yourself

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//48x48 Chinese font structure definition
typedef struct 
{
       unsigned char Index[2];	//Store Chinese character GBK code
       char Msk[288]; //Store Chinese character modulo data
}typFNT_GB48; //Structure name can be defined by yourself
  • The different sizes of Chinese modulo description

BACK TO TOP