display.c
字号:
/*
* TI driver functions
*/
extern void LCD_SetPower (void);
extern void LCD_Reset (void);
extern void LCD_Enable (int);
extern void LCD_Clear (void);
extern void LCD_WriteString (int y, int x, char *s);
extern void LCD_PixBlt (int x, int y, int w, int h, char *bmp);
extern void LCD_DrawIcon (int x, int y, char id);
extern void LCD_TranslateBitmap (int w, int h, char *bo, char *bt);
extern void LCD_Cursor (int row, int col);
extern void r2d_draw_rectangle(T_R2D_GC_PTR gc,
INT16 ul_x,INT16 ul_y,INT16 bl_x, INT16 bl_y);
GLOBAL void rt_ExtPrimitive ( USHORT TaskHandle, USHORT DestComHandle, USHORT DestTaskHandle,
char *ExtDest, OS_QDATA *Msg );
/*
* Internal Functions for Graphic Driver (Workaround)
*/
LOCAL void scrInit (void);
LOCAL void scrExit (void);
LOCAL void scrSize (int *x, int *y);
#if (!CUST)//JVJE #if (CUST==1)
LOCAL void scrClear (void);
#endif
LOCAL void scrClearRect (int px, int py, int sx, int sy);
extern void scrText (int x, int y, UBYTE in_Attrib, char *txt); //zgz,2002.8.19 change it to global function
extern void scrText_Unicode (int x, int y, UBYTE in_Attrib, char *txt); //zgz,2002.8.19 change it to global function
#if R2D_SUBLCD_SUPPORT
void sub_scrText_Unicode (int x, int y, UBYTE in_Attrib, char * intxt);
void sub_scrText(int x, int y, UBYTE in_Attrib, char *txt);
#endif
LOCAL void scrLine (int px, int py, int sx, int sy);
LOCAL void scrRect (int px, int py, int sx, int sy);
LOCAL int scrFntSelect (int font);
LOCAL int scrFntHeight (void);
LOCAL int scrFntGetFit (char *tp, int lineWidth);
#if R2D_SUBLCD_SUPPORT
LOCAL int scrFntGetLen (char *tp, int nChars, int sub_main);
#else
LOCAL int scrFntGetLen (char *tp, int nChars);
#endif
LOCAL int scrBmpDraw (int px, int py, int sx, int sy,
int ix, char *bm, int mode);
LOCAL void scrCurType (int type);
LOCAL void scrCursor (int x, int y);
LOCAL void scrPoint (int px, int py, int col);
#if R2D_SUBLCD_SUPPORT
LOCAL void scrTxtPoint (int px, int py, UBYTE in_Attr, int col, UBYTE sub_main);
#else
LOCAL void scrTxtPoint (int px, int py, UBYTE in_Attr, int col);
#endif
LOCAL int scrUpdate (int onOff);
#if R2D_SUBLCD_SUPPORT
void dspl_show_bitmap (int x,
int y,
UBYTE txtAttrib,
t_font_bitmap *current_bitmap,
UBYTE attr,
UBYTE sub_main );
#else
void dspl_show_bitmap (int x,
int y,
UBYTE txtAttrib,
t_font_bitmap *current_bitmap,
UBYTE attr);
#endif
/* Robert.Chen add, 2003-12-14 */
#if R2D_SUBLCD_SUPPORT
#define SUBLCD_COL 96
#define SUBLCD_ROW 64
#endif
/*2003/12/25,talcon add*/
GLOBAL UBYTE dspl_TextOut_Cmode_Center(USHORT in_Y, USHORT len_x, UBYTE in_Attrib,
char * in_Text, UBYTE Newline);
static U8 dsplScreenType = 0;
PDSPL_BITBLT pdspl_BitBlt = (PDSPL_BITBLT)dspl_BitBlt;
PSET_FONT_TYPE pset_font_type = (PSET_FONT_TYPE)set_font_type;
PDSPL_ENABLE pdspl_Enable = (PDSPL_ENABLE)dspl_Enable;
PDSPL_TEXTOUT_CMODE_CENTER pdspl_TextOut_Cmode_Center = (PDSPL_TEXTOUT_CMODE_CENTER)dspl_TextOut_Cmode_Center;
PDSPL_COLORTEXTOUT pdspl_colorTextOut = (PDSPL_COLORTEXTOUT)dspl_colorTextOut;
PDSPL_CLEARALL pdspl_ClearAll =(PDSPL_CLEARALL)dspl_ClearAll;
PDSPL_CLEAR pdspl_Clear = (PDSPL_CLEAR)dspl_Clear;
/*END TALCON ADD*/
/*==== CONSTANTS ==================================================*/
/*******************************************************************
* *
* PART I: Driver Interface *
* *
*******************************************************************/
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_Init |
+--------------------------------------------------------------------+
PURPOSE : The function initializes the driver磗 internal data. The
function returns DRV_INITIALIZED if the driver has already
been initialized and is ready to be used or already in use.
In case of an initialization failure, which means that the
driver cannot be used, the function returns DRV_INITFAILURE.
*/
GLOBAL UBYTE dspl_Init (void)
{
/*
* Default is character Display
*/
fontinfo = (FONTINFO *)malloc(sizeof (FONTINFO));/* must allot place to save fontinfo */
displayData.DisplayType = DSPL_TYPE_CHARACTER;
set_font_type(NORMAL_FONT);/* set the initial font type is NORMAL_FONT */
/* Robert.Chen add, for sub LCD, 2003-12-14 */
#if R2D_SUBLCD_SUPPORT
sub_fontinfo = (FONTINFO *)malloc(sizeof (FONTINFO));
sub_displayData.DisplayType = DSPL_TYPE_GRAPHIC;
sub_displayData.Height = SUBLCD_ROW;
sub_displayData.Width = SUBLCD_COL;
sub_scrX = SUBLCD_COL;
sub_scrY = SUBLCD_ROW;
set_sub_font_type(NORMAL_FONT);
r2d_erase(r2d_g_sublcd_gc);
sub_scrEnabled = 1;
#endif
/* end */
if(!extDisplay) /* use internal display */
{
#if defined (SIMULATE_LCD)
LCD_Reset (); /* use character oriented display */
LCD_Enable (1);
LCD_Clear ();
scrInit(); /* we need this also for glob vars, kk 14.02.2000*/
#else
scrInit(); /* use graphic display */
#endif
}
else
#if defined (SIMULATE_LCD)
LCD_Enable (0);
#else
scrExit();
#endif
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_Exit |
+--------------------------------------------------------------------+
PURPOSE : The function is called when the driver functionality is
not longer needed. The function "de-allocates" all
allocated resources and finalizes the driver.
*/
GLOBAL void dspl_Exit (void)
{
scrExit();
}
/*
+--------------------------------------------------------------------+
PURPOSE : This function is used to clear a specific region of the
display using the current background colour. The region
is specified by the upper left corner (X1, Y1) and the
lower right corner (X2, Y2) inclusive. The background
color can be set using dspl_SetBkgColor () function.
*/
GLOBAL UBYTE dspl_Clear (USHORT in_X1,
USHORT in_Y1,
USHORT in_X2,
USHORT in_Y2)
{
r2d_fill_rectangle( r2d_g_lcd_gc, in_X1-1, in_Y1-1, in_X2, in_Y2);//attention:need to clear buffer also later
return DRV_OK;
}
/* Robert.Chen add, 2003-12-14 */
#if R2D_SUBLCD_SUPPORT
GLOBAL UBYTE dspl_sub_Clear (USHORT in_X1,
USHORT in_Y1,
USHORT in_X2,
USHORT in_Y2)
{
r2d_fill_rectangle( r2d_g_sublcd_gc, in_X1-1, in_Y1-1, in_X2, in_Y2);
return DRV_OK;
}
#endif
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_Clear |
+--------------------------------------------------------------------+
PURPOSE : This function is used to clear a specific region of the
display using the current background colour. The region
is specified by the upper left corner (X1, Y1) and the
lower right corner (X2, Y2) inclusive. The background
color can be set using dspl_SetBkgColor () function.
*/
GLOBAL UBYTE dspl_ClearAll (void)
{
scrClear ();
return DRV_OK;
}
/* Robert.Chen add, 2003-12-14 */
#if R2D_SUBLCD_SUPPORT
GLOBAL UBYTE dspl_sub_ClearAll(void)
{
U8 uMode;
uMode = dspl_sub_Enable(0);
r2d_erase(r2d_g_sublcd_gc);
dspl_sub_Enable(uMode);
}
#endif
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_Enable |
+--------------------------------------------------------------------+
PURPOSE : The function is used to turn the display on or off. While
a display is switched off, it is possible to perform any
drawing function.
*/
GLOBAL UBYTE dspl_Enable (UBYTE in_Enable)
{
return scrUpdate (in_Enable);
}
/* Robert.Chen add, for enable/disable sub LCD, 2003-12-14 */
#if R2D_SUBLCD_SUPPORT
GLOBAL UBYTE dspl_sub_Enable(UBYTE in_Enable)
{
int ena = sub_scrEnabled;
sub_scrEnabled = in_Enable;
if(sub_scrEnabled)
{
LcdUpdateRequire(r2d_g_sublcd_gc);
}
return ena;
}
#endif
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_GetDeviceCaps |
+--------------------------------------------------------------------+
PURPOSE : This function is used to retrieve the capabilities of the
display device including the dimensions of the display and
the logical unit in which the dimensions is measured.
*/
GLOBAL void dspl_GetDeviceCaps (dspl_DevCaps * out_DeviceCapsPtr)
{
int x,y;
scrSize (&x, &y);
out_DeviceCapsPtr->Height = (USHORT)y;
out_DeviceCapsPtr->Width = (USHORT)x;
}
/* Robert.Chen add, for sub LCD capability, 2003-12-14 */
#if R2D_SUBLCD_SUPPORT
GLOBAL void dspl_sub_GetDeviceCaps(dspl_DevCaps * out_DeviceCapsPtr)
{
out_DeviceCapsPtr->Height = (USHORT)SUBLCD_ROW;
out_DeviceCapsPtr->Width = (USHORT)SUBLCD_COL;
}
#endif
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_SetDeviceCaps |
+--------------------------------------------------------------------+
PURPOSE : This function is used to set the capabilities of the
display device including the dimensions of the display and
the logical unit in which the dimensions is measured.
*/
GLOBAL void dspl_SetDeviceCaps (dspl_DevCaps * in_DeviceCapsPtr)
{
displayData.DisplayType = in_DeviceCapsPtr->DisplayType;
}
/* Robert.Chen add, for sub LCD capability, 2003-12-14 */
#if R2D_SUBLCD_SUPPORT
GLOBAL void dspl_sub_SetDeviceCaps (dspl_DevCaps * in_DeviceCapsPtr)
{
sub_displayData.DisplayType = in_DeviceCapsPtr->DisplayType;
}
#endif
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_GetIconImage |
+--------------------------------------------------------------------+
PURPOSE : This function is used to copy the image of a driver
internal icon into an application specific icon buffer.
The icon may modify the icon. In case of a successful
completion the function returns DRV_OK. In case the
size of the buffer where the icon image shall be copied
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_GetIconImage (UBYTE in_Icon,
USHORT in_Size,
UBYTE * out_IconImagePtr)
{
return DSPL_FCT_NOTSUPPORTED;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_SetCursor |
+--------------------------------------------------------------------+
PURPOSE : This function is used to change the current cursor settings.
These settings include the type of cursor and the mode
(e.g. static cursor, not flashing). A set of standard
types and modes is defined.
*/
GLOBAL UBYTE dspl_SetCursor (UBYTE in_CursorType,
UBYTE in_CursorMode)
{
return DRV_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103) MODULE : DRV_DSPL |
| STATE : code ROUTINE : dspl_SetCursorPos |
+--------------------------------------------------------------------+
PURPOSE : This function is used to set the current cursor position.
If the function succeeds, the cursor is set to the new
position. If one of the values is out of range, the function
returns DRV_INVALID_PARAMS. The number of rows and columns
the display supports can be retrieved using the function
dspl_GetDevCaps(). The upper left corner has the coordinates
0,0. The values in_X and in_Y are measured in logical units
depending on the capabilities of the device. The means a
graphical display will use pixels.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -