金牌会员
- 积分
- 1055
- 金钱
- 1055
- 注册时间
- 2017-3-10
- 在线时间
- 170 小时
|
10金钱
中文显示无异常,英文显示的时候菜单翻页会蓝屏;还有就是左右箭头,中文能显示出来,英文不能显示出。贴出的代码为写字符串;找出的问题是在 //lcd_data_write(*(text++));处,有这个的时候翻页不蓝屏,但是在另一个页面分为左右两部分,会出现右侧显示信息,换行后第一个字母会显示在左侧第一个字母处;哪位老哥来分析下啊[mw_shl_code=applescript,true]void lcd_write_string(u16 x, u8 y, u16 width, u8 *string, bit inverse, u8 type)
{
ux8 i,shift_bit = 1;
ux16 x_i = x, y_i = y;
uc8 font_width_bit[AppFontNum] = {UNIVERSAL_WIDTH_BIT, ASCII_NORMAL_WIDTH_BIT, ASCII_SMALL_WIDTH_BIT, ASCII_BIG_WIDTH_BIT,
CN_FONT_WIDTH_BIT, KR_FONT_WIDTH_BIT, JP_FONT_WIDTH_BIT};
uc8 font_height_bit[AppFontNum] = {UNIVERSAL_HEIGHT_BIT, ASCII_NORMAL_HEIGHT_BIT, ASCII_SMALL_HEIGHT_BIT, ASCII_BIG_HEIGHT_BIT,
CN_FONT_HEIGHT_BIT, KR_FONT_HEIGHT_BIT, JP_FONT_HEIGHT_BIT};
ux8 clr_text[3] = {" "};
if((type == AsciiNormalFont) || (type == AsciiBigFont) || (type == AsciiSmallFont))
{
clr_text[1] = '\0';
shift_bit = 0;
}
for(i = 0; (*(string + (i<<shift_bit))) != 0; i++)
{
lcd_write_text(x_i, y_i, string + (i<<shift_bit), inverse,type);
x_i += font_width_bit[type];
if((x_i + font_width_bit[type]) > (x + width) || (x_i + font_width_bit[type]) > LCD_WIDTH_PIXELS)
{
x_i = x;
y_i += (font_height_bit[type]);
}
}
// if line is new line, don't need to be cleared
if(x_i == x && *string != DEF_NULL)
return;
for(;(x_i + font_width_bit[type]) <= (x + width);)
{
lcd_write_text(x_i, y_i, clr_text, inverse,type);
x_i += font_width_bit[type];
}
}
-------------------------------------
void lcd_write_char(u16 x, u8 y, u8 *dot, u8 height,bit inverse)
{
u8 y_i;
u8 mode;
u8 pre_bits,rem_bits;
u8 pre_data,rem_data;
u8 disp_data;
mode = x % 8;
pre_bits = mode;
rem_bits = 8 - mode;
// Normal type : alignment with byte
if(mode == 0)
{
lcd_set_cursor(x,y);
for(y_i = 0; y_i < height; y_i++)
{
if(inverse)
lcd_data_write(~(*dot));
else
lcd_data_write(*dot);
dot ++;
}
}
// Other type
else
{
for(y_i = 0; y_i < height; y_i++)
{
// read previous data
lcd_set_reg_class0(MAMR,0xb1);
lcd_set_reg_class0(WCCR,0xa9);
lcd_set_cursor(x,y + y_i);
pre_data = lcd_data_read();
rem_data = lcd_data_read();
if(inverse)
{
disp_data = ~(*dot);
}
else
{
disp_data = *dot;
}
pre_data = (pre_data & (0xff << rem_bits)) | ((disp_data & (0xff << pre_bits))>>pre_bits);
rem_data = (rem_data & (0xff >> pre_bits)) | ((disp_data & (0xff >> rem_bits))<<rem_bits);
lcd_set_cursor(x,y + y_i);
lcd_data_write(pre_data);
lcd_data_write(rem_data);
dot ++;
}
}
lcd_set_reg_class0(MAMR,0x31);
lcd_set_reg_class0(WCCR,0x29);
}
/*
*********************************************************************************************************
*
* lcd_write_text
*
* Description : write text on the lcd display area.
(Note: No change the cursor auto add direction!)
* InputParam : x: lcd x pixels(0-319)
y: lcd y pixels(0-199)
*text: text to write
inverse: 0:black word, 1:white word
type: font type
* Returns : none
* Author : Jenson
* Date : 2016/07/04
*
*********************************************************************************************************
*/
void lcd_write_text(u16 x, u8 y, u8 *text, bit inverse, u8 type)
{
u16 index,font_num;
uc8 *font_index,*font_dot;
u8 font_size,font_height,font_width;
u8 x_i,index_step;
switch(type)
{
// Universal Charactor
case UniversalFont:
{
#if Extern_Font_Universal
font_num = UNIVERSAL_NUM;
font_index = &UniversalIndex;
font_dot = &UniversalDot;
font_size = UNIVERSAL_SIZE_BYTE;
font_height = UNIVERSAL_HEIGHT_BIT;
font_width = UNIVERSAL_WIDTH_BYTE;
index_step = 1;
#else
return;
#endif
break;
}
// Ascii Normal Font
case AsciiNormalFont:
{
#if Extern_Font_ASCII
font_num = ASCII_NORMAL_NUM;
font_index = &AsciiNormalIndex;
font_dot = &AsciiNormalDot;
font_size = ASCII_SMALL_SIZE_BYTE;
font_height = ASCII_NORMAL_HEIGHT_BIT;
font_width = ASCII_NORMAL_WIDTH_BYTE;
index_step = 0;
#else
lcd_set_cursor(x,y);
lcd_set_reg_class0(WLCR,0xcd); // 切换文本模式
if(inverse)
{
lcd_set_reg_class0(WCCR,0x09); // 数据反相存储
}
//lcd_data_write(*(text++));
lcd_data_write(*text);
for(index=0; index<40; index ++); // 等待LCD解析显示
if(inverse)
{
lcd_set_reg_class0(WCCR,0x29); // 恢复正相存储
}
lcd_set_reg_class0(WLCR,0xc5); // 恢复图形模式
return;
#endif
break;
}
// Ascii Small Font
case AsciiSmallFont:
{
#if Extern_Font_ASCII_SMALL
font_num = ASCII_SMALL_NUM;
font_index = &AsciiSmallIndex;
font_dot = &AsciiSmallDot;
font_size = ASCII_SMALL_SIZE_BYTE;
font_height = ASCII_SMALL_HEIGHT_BIT;
font_width = ASCII_SMALL_WIDTH_BYTE;
index_step = 0;
#else
lcd_set_cursor(x,y);
lcd_set_reg_class0(WLCR,0xcd); // 切换文本模式
if(inverse)
{
lcd_set_reg_class0(WCCR,0x09); // 数据反相存储
}
lcd_data_write(*text);
if(inverse)
{
lcd_set_reg_class0(WCCR,0x29); // 恢复正相存储
}
lcd_set_reg_class0(WLCR,0xc5); // 恢复图形模式
return;
#endif
break;
}
// Ascii Big Font
case AsciiBigFont:
{
#if Extern_Font_ASCII_BIG
font_num = ASCII_BIG_NUM;
font_index = &AsciiBigIndex;
font_dot = &AsciiBigDot;
font_size = ASCII_BIG_SIZE_BYTE;
font_height = ASCII_BIG_HEIGHT_BIT;
font_width = ASCII_BIG_WIDTH_BYTE;
index_step = 0;
#else
lcd_set_cursor(x,y);
lcd_set_reg_class0(WLCR,0xcd); // 切换文本模式
lcd_set_reg_class0(FVHT,0xaf); // 水平尺寸3倍,垂直尺寸3倍
if(inverse)
{
lcd_set_reg_class0(WCCR,0x09); // 数据反相存储
}
lcd_data_write(*text);
for(index=0; index<40; index ++); // 等待LCD解析显示
lcd_set_reg_class0(WCCR,0x29); // 恢复正相存储,不加粗
lcd_set_reg_class0(FVHT,0x0f); // 水平尺寸1倍,垂直尺寸1倍
lcd_set_reg_class0(WLCR,0xc5); // 恢复图形模式
return;
#endif
break;
}
#if Chinese
// Chinese language
case ChineseFont:
{
#if Extern_Font_Cn
font_num = CN_NUM;
font_index = &CnIndex;
font_dot = &CnDot;
font_size = CN_FONT_SIZE_BYTE;
font_height = CN_FONT_HEIGHT_BIT;
font_width = CN_FONT_WIDTH_BYTE;
index_step = 1;
#else
lcd_set_cursor(x,y);
lcd_set_reg_class0(WLCR,0xcd); // 切换文本模式
if(inverse)
{
lcd_set_reg_class0(WCCR,0x09); // 数据反相存储
}
lcd_data_write(*(text++));
lcd_data_write(*text);
for(index=0; index<5; index ++); // 等待LCD解析显示
if(inverse)
{
lcd_set_reg_class0(WCCR,0x29); // 恢复正相存储
}
lcd_set_reg_class0(WLCR,0xc5); // 恢复图形模式
return;
#endif
break;
}
#endif
#if Korean
// Korean language
case KoreanFont:
{
#if Extern_Font_Kr
font_num = KR_NUM;
font_index = &KrIndex;
font_dot = &KrDot;
font_size = KR_FONT_SIZE_BYTE;
font_height = KR_FONT_HEIGHT_BIT;
font_width = KR_FONT_WIDTH_BYTE;
index_step = 1;
#else
return;
#endif
break;
}
#endif
#if Japanese
// Japanese language
case JapaneseFont:
{
#if Extern_Font_Jp
font_num = JP_NUM;
font_index = &JpIndex;
font_dot = &JpDot;
font_size = JP_FONT_SIZE_BYTE;
font_height = JP_FONT_HEIGHT_BIT;
font_width = JP_FONT_WIDTH_BYTE;
index_step = 1;
#else
return;
#endif
break;
}
#endif
default:
{
return;
break;
}
}
// find index code
switch(index_step)
{
case 0:
{
for (index = 0; index < font_num; index++)
{
if ((*(font_index + index) == *text))
{
break;
}
}
}
case 1:
{
for (index = 0; index < font_num; index++)
{
if ((*(font_index + (index<<1)) == *text) && (*(font_index + (index<<1) + 1) == *(text + 1)))
{
break;
}
}
}
default:
break;
}
// If can't find the word in the chinese index table,return
if(index == font_num)
{
return;
}
else
{
index *= font_size;
}
// Find the word, and write to lcd
for(x_i = 0; x_i < font_width; x_i++)
{
x += (x_i<<3);
lcd_write_char(x,y,(font_dot + index + (x_i*font_height)),font_height,inverse);
}
}[/mw_shl_code] |
|