Exemple #1
0
static void _InitController(unsigned LayerIndex) {
  //
  // Set display size and video-RAM address
  //
  LCD_SetSizeEx (XSIZE_PHYS, YSIZE_PHYS, LayerIndex);
  LCD_SetVSizeEx(VXSIZE_PHYS, VYSIZE_PHYS, LayerIndex);
  LCD_SetVRAMAddrEx(LayerIndex, (void*)LCD_VRAM_BASE_ADDR);
  //
  // Init LCD
  //

#if GUI_SUPPORT_TOUCH  // Used when touch screen support is enabled
  {
    U32 TouchOrientation;
    TouchOrientation = (GUI_MIRROR_X * LCD_GetMirrorXEx(0)) |
                       (GUI_MIRROR_Y * LCD_GetMirrorYEx(0)) |
                       (GUI_SWAP_XY  * LCD_GetSwapXYEx (0)) ;
    GUI_TOUCH_SetOrientation(TouchOrientation);
    if (LCD_GetSwapXYEx(0)) {
      GUI_TOUCH_Calibrate(GUI_COORD_X, 0, XSIZE_PHYS, TOUCH_AD_LEFT, TOUCH_AD_RIGHT);   // x axis swapped
      GUI_TOUCH_Calibrate(GUI_COORD_Y, 0, YSIZE_PHYS, TOUCH_AD_TOP , TOUCH_AD_BOTTOM);  // y axis swapped
    } else {
      GUI_TOUCH_Calibrate(GUI_COORD_X, 0, XSIZE_PHYS, TOUCH_AD_LEFT, TOUCH_AD_RIGHT);   // x axis
      GUI_TOUCH_Calibrate(GUI_COORD_Y, 0, YSIZE_PHYS, TOUCH_AD_TOP , TOUCH_AD_BOTTOM);  // y axis
    }
  }
#endif
}
/*********************************************************************
*
*       _InitController
*
* Function description:
*   Initializes the LCD controller and touch screen
*
*/
static void _InitController(unsigned LayerIndex) {
  //
  // Set display size and video-RAM address
  //
  LCD_SetSizeEx (XSIZE_PHYS, YSIZE_PHYS, LayerIndex);
  LCD_SetVSizeEx(VXSIZE_PHYS, VYSIZE_PHYS, LayerIndex);
  LCD_SetVRAMAddrEx(LayerIndex, (void*)LCD_VRAM_BASE_ADDR);
  //
  // Init LCD
  //
  GLCD_Init();

#if GUI_SUPPORT_TOUCH  // Used when touch screen support is enabled
  {
    U32 TouchOrientation;
    U32 pclk;

    //
    // Initialize touch screen
    //
    LPC_SC->PCONP |= (1 << 12);  // Enable clock for ADC
    LPC_ADC->CR    = 0
                     | (1          <<  1)  // Sel AD0[1]
                     | (ADC_CLKDIV <<  8)
                     | (1          << 21)  // Enable ADC
                     ;
    //
    // Calibrate touch
    //
    TouchOrientation = (GUI_MIRROR_X * LCD_GetMirrorXEx(0)) |
                       (GUI_MIRROR_Y * LCD_GetMirrorYEx(0)) |
                       (GUI_SWAP_XY  * LCD_GetSwapXYEx (0)) ;
    GUI_TOUCH_SetOrientation(TouchOrientation);
    if (LCD_GetSwapXYEx(0)) {
      GUI_TOUCH_Calibrate(GUI_COORD_X, 0, XSIZE_PHYS, TOUCH_AD_LEFT, TOUCH_AD_RIGHT);   // x axis swapped
      GUI_TOUCH_Calibrate(GUI_COORD_Y, 0, YSIZE_PHYS, TOUCH_AD_TOP , TOUCH_AD_BOTTOM);  // y axis swapped
    } else {
      GUI_TOUCH_Calibrate(GUI_COORD_X, 0, XSIZE_PHYS, TOUCH_AD_LEFT, TOUCH_AD_RIGHT);   // x axis
      GUI_TOUCH_Calibrate(GUI_COORD_Y, 0, YSIZE_PHYS, TOUCH_AD_TOP , TOUCH_AD_BOTTOM);  // y axis
    }
    //
    // Start touch timer
    //
    LPC_SC->PCONP |= (0x1<<2);
    pclk = SystemCoreClock/4;
    LPC_TIM1->PR  = pclk/1000000; /* Set prescaler to get 1 M counts/sec */
    LPC_TIM1->MR0 = 1000 * TOUCH_TIMER_INTERVAL;
    LPC_TIM1->MCR = (0x3<<0);	    /* Interrupt and Reset on MR0 */
    NVIC_EnableIRQ(TIMER1_IRQn);
    LPC_TIM1->TCR = 1;            /* Enable timer 1 */
  }
#endif
}
Exemple #3
0
/*********************************************************************
*
*       LCD_X_Config
*
* Function description:
*   Called during the initialization process in order to set up the
*   display driver configuration.
*
*/
void LCD_X_Config(void) {
  GUI_DEVICE * pDevice;
  CONFIG_FLEXCOLOR Config = {0};
  GUI_PORT_API PortAPI = {0};
  //
  // Set display driver and color conversion
  //
  pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_565, 0, 0);
  //
  // Display driver configuration, required for Lin-driver
  //
  LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
  LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
  //
  // Orientation
  //
  	Config.FirstCOM = 0;   //modify by xiaoku                                        
	Config.FirstSEG = 0;   //modify by xiaoku                                     
	//Config.Orientation = GUI_MIRROR_Y|GUI_MIRROR_X;  //modify by xiaoku 竖屏                  
	// Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;  //modify by xiaoku 横屏                  
	Config.NumDummyReads = 2;  //modify by xiaoku  读取的第二个数据才是真实数据 

  GUIDRV_FlexColor_Config(pDevice, &Config);
  //
  // Set controller and operation mode
  //
  PortAPI.pfWrite16_A0  = LcdWriteReg;
  PortAPI.pfWrite16_A1  = LcdWriteData;
  PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
  PortAPI.pfReadM16_A1  = LcdReadDataMultiple;
  //GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66708, GUIDRV_FLEXCOLOR_M16C0B16);
  GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B16);	  //modify by xiaoku



  /* modify by fire 设置触摸原点 */ 
	GUI_TOUCH_SetOrientation((GUI_MIRROR_X * LCD_GetMirrorXEx(0)) | 
                         	(GUI_MIRROR_Y * LCD_GetMirrorYEx(0)) | 
							(GUI_SWAP_XY  * LCD_GetSwapXYEx (0))); 
 
 /* modify by fire 设置触摸校准 */ 
 GUI_TOUCH_Calibrate(GUI_COORD_X, 0, 240-1,TOUCH_AD_LEFT ,TOUCH_AD_RIGHT ); 
 GUI_TOUCH_Calibrate(GUI_COORD_Y, 0, 320-1,TOUCH_AD_TOP , TOUCH_AD_BOTTOM); 



}
/*********************************************************************
*
*       _LCDBench
*/
static void _LCDBench(void) {
  GUI_POINT   Point;
  float       aPixelrateBitmap[5] = {0, 0, 0, 0, 0};
  float       PixelrateBigFont;
  float       PixelrateF6x8;
  float       FillratePPS;
  char      * s;
  char        ac[80];
  int         BitsPerPixel;
  int         xSizeString;
  int         ySizeFont;
  int         NumColors;
  int         MirrorX;
  int         MirrorY;
  int         SwapXY;
  int         xSize;
  int         ySize;

  BitsPerPixel = LCD_GetBitsPerPixelEx(0);
  xSize        = LCD_GetXSizeEx(0);
  ySize        = LCD_GetYSizeEx(0);
  MirrorX      = LCD_GetMirrorXEx(0);
  MirrorY      = LCD_GetMirrorYEx(0);
  SwapXY       = LCD_GetSwapXYEx(0);
  NumColors    = (1 << BitsPerPixel);
  _InitXbppDDP();
  //
  // Say hi !
  //
  GUI_X_Log("\nLCD driver benchmark. All values are  \xb5""s/pixel");
  GUI_X_Log("\nLower values are better.");
  GUI_SetBkColor(GUI_RED);
  GUI_SetColor(GUI_WHITE);
  GUI_Clear();
  GUI_SetFont(&GUI_FontComic18B_1);
  GUI_DispStringHCenterAt("LCD driver", xSize / 2, ySize / 3 - 10);
  GUI_DispStringHCenterAt("Benchmark" , xSize / 2, ySize / 3 + 20);
  GUI_Delay(1000);
  GUI_SetBkColor(GUI_BLACK);
  GUI_Clear();
  GUI_SetLBorder(1);
  //
  // Log color depth, controller, orientation and cache
  //
  sprintf(ac, "\nColor depth: %d", BitsPerPixel);
  GUI_X_Log(ac);
  sprintf(ac, "\nOrientation: LCD_MIRROR_X = %d, LCD_MIRROR_Y = %d, LCD_SWAP_XY = %d", MirrorX, MirrorY, SwapXY);
  GUI_X_Log(ac);
  //
  // Measure filling
  //
  Point.x             = xSize;
  Point.y             = ySize;
  FillratePPS         = _Measure(&_ExecFill, &Point)  * (float)(2 * ((U32)xSize - 4) * ((U32)ySize - 4));
  sprintf(ac, "\nFill: %f", (float)1E6 / FillratePPS);
  GUI_X_Log(ac);
  //
  // Measure small font
  //
  GUI_SetFont(&GUI_Font6x8);
  s                   = _acSmall;
  xSizeString         = GUI_GetStringDistX(s);
  ySizeFont           = GUI_GetFontSizeY();
  PixelrateF6x8       = _Measure(&_ExecSmallFont, s)  * (float)2 * xSizeString * ySizeFont * 8;
  sprintf(ac, "\nF6x8: %f", (float)1E6 / PixelrateF6x8);
  GUI_X_Log(ac);
  //
  // Measure big font
  //
  GUI_SetFont(&GUI_FontComic18B_ASCII);
  s                   = _acBig;
  xSizeString         = GUI_GetStringDistX(s);
  ySizeFont           = GUI_GetFontSizeY();
  PixelrateBigFont    = _Measure(&_ExecBigFont, s)    * (float)2 * xSizeString * ySizeFont * 2;
  sprintf(ac, "\nFBig: %f", (float)1E6 / PixelrateBigFont);
  GUI_X_Log(ac);
  //
  // Measure 1bpp bitmap
  //
  aPixelrateBitmap[0] = _Measure(&_Exec1bpp, NULL)    * (float)2 * _bm_1bpp_58x8.XSize * 8;
  sprintf(ac, "\n1bpp: %f", (float)1E6 / aPixelrateBitmap[0]);
  GUI_X_Log(ac);
  //
  // Measure 2bpp bitmap
  //
  aPixelrateBitmap[1] = _Measure(&_Exec2bpp, NULL)    * (float)2 * _bm_2bpp_32x11.XSize * 11;
  sprintf(ac, "\n2bpp: %f", (float)1E6 / aPixelrateBitmap[1]);
  GUI_X_Log(ac);
  //
  // Measure 4bpp bitmap
  //
  aPixelrateBitmap[2] = _Measure(&_Exec4bpp, NULL)    * (float)2 * _bm_4bpp_32x11.XSize * 11;
  sprintf(ac, "\n4bpp: %f", (float)1E6 / aPixelrateBitmap[2]);
  GUI_X_Log(ac);
  //
  // Measure 8bpp bitmap
  //
  aPixelrateBitmap[3] = _Measure(&_Exec8bpp, NULL)    * (float)2 * _bm_8bpp_32x11.XSize * 11;
  sprintf(ac, "\n8bpp: %f", (float)1E6 / aPixelrateBitmap[3]);
  GUI_X_Log(ac);
  //
  // Measure device dependent bitmap
  //
  aPixelrateBitmap[4] = _Measure(&_ExecXbppDDP, NULL) * (float)2 * XSIZE_XBPP * YSIZE_XBPP;
  sprintf(ac, "\nXDDP: %f", (float)1E6 / aPixelrateBitmap[4]);
  GUI_X_Log(ac);
  //
  // Show results on display
  //
  GUI_Clear();
  if (xSize < 320) {
    GUI_SetFont(&GUI_Font6x8);
  } else {
    GUI_SetFont(&GUI_Font8x16);
  }
  GUI_GotoXY(0, 0);
  GUI_DispDecMin(BitsPerPixel);
  GUI_DispString(" bpp, ");
  GUI_DispDecMin(NumColors);
  GUI_DispString(" colors\n\nMIRROR_X ");
  GUI_DispDecMin(MirrorX);
  GUI_DispString(", MIRROR_Y ");
  GUI_DispDecMin(MirrorY);
  GUI_DispString(", SWAPXY ");
  GUI_DispDecMin(SwapXY);
  GUI_SetLBorder(1);
  GUI_SetFont(&GUI_Font6x8);
  GUI_DispChar('\n');
  _DispFillrate("\nFill: ", FillratePPS,         " Fill");
  _DispFillrate("\nF6x8: ", PixelrateF6x8,       " F6x8");
  _DispFillrate("\nFBig: ", PixelrateBigFont,    " FComic18");
  _DispFillrate("\n1bpp: ", aPixelrateBitmap[0], " Bitmap 1bpp");
  _DispFillrate("\n2bpp: ", aPixelrateBitmap[1], " Bitmap 2bpp");
  _DispFillrate("\n4bpp: ", aPixelrateBitmap[2], " Bitmap 4bpp");
  _DispFillrate("\n8bpp: ", aPixelrateBitmap[3], " Bitmap 8bpp");
  _DispFillrate("\nXDDP: ", aPixelrateBitmap[4], " 8/16bppDDP");
}