当前位置:网站首页>The Chinese and English dot matrix character display principle of the 111th blog of the fledgling Xiao Li

The Chinese and English dot matrix character display principle of the 111th blog of the fledgling Xiao Li

2022-07-23 07:54:00 Fledgling Xiao Li

Character Introduction

Characters are divided into Chinese characters and English characters , English characters are what we often say ASCII character , Chinese characters refer to Chinese characters and some commonly used Chinese characters and symbols

Display principle

In fact, to display a character on an embedded display device is essentially punctuation , By drawing the shape of this character in a certain area, the shape of this character is displayed .

English characters

 Insert picture description here
Here with this character “H” For example , It can be found in total 816 A character is displayed in the small grid of , The first line is not displayed , The second line also does not show , The third line is the same , The fourth line is displayed or not If we code the display as 1, Code the places that are not displayed as 0 Then the first row of data can be bynema 00000000, The second line of data is also 00000000, The third line is the same 00000000, In the fourth row 111001111, In this way, 16 rows of data can be represented in this way , Then the data of these sixteen lines is H The font encoding data of this character , We usually write these data in hexadecimal , For example, the first line is written 0x00, The second line is also 0x00, By analogy , With 16 For example, a total of 816 A grid point is 16 Bytes of data , Because a byte is eight grid points .

Chinese characters

 Insert picture description here
Same thing , But the difference is that the same character occupies different lattice points , The number of bytes needed here becomes 16*16 individual , The number of bytes has also become 32 Bytes . Similarly, the font data is 32 Bytes .

ASCII Character set

hold ASCII Font of characters ( Regular byte data ) Making a set is ASCII Character set .

Chinese character set

Put the font of Chinese characters ( Regular byte data ) Making a set is Chinese character set . Common Chinese character sets are GB2312 Character set GBK Character sets and so on .

Library files

Write the data of the character set into a file, which is called a font file , There are separate ASCII Font files also have , There is also a separate Chinese font file , There is also a character file composed of the two .

 Insert picture description here

Reading and displaying character files

 Insert picture description here

  • English character display

  •  Insert picture description here

  • Chinese character display
     Insert picture description here

According to the effect

english
 Insert picture description here
chinese
 Insert picture description here

Display code

int main(void)
{
    
	char ch = 'A'; 
	char BUFF[2] = {
    " Li "};  
	uint8_t AB     = 0x00;
	uint8_t CD     = 0x00; 
	int ZK_NUM     = 0; 
	int GB2312_NUM = 0;
	int ASCII_NUM  = 0;
	char *p = &BUFF[0];
    int i   = 0;
	AB = (uint8_t)*p;
	CD = ((uint8_t)*(p+1));
	//GB2312_NUM = ((AB-0xa1)*94+(CD-0xa0)-1); 
	printf("%X %X %d \r\n",AB,CD,GB2312_NUM);  //fseek(fp,(1445*32),SEEK_SET);
	char Table_Text[32]={
    0};
	//FILE *fp0 = fopen("C:/Users/23206/Desktop/ASC16.bin","r+");
	//FILE *fp1 = fopen("C:/Users/23206/Desktop/HZK16.bin","r+");
	FILE *fp = fopen("C:/Users/23206/Desktop/ZK16.bin","r+");
	for(ZK_NUM = 128;ZK_NUM<150;ZK_NUM++) 
	{
    
		printf("\r\n*GB2312_16_16_ZK The first %-4d Character font *\n",ZK_NUM);
		printf("\n");
		if(ZK_NUM*16<0x00000806)
		{
    
		printf("\r\n*GB2312_16_16_ZK The first %-4d English font *\n",ASCII_NUM);
			fseek(fp,(ASCII_NUM*16),SEEK_SET);
			fgets(&Table_Text[0],16+1,fp); 
			Printf_ASCII(&Table_Text[0],16);
			ASCII_NUM++;
			printf("ASCII_NUM = %d\r\n",ASCII_NUM);
		}
		else
		{
    
		printf("\r\n*GB2312_16_16_ZK The first %-4d Chinese font *\n",GB2312_NUM);
			fseek(fp,((GB2312_NUM)*32+0x00000806),SEEK_SET);
			fgets(&Table_Text[0],32+1,fp); 
			Printf_HZ(&Table_Text[0],16);
			GB2312_NUM++;
			printf("GB2312_NUM = %d\r\n",GB2312_NUM);
		} 
        printf("\n");
        mssleep(10);
        //sleep(1);
	}
	fclose(fp);
	return 0; 
}
原网站

版权声明
本文为[Fledgling Xiao Li]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207222134035755.html