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

📄 display.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/*
+-----------------------------------------------------------------------------
|  Project :
|  Modul   :  display.c
+-----------------------------------------------------------------------------
|  Copyright 2002 Texas Instruments Berlin, AG
|                 All rights reserved.
|
|                 This file is confidential and a trade secret of Texas
|                 Instruments Berlin, AG
|                 The receipt of or possession of this file does not convey
|                 any rights to reproduce or disclose its contents or to
|                 manufacture, use, or sell anything it may describe, in
|                 whole, or in part, without the specific written consent of
|                 Texas Instruments Berlin, AG.
+-----------------------------------------------------------------------------
|  Purpose :
+-----------------------------------------------------------------------------
*/
/*
GW 31/01/03 -	Added support for 16 bit LCD buffer -
					Split DSAMPLE_COLOUR code into DSAMPLE_COLOUR32 (original 32bits/pixel)
					and DSAMPLE_COLOUR16 (16 bits/pixel - untested)
				Removed CSAMPLE_COLOUR option
				Removed 'PLOT' option for D-sample - too slow to be useful


*/

#ifndef DRV_DSPL_C
#define DRV_DSPL_C
#endif
/*==== INCLUDES ===================================================*/
#define ENTITY_CST

#include <string.h>
#if defined (WIN32)
#include <stdio.h>
#endif

#if defined (NEW_FRAME)
#include "typedefs.h"
#include "gdi.h"
#include "dspl.h"
#include "font_bitmaps.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "p_mmi.h"
#include "tok.h"
#include "cst.h"
#include "os.h"

#else

#include "stddefs.h"
#include "gdi.h"
#include "dspl.h"
#include "font_bitmaps.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "p_mmi.h"
#include "vsi.h"
#include "tok.h"
#include "cst.h"
#endif
#include "rvf_api.h"
#ifndef _SIMULATION_
#include "r2d.h"
#include "r2d_config.h"
#endif
/* GW enable/disable trace using the MMI */
/* NB. Traces are only for diagnostics while developing and must be removed for code deliveries!*/
/* defining mmi_trace as <empty> will remove them */
//#define MMI_TRACE
#define mmi_trace
//void mmi_trace(char* str);
/*==== EXPORT =====================================================*/
#define ENCODE_OFFSET 24
//#define EASY_TEXT_ENABLED

#undef R2D_ENABLED
#ifndef _SIMULATION_

#if (defined(_TARGET_) && (BOARD!=10) && (BOARD!=34))
/*
 * R2D is not supported by EP2 module (BOARD == 10, of customer 6351/36)
 * and by Avenger2/Perseus1 board (BOARD == 34). (dbachran / 2002-11-27)
 */
#define R2D_ENABLED
#endif
#endif

/************************************************************************
* The following macros define what hardware we are running on and what 	*
* drivers are being used to drive the display							*
* BSAMPLE - 84x48 display												*
* CSAMPLE - 84x48 display												*
* CSAMPLE_COLOUR - no longer supported									*
* DSAMPLE - 176x220 display which can be driven as 16 bit colour or b+w	*
*      DSAMPLE_COLOUR - colour display 									*
*           DSAMPLE_COLOUR16 - 16 bits per pixel displayed 				*
*                              NB. This has not been tested at all - it	*
*                              may not display correctly or may crash	*
*                              although it does not crash when enabled 	*
*                              with the 32bit drivers)                	*
*                                                                       *
*           DSAMPLE_COLOUR32 - 32 bits per pixel displayed (16 bits are	*
*								 zero and have no effect)				*
*      DSAMPLE_LITE - 1 bit per pixel (b+w display)                    	*
* GW SPR#1840 25/03/03													*
* Also, the compiler switches have been added to allow us to develop  	*
* the MMI for a different final format (b+w/smaller display).			*
* COLOURDISPLAY - If not defined - all output is to be b+w				*
* LSCREEN - If not defined - screen is 'small' - use the 8x6 font 		*
*************************************************************************/
#if (defined(_TARGET_))
//#if (BOARD==33)
#if ((BOARD == 8) || (BOARD == 9))
#define CSAMPLE
#elif ((BOARD == 40) || (BOARD == 41))
#define DSAMPLE
#else
//Other board type
#define BSAMPLE
#endif
#else
//_TARGET_ not defined
//Not running on hardware - select the hw for simulation purposes.
#define BSAMPLE

//Also, if not already disabled - disable trace code
#ifdef MMI_TRACE
#undef MMI_TRACE
#endif
#endif



#ifdef DSAMPLE
//Select type of d-sample display (1 bit/16 bit or 32 bit colour depth
#if (R2D_LCD_DISPLAY == R2D_COLOR)
#define DSAMPLE_COLOUR

/*
   The data format for the LCD is either 16 bit or 32 bit
   To ensure that we notice problems at compile-time it is possible to
   have both DSAMPLE_COLOUR32 and DSAMPLE_COLOUR16 undefined.
   This will cause an error at compile time.
*/
#if (R2D_PIXEL_POS_TO_BIT_POS == 5)
#define DSAMPLE_COLOUR32
//define for test only #define DSAMPLE_COLOUR16
#endif

#if (R2D_PIXEL_POS_TO_BIT_POS == 4)
//Display is 16 bit colour - NOT TESTED with R2D drivers
#define DSAMPLE_COLOUR16

//GW - swap LSW/MSW round  PIXEL_0_IN_LSW

#endif

#else
//Display is b+w
#define DSAMPLE_LITE
#undef COLOURDISPLAY
#endif
#endif


//Ensure that if the H/W does not support colour, the compiler option is overridden
//- we can display b+w only on a colour display but not the other way round
#ifndef DSAMPLE_COLOUR
#ifdef COLOURDISPLAY
#undef COLOURDISPLAY
#endif
#endif


/*
USE_PLOT -	Defined if we are to use r2d_draw_point to output a display
			This method will always produce a display (of sorts) but can be very slow
USE_BLIT_RECT - Defined if we provide a 24 bit colour display and allow the riviera code to
				translate into the LCD format.
USE_BUFFER - 	This must be defined if USE_BLIT_RECT is being used. This will require an image
				of the colour display to be stored in local memory.

If neither are defined then we must create our buffer in the same format as the LCD.
NB if 'USE_BLIT_RECT' is not defined, any changes to the h/w or driver software will have an
impact on the code below.

*/

/*==== CONSTANTS ==================================================*/
static const int translation_ascii_2_unicode[256] = { 
	0x0000, 0x00A4, 0x00d8, 0xFFFF, 0x0394, 0x03A8, 0x00BF, 0x00F8, 0xFFFF, 0xFFFF, 0x000A, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
	0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
	0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026,0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
	0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
	0x0040,0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
	0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x005F, 
	0xFFFF, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
	0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,

	0xFFFF, 0x00C7, 0x00FC, 0x00E9, 0x00E4, 0x00E0, 0x00E5, 0xFFFF, 0xFFFF, 0xFFFF, 0x00E8, 0xFFFF, 0xFFFF, 0x00EC, 0x00C4, 0x00C5, 
	0x00C9, 0x00E6, 0x00C6, 0xFFFF, 0x00F6, 0x00F2, 0xFFFF, 0x00F9, 0xFFFF, 0x00D6, 0x00DC, 0xFFFF, 0x00A3, 0x00A5, 0xFFFF, 0xFFFF,
	0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x00F1, 0x00D1, 0xFFFF, 0xFFFF, 0x00A7, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x00A1, 0xFFFF, 0xFFFF,
	0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
	0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
	0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
	0xFFFF, 0x00DF, 0x0393, 0x03A0, 0x03A3, 0xFFFF, 0xFFFF, 0xFFFF, 0x03A6, 0x0398, 0x03A9, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x039B, 
	0x039E, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF
	
	};
/*==== VARIABLES ==================================================*/
//EXTERN UBYTE        extDisplay;          /* external display ? */
EXTERN UBYTE        extDisplay;          /* external display ? */
GLOBAL UBYTE dspl_char_type;


/*
 * We don't need display.c with ACI-only builds, but CST references extDisplay
 * above, so we need to keep that one for now.
 * Only process this file, if MMI is set to 1 (SMI) or 2 (BMI).
 */
#if (MMI != 0)

GLOBAL dspl_DevCaps displayData;
#if defined (NEW_FRAME)
EXTERN T_HANDLE       hCommL1;
#else
EXTERN T_VSI_CHANDLE  hCommL1;
#endif

static int scrEnabled = 0;              /* screen update enable     */
static int txtInvert = 0;         //Text invert

static T_HANDLE mmi_handle;
static T_HANDLE hCommMMI = VSI_ERROR;

/*==== FUNCTIONS ==================================================*/
/*
 * send to external Display
 */
LOCAL void dspl_SendDisplayReq (USHORT x, USHORT y, char *text);
GLOBAL void kbd_test (UBYTE key);

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

GLOBAL void rt_ExtPrimitive ( USHORT TaskHandle, USHORT DestComHandle,
                              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);
LOCAL  void scrText      (int x, int y, char *txt);
LOCAL  void scrText_Unicode      (int x, int y, USHORT *txt);
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);
LOCAL  int  scrFntGetLen (char *tp, int nChars);
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);
LOCAL  int  scrUpdate    (int onOff);

LOCAL  void scrText_Invert_Unicode (int x, int y, USHORT *txt); /*kk*/

LOCAL int checkPixelColour(int px, int py, U32 col);
LOCAL void scrLCDUpdate (void);

void scrText_Invert (int x, int y, char *txt);

void scrDrawFilledRect (int px, int py, int sx, int sy, U32 col);

int scrGetRealLength(char *str, int* totChar, int* totPixel);





void dspl_show_bitmap(int x, int y,t_font_bitmap* current_bitmap,U32 attr );




GLOBAL UBYTE dspl_SetWindow(USHORT   in_X1,
                         USHORT   in_Y1,
                         USHORT   in_X2,
                         USHORT   in_Y2);







/*==== 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
   */
  displayData.DisplayType = DSPL_TYPE_CHARACTER;

  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();
}

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

⌨️ 快捷键说明

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