2502 views|12 replies

931

Posts

3

Resources
The OP
 

【GD32E503 Review】 Experiment on displaying Chinese characters and character strings [Copy link]

 
 

After a preliminary understanding of the TFT screen display of the development board, this will complete the experiment of displaying Chinese characters. At the same time, a string function that can display ASCII code with 8*16 dot matrix and Chinese characters with 16*16 dot matrix has been written, which improves the defect that the original example can only display a single character. The following figure shows the display effect:

The display control code is as follows. You can include any Chinese characters or ASCII characters in the string:

The structure of the Chinese character library is as follows:

The string display function is as follows:

/*!
    \brief      从根据指定位置开始在液晶屏上显示字符串(8*16ASCII和16*16汉字字符集)
    \param[in]  x: the start position of row-coordinate    X坐标
    \param[in]  y: the start position of column-coordinate Y坐标
    \param[in]  text: the char                             要显示的字符串
    \param[in]  char_color: the color of char              字符颜色
    \param[in]  c_format: the structure of char format     字体(字库)
                  font: CHAR_FONT_8_16 or CHAR_FONT_16_24
                  direction: CHAR_DIRECTION_HORIZONTAL or CHAR_DIRECTION_VERTICAL
                  char_color: the color of char
                  bk_color: the color of background
    \param[out] none
    \retval     none
*/
void lcd_strue_display(uint16_t x,uint16_t y,uint8_t *str,char_format_struct c_format)
{
    uint8_t i,j,k,temp_char;
	uint16_t X,Y;
	X = x;
	Y = y;
	while(*str){
        if(((uint8_t)(*str)) < 128){   //显示单字节ASCII(8*16)
            if(*str > 31){
                for (i = 0; i < 16; i++) { //显示16行的点阵
                    temp_char = ascii_8x16[((*str - 0x20) * 16) + i];
                    for (j = 0; j < 8; j++) {
                        if (((temp_char >> (7 - j)) & 0x01) == 0x01) {
                            lcd_point_set(X + j, Y + i, c_format.char_color);
                        } else {
                            lcd_point_set(X + j, Y + i, c_format.bk_color);
                        }
                    }
                }
            }
			str++;	
            X += 8;	
		}
		else{                          //显示双字节汉字(16*16)
		    for(k=0; k<200; k++){      //在汉字字符集中查找小于200次
			    if((GB_16ID[k][0] == *(str)) && (GB_16ID[k][1] == *(str + 1))){
		    		for( i=0; i<16; i++){//显示16行的点阵(左半边)
                        temp_char = GB_16[(k * 32) + i];
                        for (j = 0; j < 8; j++) {
                            if (((temp_char >> (7 - j)) & 0x01) == 0x01) {
                                lcd_point_set(X + j, Y + i, c_format.char_color);
                            } else {
                                lcd_point_set(X + j, Y + i, c_format.bk_color);
                            }
                        }
			    	}
		    		for( i=0; i<16; i++){//显示16行的点阵(右半边)
                        temp_char = GB_16[(k * 32) + i + 16];
                        for (j = 0; j < 8; j++) {
                            if (((temp_char >> (7 - j)) & 0x01) == 0x01) {
                                lcd_point_set(X + j + 8, Y + i, c_format.char_color);
                            } else {
                                lcd_point_set(X + j + 8, Y + i, c_format.bk_color);
                            }
                        }
			    	}
				}
			}
			str += 2;
			X += 16;
		}
	}
}

In this function, the issue of changing the font direction has not yet been considered. This function will be added later to connect with the example code.

This post is from Domestic Chip Exchange

Latest reply

Thanks man, I'll take a look   Details Published on 2024-5-17 11:00

赞赏

1

查看全部赞赏

 
 

1942

Posts

2

Resources
2
 

Very good! Is there a way to set the font dot matrix, row scanning, column scanning, etc., you can post pictures.

This post is from Domestic Chip Exchange

Comments

The second picture is: horizontally taking the left high bit, the data is arranged from top to bottom and from left to right.  Details Published on 2021-1-13 09:34
 
 
 

931

Posts

3

Resources
3
 
w494143467 posted on 2021-1-12 22:19 Not bad! Is there a way to set the font dot matrix, row scanning, column scanning, etc., you can post pictures.

The second picture is: horizontally taking the left high bit, the data is arranged from top to bottom and from left to right.

This post is from Domestic Chip Exchange

Comments

Okay, I'll give it a try then, so I don't have to try various directions.  Details Published on 2021-1-13 13:28
 
 
 

1942

Posts

2

Resources
4
 
hujj posted on 2021-1-13 09:34 The second picture is: horizontal modulus left high position, data arrangement from top to bottom and from left to right.

Okay, I'll give it a try then, so I don't have to try various directions.

This post is from Domestic Chip Exchange
 
 
 

931

Posts

3

Resources
5
 

After testing, the horizontal display of the string is also successful. The following is the display effect:

The code displayed is as follows:

Function code displayed:

/*!
    \brief      从根据指定位置开始在液晶屏上显示字符串(8*16ASCII和16*16汉字字符集)
    \param[in]  x: the start position of row-coordinate    X坐标
    \param[in]  y: the start position of column-coordinate Y坐标
    \param[in]  text: the char                             要显示的字符串
    \param[in]  char_color: the color of char              字符颜色
    \param[in]  c_format: the structure of char format     字体(字库)
                  font: CHAR_FONT_8_16 or CHAR_FONT_16_24
                  direction: CHAR_DIRECTION_HORIZONTAL or CHAR_DIRECTION_VERTICAL
                  char_color: the color of char
                  bk_color: the color of background
    \param[out] none
    \retval     none
*/
void lcd_strue_display(uint16_t x,uint16_t y,uint8_t *str,char_format_struct c_format)
{
    uint8_t i,j,k,temp_char;
	uint16_t X,Y;
	X = x;
	Y = y;
	while(*str){
        if(((uint8_t)(*str)) < 128){   //显示单字节ASCII(8*16)
            if(*str > 31){
				if(CHAR_DIRECTION_HORIZONTAL == c_format.direction){//水平显示
                    for (i = 0; i < 16; i++) { //显示16行的点阵
                        temp_char = ascii_8x16[((*str - 0x20) * 16) + i];
                        for (j = 0; j < 8; j++) {
                            if (((temp_char >> (7 - j)) & 0x01) == 0x01) {
                                lcd_point_set(X - i, Y + j, c_format.char_color);
                            } else {
                                lcd_point_set(X - i, Y + j, c_format.bk_color);
                            }
                        }
                    }
					Y += 8;
			    }else{
				    for (i = 0; i < 16; i++) { //显示16行的点阵
                        temp_char = ascii_8x16[((*str - 0x20) * 16) + i];
                        for (j = 0; j < 8; j++) {
                            if (((temp_char >> (7 - j)) & 0x01) == 0x01)
                                lcd_point_set(X + j, Y + i, c_format.char_color);
                            else
                                lcd_point_set(X + j, Y + i, c_format.bk_color);
                        }
                    }
		    		X += 8;
				}

            }
			str++;
		}
		else{                          //显示双字节汉字(16*16)
		    for(k=0; k<200; k++){      //在汉字字符集中查找小于200次
			    if((GB_16ID[k][0] == *(str)) && (GB_16ID[k][1] == *(str + 1))){
					if(CHAR_DIRECTION_HORIZONTAL == c_format.direction){  //水平显示
                		for( i=0; i<16; i++){//显示16行的点阵(左半边)
                            temp_char = GB_16[(k * 32) + i];
                            for (j = 0; j < 8; j++) {
                                if (((temp_char >> (7 - j)) & 0x01) == 0x01)
                                    lcd_point_set(X - i, Y + j, c_format.char_color);
                                else
                                    lcd_point_set(X - i, Y + j, c_format.bk_color);
                            }
                        }
			            for( i=0; i<16; i++){//显示16行的点阵(右半边)
                            temp_char = GB_16[(k * 32) + i + 16];
                            for (j = 0; j < 8; j++) {
                                if (((temp_char >> (7 - j)) & 0x01) == 0x01)
                                    lcd_point_set(X - i, Y + j + 8, c_format.char_color);
                                else
                                    lcd_point_set(X - i, Y + j + 8, c_format.bk_color);
                            }
                        }
						Y += 16;
			    	} else {
                		for( i=0; i<16; i++){//显示16行的点阵(左半边)
                            temp_char = GB_16[(k * 32) + i];
                            for (j = 0; j < 8; j++) {
                                if (((temp_char >> (7 - j)) & 0x01) == 0x01)
                                    lcd_point_set(X + j, Y + i, c_format.char_color);
                                else
                                    lcd_point_set(X + j, Y + i, c_format.bk_color);
                            }
                        }
			            for( i=0; i<16; i++){//显示16行的点阵(右半边)
                            temp_char = GB_16[(k * 32) + i + 16];
                            for (j = 0; j < 8; j++) {
                                if (((temp_char >> (7 - j)) & 0x01) == 0x01)
                                    lcd_point_set(X + j + 8, Y + i, c_format.char_color);
                                else
                                    lcd_point_set(X + j + 8, Y + i, c_format.bk_color);
                            }
                        }
						X += 16;
					}
				}
			}
			str += 2;
		}
	}
}

This post is from Domestic Chip Exchange
 
 
 

7453

Posts

2

Resources
6
 

Thanks for sharing, looking forward to the follow-up!

This post is from Domestic Chip Exchange
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

266

Posts

0

Resources
7
 

Awesome! I was still working on this last night and couldn't figure it out~

This post is from Domestic Chip Exchange

Comments

This is a copy of the example, but I was a little confused about the horizontal (horizontal) and vertical (vertical) directions. It took me many tests before I succeeded.  Details Published on 2021-1-14 09:33
Personal signature

gitee/casy

 
 
 

931

Posts

3

Resources
8
 
caizhiwei posted on 2021-1-14 08:18 Awesome! I was still working on this last night, but I didn’t figure it out~

This is a copy of the example, but I was a little confused about the horizontal (horizontal) and vertical (vertical) directions. It took me many tests before I succeeded.

This post is from Domestic Chip Exchange
 
 
 

266

Posts

0

Resources
9
 

Can you share some software for taking Chinese characters or images?

This post is from Domestic Chip Exchange
Personal signature

gitee/casy

 
 
 

931

Posts

3

Resources
10
 

This software was also obtained from the Internet. I have gotten used to it and feel it is very easy to use and can fully meet my needs. By the way, I would like to thank the author of the software!

lcd汉字取模软件.rar (2.9 MB, downloads: 32)

This post is from Domestic Chip Exchange
 
 
 

24

Posts

0

Resources
11
 

Can you send me a complete one? I will modify it into GD32F303 according to the code. It reports an error when I run it. I want to see where the problem is.

This post is from Domestic Chip Exchange

Comments

This is the project file saved at that time, I hope it can help you.  Details Published on 2024-5-16 11:46
 
 
 

931

Posts

3

Resources
12
 
csfc posted on 2024-5-15 13:58 Can you send me a complete one? I will modify it into GD32F303 and it will report an error when running. I want to see which part is the problem.

This is the project file saved at that time, I hope it can help you.

MyTest_9.rar (376.46 KB, downloads: 2)
This post is from Domestic Chip Exchange

Comments

Thanks man, I'll take a look  Details Published on 2024-5-17 11:00
 
 
 

24

Posts

0

Resources
13
 
hujj posted on 2024-5-16 11:46 This is the project file saved at that time, I hope it can help you.

Thanks man, I'll take a look

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list