经过测试,字符串的水平方向显示也成功了,下面是显示的效果:
显示的代码如下:
显示的函数代码:
/*!
\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;
}
}
}
|