⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 display.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:
| 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_Clear (USHORT   in_X1,
                         USHORT   in_Y1,
                         USHORT   in_X2,
                         USHORT   in_Y2)
{
  scrClearRect ((int)in_X1,(int)in_Y1,(int)(in_X2-in_X1+1),(int)(in_Y2-in_Y1+1));

  return DRV_OK;
}

/*
+--------------------------------------------------------------------+
| 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)
{
#if (!CUST)
  scrClear ();
#endif

  return DRV_OK;
}

/*
+--------------------------------------------------------------------+
| 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);
}

/*
+--------------------------------------------------------------------+
| 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;
}

/*
+--------------------------------------------------------------------+
| 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;
}

/*
+--------------------------------------------------------------------+
| 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.

GW 05/09/01 Added size x and size y parameters to allow for chinese chars.
*/

GLOBAL UBYTE dspl_SetCursorPos (USHORT   in_X,
                                USHORT   in_Y,
                USHORT   in_SizeX,
                USHORT   in_SizeY
                )
{
  if (displayData.DisplayType EQ DSPL_TYPE_CHARACTER)
  {
     LCD_Cursor (in_Y, in_X);               /* set cursor position */
     if (extDisplay)                        /* if external display */
       dspl_SendDisplayReq (in_X, in_Y, NULL);
  }
  else
     scrLine(in_X,in_Y+in_SizeY-1,in_X+in_SizeX-1,in_Y+in_SizeY-1);
  return DRV_OK;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_DSPL                   |
| STATE   : code                ROUTINE : dspl_ShowCursor            |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to change the status of the cursor.
            The cursor can be visible or invisible. The function returns
            the previous status of the cursor.

*/

GLOBAL UBYTE dspl_ShowCursor (UBYTE in_Show)
{
  return DSPL_CURSOR_VISIBLE;
}


/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_DSPL                   |
| STATE   : code                ROUTINE : dspl_SetBkgColor           |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to change the color used for
            background painting. If the color is out of range, the
            driver returns DRV_INVALID_PARAMS and leaves the color
            unchanged.

*/

GLOBAL UBYTE dspl_SetBkgColor (UBYTE in_Color)
{
  return DRV_OK;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_DSPL                   |
| STATE   : code                ROUTINE : dspl_SetFrgColor           |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to change the color used for
            foreground painting, e.g. text color. If the color is
            out of range, the driver returns DRV_INVALID_PARAMS and
            leaves the color unchanged.
            set a call-back function which

*/

GLOBAL UBYTE dspl_SetFrgColor (UBYTE in_Color)
{
  return DSPL_FCT_NOTSUPPORTED;
}

enum
{
	COL_TYPE_FGD =0,
	COL_TYPE_BGD,
	COL_TYPE_HIGHLIGHT,
	COL_TYPE_BORDER,
	COL_TYPE_SHADOW,
	MAX_COL_TYPE
};
enum
{
	COL_CMD_INIT,
	COL_CMD_GET,
	COL_CMD_SET,
	COL_CMD_SETSHADOW,
	COL_CMD_RESTORECOL,
	MAX_COL_CMD
};

//This definition allows us to have a transparent colour in 256 colour bitmaps.
//We lose the colour nearly-black gray but I don't think it will be missed!
//Better to lose white than gray but will require all icons to be updated!
#define TRANSPARENT_256_COL 0x25

//This definition allows us to have a transparent colour in 16bit LCD colour bitmaps.
//We lose almost white R=0xF8 G=0xFC B=0xF8. NB word is inverted
#define TRANSPARENT_16BIT_COL 0x0020

//using ARGB format, transparent = 0xFFxxxxxx
#define TRANSPARENT_32BIT_COLOUR 0xFF000000

//Hide colours
LOCAL U32 colour_class (int cmd, int colId, U32 inColour)
{
static U32 g_col[MAX_COL_TYPE];
static U32 g_colOld[MAX_COL_TYPE];
	switch (cmd)
	{
		case COL_CMD_INIT:
			colour_class(COL_CMD_SET,	COL_TYPE_FGD,			0x00404040	);
			colour_class(COL_CMD_SET,	COL_TYPE_BGD,			0x00FFFFFF	); //white
			colour_class(COL_CMD_SET,	COL_TYPE_HIGHLIGHT,		0x00FF00FF	);
			colour_class(COL_CMD_SET,	COL_TYPE_BORDER,		0x00FFFFFF	);
			colour_class(COL_CMD_SET,	COL_TYPE_SHADOW,		0x40010101	); //50% translucency
			return (0);
			break;
		case COL_CMD_SET:
			if (inColour != 0)
			{
				g_colOld[colId]	=	g_col[colId];
				g_col[colId]	=	inColour;
			}
			return(g_colOld[colId]);
			break;
		case COL_CMD_GET:
#ifdef COLOURDISPLAY
#ifdef DSAMPLE_COLOUR
			return(g_col[colId]);
#endif
#else
			switch (colId)
			{
				case COL_TYPE_FGD:			return (0x00FFFFFF);
				case COL_TYPE_BGD:			return (0x00000000);
				case COL_TYPE_HIGHLIGHT:	return (0x00000000);
				case COL_TYPE_BORDER:		return (0x00000000);
				case COL_TYPE_SHADOW:		return (0x00000000);
				default:					return (0);
			}
#endif
			break;
		case COL_CMD_SETSHADOW:
			g_colOld[colId]	=	g_col[colId];//currently we dont really need to save the old value
			// set shadow to 50% black
			g_col[colId] = 0x40010101;// | ((inColour >> 2) & 0x003F3F3F);
			return(0x40010101);
			break;
		case COL_CMD_RESTORECOL:
			g_col[colId] = g_colOld[colId];
			return (0);
			break;
		default:
			break;
	}
	return (0);
}

GLOBAL U32 dspl_SetFgdColour (U32 inColour)			{	return (colour_class(COL_CMD_SET,		COL_TYPE_FGD,		inColour));	}
GLOBAL U32 dspl_SetBgdColour (U32 inColour)			{	return (colour_class(COL_CMD_SET,		COL_TYPE_BGD,		inColour));	}
GLOBAL U32 dspl_SetHighlightColour (U32 inColour)	{	return (colour_class(COL_CMD_SET,		COL_TYPE_HIGHLIGHT,	inColour));	}
GLOBAL U32 dspl_SetBorderColour (U32 inColour)		{	return (colour_class(COL_CMD_SET,		COL_TYPE_BORDER,  	inColour));	}
GLOBAL U32 dspl_SetShadowColour (U32 inColour)		{	return (colour_class(COL_CMD_SETSHADOW,	COL_TYPE_SHADOW,  	inColour));	}

GLOBAL U32 dspl_GetFgdColour ( void )				{	return (colour_class(COL_CMD_GET,		COL_TYPE_FGD,		0));	}
GLOBAL U32 dspl_GetBgdColour ( void )				{	return (colour_class(COL_CMD_GET,		COL_TYPE_BGD,		0));	}
GLOBAL U32 dspl_GetHighlightColour ( void )			{	return (colour_class(COL_CMD_GET,		COL_TYPE_HIGHLIGHT,	0));	}
GLOBAL U32 dspl_GetBorderColour ( void )			{	return (colour_class(COL_CMD_GET,		COL_TYPE_BORDER,	0));	}
GLOBAL U32 dspl_GetShadowColour (void)				{	return (colour_class(COL_CMD_GET,		COL_TYPE_SHADOW,  	0));	}

GLOBAL void dspl_InitColour (void)
{
	colour_class(COL_CMD_INIT,	0,	0);
}
GLOBAL void dspl_RestoreColour (void)
{
	colour_class(COL_CMD_RESTORECOL,	COL_TYPE_FGD,	0);
	colour_class(COL_CMD_RESTORECOL,	COL_TYPE_BGD,	0);
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_DSPL                   |
| STATE   : code                ROUTINE : dspl_DrawIcon              |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to draw a driver internal icon.
            The origin of the icon is the upper left corner, defined
            by the parameters in_X/in_Y.

*/

GLOBAL UBYTE dspl_DrawIcon (UBYTE  in_IconID,
                            USHORT in_X,
                            USHORT in_Y)
{
  return DSPL_FCT_NOTSUPPORTED;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_DSPL                   |
| STATE   : code                ROUTINE : dspl_DrawLine              |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to draw a line from a specific
            location defined by the parameters in_X1/in_Y1, to a
            specific location defined by the parameters in_X2/in_Y2.
            The display磗 origin is the upper left corner with the
            co-ordinates (0,0). The function uses the current
            foreground color, which can be set using the
            dspl_SetFrgColor (), to draw the line.

*/

GLOBAL UBYTE dspl_DrawLine (USHORT in_X1,
                            USHORT in_Y1,
                            USHORT in_X2,
                            USHORT in_Y2)
{
    scrLine(in_X1,in_Y1,in_X2,in_Y2);

    return DRV_OK;
}

/*
+--------------------------------------------------------------------+

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -