display.c
字号:
+--------------------------------------------------------------------+
PURPOSE : This function is used to copy the image of a font into an
application specific font buffer. The application may modify
the font. In case of a successful completion the function
returns DRV_OK. In case the size of the buffer where the
font image shall be copied to is too small the driver returns
DRV_INVALID_PARAMS. In case a specific driver implementation
does not support this functionality the driver returns
DSPL_FCT_NOTSUPPORTED.
*/
GLOBAL UBYTE dspl_GetFontImage (UBYTE in_Font,
USHORT in_Size,
UBYTE * out_FontPtr)
{
return DSPL_FCT_NOTSUPPORTED;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_GetFontHeight |
+--------------------------------------------------------------------+
PURPOSE : This function is used to retrieve the vertical size of
the currently selected font. The function returns the
height measured in logical units depending on the device
capabilities (e.g. pixels or multiple of characters). Call
the function dspl_SelectFont() to select a font.
*/
GLOBAL UBYTE dspl_GetFontHeight (void)
{
return scrFntHeight();
}
/* Robert.Chen add, for getting sub LCD font height, 2003-12-14 */
#if R2D_SUBLCD_SUPPORT
GLOBAL UBYTE dspl_sub_GetFontHeight (void)
{
return sub_fontinfo->font_h;
}
#endif
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_GetTextExtent |
+--------------------------------------------------------------------+
PURPOSE : This function is used to calculate the size of a 0-terminated
string, to which the parameter in_Text points. The function
returns the size needed to display the text. The value of
the size is measured in units depending on the device
capabilities (e.g. pixels or multiple of characters). Call
the function dspl_SelectFont() to select a font.
*/
/* Robert.Chen changed, for sub LCD, 2003-102-14 */
#if R2D_SUBLCD_SUPPORT
GLOBAL USHORT dspl_GetTextExtent (char * in_Text, USHORT in_Length)
{
if(displayData.DisplayType EQ DSPL_TYPE_CHARACTER)
return in_Length;
else
return scrFntGetLen ( in_Text, ( int ) in_Length, 1 );
}
GLOBAL USHORT dspl_sub_GetTextExtent (char *in_Text, USHORT in_Length)
{
if(sub_displayData.DisplayType EQ DSPL_TYPE_CHARACTER)
return in_Length;
else
return scrFntGetLen ( in_Text, ( int ) in_Length, 0 );
}
#else
GLOBAL USHORT dspl_GetTextExtent (char * in_Text, USHORT in_Length)
{
if(displayData.DisplayType EQ DSPL_TYPE_CHARACTER)
return in_Length;
else
return scrFntGetLen ( in_Text, ( int ) in_Length );
}
#endif
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_GetMaxTextLen |
+--------------------------------------------------------------------+
PURPOSE : This function is used to calculate the sub-string
(number of characters) of a 0-terminated string (in_Text)
that can be displayed in the region given by the parameter
in_HSize. The value of in_HSize is measured in logical
units (e.g. pixels or multiple of characters). Call
the function dspl_SelectFont() to select a font.
*/
GLOBAL USHORT dspl_GetMaxTextLen (char * in_Text,
USHORT in_HSize)
{
if(displayData.DisplayType EQ DSPL_TYPE_CHARACTER)
return strlen (in_Text);
else
return scrFntGetFit ( in_Text, ( int ) in_HSize );
}
GLOBAL void dspl_set_char_type(UBYTE char_type)
{
dspl_char_type = char_type;
}
GLOBAL UBYTE dspl_get_char_type(void)
{
return dspl_char_type;
}
/* Robert.Chen add, for sub LCD, 2003-12-14 */
#if R2D_SUBLCD_SUPPORT
GLOBAL void dspl_sub_set_char_type(UBYTE char_type)
{
dspl_sub_char_type = char_type;
}
GLOBAL UBYTE dspl_sub_get_char_type(void)
{
return dspl_sub_char_type;
}
#endif
#if R2D_SUBLCD_SUPPORT
/* font type setting internal function */
static void set_font_type_i(UBYTE font_type, UBYTE lcd)
{
FONTINFO *finfo;
if(lcd == 1) /* set main LCD font type */
{
dspl_font_type = font_type;
finfo = fontinfo;
}
else
{
dspl_sub_font_type = font_type;
finfo = sub_fontinfo;
}
switch(font_type)
{
case NORMAL_FONT:
/* 2003/12/29 sunsj add font switch */
#if defined FONT_12X12
finfo->font_w = 6; /* we should set font_w as 1/2 of width of unicode */
finfo->font_h = 12; /* font height */
finfo->font_s = 12; /* we should set font_s as 1/2 of size of unicode */
finfo->font_e = MAXCODESYM; /* how many char in uni_sym font lib table */
finfo->ascfont = (char *)Asc0_127_6x12Ex; /* ascii font lib */
finfo->uni0_256 = (char *)Asc0_127_6x12Ex; /* uni 0~256 font lib */
finfo->uni_cjk = (char *)UniCJKNormal12x12; /* uni cjk font lib */
finfo->uni_sym = (_UniSym_ *)UniSym12x12; /* uni sym font lib */
finfo->uni_12x12= 0; /* uni12x12 font lib, if you needn't it,you can set it to 0 */
#elif defined FONT_16X16
finfo->font_w = 8; /* we should set font_w as 1/2 of width of unicode */
finfo->font_h = 16; /* font height */
finfo->font_s = 16; /* we should set font_s as 1/2 of size of unicode */
finfo->font_e = MAXCODESYM; /* how many char in uni_sym font lib table */
finfo->ascfont = (char *)Uni0_256_8x16Ex; /* ascii font lib */
finfo->uni0_256 = (char *)Uni0_256_8x16Ex; /* uni 0~256 font lib */
finfo->uni_cjk = (char *)UniCJKNormal16x16; /* uni cjk font lib */
finfo->uni_sym = (_UniSym_ *)UniSym16x16; /* uni sym font lib */
finfo->uni_12x12= 0; /* uni12x12 font lib, if you needn't it,you can set it to 0 */
#endif
/* 2003/10/13 sunsj charwidth if we display auto width ascii */
finfo->charwidth = (char *)asccharwidth;
/* 2003/10/26 sunsj add for stroke element and pinyin element */
finfo->elementmap = (char *)ElementMap;
break;
case UNI12X12_FONT: /* for gudy's calendar */
finfo->font_w = 6;
finfo->font_h = 12;
finfo->font_s = 12;
finfo->font_e = MAXCODE12X12;
finfo->ascfont = (char *)Asc0_127_6x12Ex;
finfo->uni0_256 = (char *)Asc0_127_6x12Ex;
finfo->uni_cjk = 0;//we needn't it,so set it to 0
finfo->uni_12x12= (_Uni12X12_ *)UniCJK12x12;
finfo->uni_sym = 0; /* we needn't it,so set it to 0 */
break;
case CHNINPUT_FONT:/* for chinese input */
finfo->font_w = 8;
finfo->font_h = 16;
finfo->font_s = 16;
finfo->font_e = MAXCODESYM;
finfo->ascfont = 0;
finfo->uni0_256 = (char *)Asc0_127_6x12Ex;
finfo->uni_cjk = 0;//(char *)UniCJKNormal;//we needn't it,so set it to 0
finfo->uni_12x12= 0;
finfo->uni_sym = 0;//we needn't it,so set it to 0
break;
case YB8X16_FONT:
finfo->font_w = 8;
finfo->font_h = 16;
finfo->font_s = 16;
finfo->font_e = 0;
finfo->ascfont = (char *)YB0_127_8x16Ex;
finfo->uni0_256 = 0;
finfo->uni_cjk = 0;
finfo->uni_12x12= 0;
finfo->uni_sym = 0;
break;
/* 2004/05/11 sunsj modify */
#ifdef _feature_mainLCD_w102_h80
/* 2004/03/08 sunsj add small font */
case SMALL_FONT:
finfo->font_w = 4;
finfo->font_h = 7;
finfo->font_s = 7;
finfo->font_e = 0;
finfo->ascfont = (char *)ASCII_number_4x7;
finfo->uni0_256 = 0;
finfo->uni_cjk = (char *)UniCJKNormal12x12;
finfo->uni_sym = (_UniSym_ *)UniSym12x12;
finfo->uni_12x12= 0;
break;
#endif
default:
break;
}
}
/*
* If you want display specific font, you must call the following function at first
* and new font type can be defined in dspl.h
*/
GLOBAL void set_font_type(UBYTE font_type)
{
/* set main LCD font type */
set_font_type_i(font_type, 1);
}
GLOBAL void set_sub_font_type(UBYTE font_type)
{
/* set sub LCD font type */
set_font_type_i(font_type, 0);
}
#else /* R2D_SUBLCD_SUPPORT */
/*
* If you want display specific font, you must call the following function at first
* and new font type can be defined in dspl.h
*/
static void set_font_type(UBYTE font_type)
{
dspl_font_type = font_type;
switch(dspl_font_type)
{
case NORMAL_FONT:
//#if(MAIN_LCD_SIZE==3)
#if defined FONT_12X12
fontinfo->font_w=6;//we should set font_w as 1/2 of width of unicode
fontinfo->font_h=12;//font height
fontinfo->font_s=12;//we should set font_s as 1/2 of size of unicode
fontinfo->font_e=MAXCODESYM;//how many char in uni_sym font lib table
fontinfo->ascfont=(char *)Asc0_127_6x12Ex;//ascii font lib
fontinfo->uni0_256=(char *)Asc0_127_6x12Ex;//uni 0~256 font lib
fontinfo->uni_cjk=(char *)UniCJKNormal12x12;//uni cjk font lib
fontinfo->uni_sym=(_UniSym_ *)UniSym12x12;//uni sym font lib
fontinfo->uni_12x12=0;//uni12x12 font lib, if you needn't it,you can set it to 0
#elif defined FONT_16X16
fontinfo->font_w=8;//we should set font_w as 1/2 of width of unicode
fontinfo->font_h=16;//font height
fontinfo->font_s=16;//we should set font_s as 1/2 of size of unicode
fontinfo->font_e=MAXCODESYM;//how many char in uni_sym font lib table
fontinfo->ascfont=(char *)Uni0_256_8x16Ex;//ascii font lib
fontinfo->uni0_256=(char *)Uni0_256_8x16Ex;//uni 0~256 font lib
fontinfo->uni_cjk=(char *)UniCJKNormal16x16;//uni cjk font lib
fontinfo->uni_sym=(_UniSym_ *)UniSym16x16;//uni sym font lib
fontinfo->uni_12x12=0;//uni12x12 font lib, if you needn't it,you can set it to 0
#endif
/* 2003/10/13 sunsj charwidth if we display auto width ascii */
fontinfo->charwidth = (char *)asccharwidth;
/* 2003/10/26 sunsj add for stroke element and pinyin element */
fontinfo->elementmap = (char *)ElementMap;
break;
case UNI12X12_FONT://zhonghz,2002/8/2, for gudy's calendar
fontinfo->font_w=6;
fontinfo->font_h=12;
fontinfo->font_s=12;
fontinfo->font_e=MAXCODE12X12;
fontinfo->ascfont=(char *)Asc0_127_6x12Ex;
fontinfo->uni0_256=(char *)Asc0_127_6x12Ex;
fontinfo->uni_cjk=0;//we needn't it,so set it to 0
fontinfo->uni_12x12=(_Uni12X12_ *)UniCJK12x12;
fontinfo->uni_sym=0;//we needn't it,so set it to 0
break;
case CHNINPUT_FONT://zhonghz,2002/9/3, for zhangxp's chinese input
fontinfo->font_w=8;
fontinfo->font_h=16;
fontinfo->font_s=16;
fontinfo->font_e=MAXCODESYM;
fontinfo->ascfont=0;
fontinfo->uni0_256=(char *)Asc0_127_6x12Ex;
fontinfo->uni_cjk=(char *)UniCJK16x16;;//we needn't it,so set it to 0
fontinfo->uni_12x12=0;
fontinfo->uni_sym=0;//we needn't it,so set it to 0
break;
case YB8X16_FONT:
fontinfo->font_w=8;
fontinfo->font_h=16;
fontinfo->font_s=16;
fontinfo->font_e=0;
fontinfo->ascfont=(char *)YB0_127_8x16Ex;
fontinfo->uni0_256=0;
fontinfo->uni_cjk=0;
fontinfo->uni_12x12=0;
fontinfo->uni_sym=0;
break;
default:
break;
}
}
#endif /* R2D_SUBLCD_SUPPORT */
/* get font type */
GLOBAL UBYTE get_font_type(void)
{
return dspl_font_type;
}
/* get font height */
GLOBAL int get_font_height(void)
{
return fontinfo->font_h;
}
/* get font width,half of width of unicode */
GLOBAL int get_font_width(void)
{
return fontinfo->font_w;
}
/* get font width,half of size of unicode */
GLOBAL int get_font_size(void)
{
return fontinfo->font_s;
}
/* Robert.Chen add, for sub LCD, 2003-12-14 */
#if R2D_SUBLCD_SUPPORT
/* get font type */
GLOBAL UBYTE get_sub_font_type(void)
{
return dspl_sub_font_type;
}
/* get font height */
GLOBAL int get_sub_font_height(void)
{
return sub_fontinfo->font_h;
}
/* get font width,half of width of unicode */
GLOBAL int get_sub_font_width(void)
{
return sub_fontinfo->font_w;
}
/* get font width,half of size of unicode */
GLOBAL int get_sub_font_size(void)
{
return sub_fontinfo->font_s;
}
#endif
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_TextOut_Cmode |
+--------------------------------------------------------------------+
PURPOSE : This function is used to display a text at the given
location in_X/in_Y uding the defined attributes (in_Attrib)
and the currently selected color (foreground and background).
The cursor position is left unchanged. The driver will not
take the displays bounding rectangle into consideration and
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -