Font Chip Learning-Chinese character internal code

Source: Internet
Author: User

Preface:

The Chinese character internal code, also known as "Chinese Character ASCII code", referred to as "Internal code", refers to the code used to store and process and transmit Chinese characters in a computer. It consists of 0 and 1 characters. After the input code is accepted, it is converted from the "input code conversion module" of the Chinese character operating system to the inner code, regardless of the keyboard input method used. The inner code is the most basic encoding of Chinese characters. No matter what Chinese character system or Chinese Character Input Method, the inner code of the entered Chinese characters must be converted into the inner code, to be stored and processed.

The inner code of Chinese characters is unique within the computer, and the inner code of the GB code is a two-byte code.

The internal code of the GB code is a two-byte code that adds "1" to the highest bit of each byte of the corresponding GB code, that is

Chinese character internal code = Chinese Character international code + 8080 H

For example, the above-mentioned "ah" Chinese character code is 3021 h, and the Chinese character machine internal code is b0a1h.

The basis of the Chinese character internal code is the Chinese character international code.

Internal code: in order to avoid the problem of ambiguity when both ASCII code and National Code are used, most Chinese character systems use each byte height 1 as the internal code of Chinese characters. This not only solves the ambiguity between the Chinese character machine internal code and the Spanish character machine internal code, but also makes the Chinese character machine internal code and the national character code have a very simple ing relationship.

The relationship between the Chinese character machine internal code, the country code, and the location code is: the two bytes of the Location Code (decimal) are converted into hexadecimal notation and then added 20 h to obtain the corresponding country code; the inner code is the inner code obtained by adding 1 to the highest bits of the two Chinese Character Exchange codes (country code), that is, adding 80 h to the two bytes of the Chinese Character Exchange Code (country code). The location code (decimal) and then add a0h to obtain the corresponding internal code.

Example: In-server code bit bedf, locate the location code?

There are two solutions: 1. BEDFH-A0A0H = 1e3fh = 3063d;

2. BEDFH-8080H = 3e5fh (country code), 3e5fh-20h = 1e3fh = 3063d.

 

Body:

When using font chips, users only need to knowCharacter inner codeYou can calculateCharacter dot matrix address on the chipAnd can be read from this address consecutively.
Dot Matrix information is used for display.

That is to say, the input to the font chip isInner code of Chinese CharactersThe output from the chip isCharacter lattice,For example, 8*8 lattice, 8*16 lattice, 15*16 lattice, these dot matrix are the model of Chinese characters displayed on the screen and can be directly displayed on the LCD screen. These arrays are also a series of binary or hexadecimal components. When there is no way to display them on the LCD, you can check whether the dot matrix binary chips read data from other places correctly.

Character lattice instance 8*8 write "King ":

11111111

00011000

00011000

11111111

00011000

00011000

00011000

11111111

 

How can I get the font internal code written into the chip? As mentioned above, "No matter what Chinese character system or Chinese Character Input Method, the entered Chinese Character external code must be converted into an internal machine code to be stored and processed ", that is to say, the Chinese characters written in the program are stored in the form of Chinese characters, as long as the content in the address storing Chinese characters is taken out, it is the internal code !! OK! Now, I have understood the font chip. The next step is to connect and set the chip pins. I will not repeat them here.

LCD input instance:

Print_24 (0, 36, "Liu yanlei", 0x00 );

Program example (in the font chip. c file ):

The font library chip is used for SPI communication. Its read and write code is as follows:

Void gt23_write (uint32_t F)
{
Uint8_t X;
Uint32_t smj;
Smj = (read <24) | F );
For (x = 0; x <32; X ++)
{
Gt_sclk0;
If (smj & 0x80000000 ))
{Gt_si1 ;}
Else
{Gt_si0 ;}
Smj = smj <1;
Gt_sclk1;
}
}

Uint8_t gt23_read ()
{
Uint8_t X, gy23_addr = 0x00, SS;
For (x = 0; x <8; X ++)
{
Gt_sclk0; // descent edge
Gy23_addr = gy23_addr <1;
For (Ss = 0; SS <1; SS ++ ){;};
If (0x04 = p1_26) // judge the data value
{Gy23_addr = (gy23_addr | 0x01 );}
Else // write data value
{Gy23_addr = (gy23_addr | 0x00 );}
Gt_sclk1;
}
Return gy23_addr;
}

Character address calculation functions in the font chip:

Uint32_t gt23_write_15 (const char * A) // * A is the word written into the chip. When writing Chinese characters into the function, the function automatically calculates the address of the character matrix (module) in the font chip, it can be directly displayed on the LCD.
{
Uint32_t address15 = 0;
Uint8_t msb15, lsb15;
Msb15 = *;
A ++;
Lsb15 = *;
If (msb15> = 0xa1 & msb15 <= 0xa9 & lsb15> = 0xa1)
Address15 = (msb15-0xa1) * 94 + (lsb15-0xa1) * 32 + baseadd15; // Algorithm for calculating the address of Characters in the chip
Else if (msb15> = 0xb0 & msb15 <= 0xf7 & lsb15> = 0xa1)
Address15 = (msb15-0xb0) * 94 + (lsb15-0xa1) + 846) * 32 + baseadd15; // Algorithm for calculating the address of Characters in the chip
Return address15;
}

Fill (which will be available in the following algorithm font chip manuals ):

15x16: gb2312 standard dot matrix font

Parameter description:
Gbcode indicates the inner code of Chinese characters.
MSB indicates the 8 bits of gbcode.
LSB indicates the low 8 bits of gbcode in Chinese characters.
Address indicates the byte address of Chinese characters or ASCII characters in the chip.
Baseadd: the starting address of the dot matrix data in the font chip.
Calculation method:
Baseadd = 0x5f4c0;
If (MSB> = 0xa1 & MSB <= 0xa3 & LSB> = 0xa1) // full-angle character area 1 Part 1
Address = (MSB-0xa1) * 94 + (LSB-0xa1) * 32 + baseadd;
Else if (MSB = 0xa6 & LSB> = 0xa1) // full-angle character area 1, part 2
Address = (MSB-0xa1) * 94 + (LSB-0xa1)-94*2) * 32 + baseadd;
Else if (MSB = 0xa9 & LSB> = 0xa1) // full-angle character area 1 Part 3
Address = (MSB-0xa1) * 94 + (LSB-0xa1)-94*4) * 32 + baseadd;
Else if (MSB> = 0xb0 & MSB <= 0xf7 & LSB> = 0xa1) // 16 lattice Chinese Character Area
Address = (MSB-0xb0) * 94 + (LSB-0xa1) + 662) * 32 + baseadd;

 

 

End:

Please leave a message about the incorrect font chip !!

Reprinted please link: http://blog.csdn.net/lyl494223339/article/details/7912554#reply

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.