Пример #1
0
/********************************************************************
*
*       _SendToPrinter
*
* Function description
*   Shows the contents of a memory device on the display
*   In "real life", this routine would send the contents of the memory
*   device to the printer.
*/
static void _SendToPrinter(GUI_MEMDEV_Handle hMem, int yOff) {
  int xSize, ySize, x, y, Offset, Bit;
  U8 * pData;
  /* Get the size of the memory device */
  xSize = GUI_MEMDEV_GetXSize(hMem);
  ySize = GUI_MEMDEV_GetYSize(hMem);
  pData = (U8 *)GUI_MEMDEV_GetDataPtr(hMem); /* Get the data pointer of the memory device */
  /* Draw the pixels of the memory device on the screen */
  for (y = 0; y < ySize; y++) {
    for (x = 0; x < xSize; x++) {
      U8 Index;
      Offset = x >> 3;
      Bit    = 7 - (x & 7);
      Index  = *(pData + Offset);
      Index &= (1 << Bit);
      /* The index could be 0 or 1, so use black and white */
      if (Index == 0 ) {
        GUI_SetColor(GUI_BLACK);
      } else {
        GUI_SetColor(GUI_WHITE);
      }
       /* Draw the pixel. At this point for example a printer output routine can be called */              
      GUI_DrawPixel(x, y + yOff);
    }
    pData += (xSize + 7) / 8;
  }
}
Пример #2
0
/*********************************************************************
*
*       _DrawBkCircle
*/
static void _DrawBkCircle(int DrawLogo) {
  static GUI_MEMDEV_Handle   hMemStretch;
  GUI_MEMDEV_Handle          hMemGradient;
  GUI_MEMDEV_Handle          hMemCircle;
  GUI_MEMDEV_Handle          hMemOld;
  int                        CircleWidth;
  int                        ySizeV;
  int                        xSize;
  int                        ySize;
  int                        i;
  U32                      * pData;

  xSize  = LCD_GetXSize();
  ySize  = LCD_GetYSize();
  ySizeV = LCD_GetVYSize();
  if (ySizeV > ySize) {
    GUI_SetBkColor(BK_COLOR_1);
    GUI_ClearRect(0, 0, xSize, ySizeV);
  }
  if (hMemStretch == 0) {
    CircleWidth  = (CIRCLE_RADIUS << 1) + 1;
    hMemCircle   = GUI_MEMDEV_CreateFixed(0, 0, CircleWidth, CircleWidth,   GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUI_COLOR_CONV_8888);
    hMemStretch  = GUI_MEMDEV_CreateEx   (0, 0, xSize,       ySize,         GUI_MEMDEV_NOTRANS);
    hMemGradient = GUI_MEMDEV_CreateFixed(0, 0, 1,           CIRCLE_RADIUS, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUI_COLOR_CONV_8888);
    //
    // Initialize background
    //
    hMemOld = GUI_MEMDEV_Select(hMemCircle);
    GUI_SetBkColor(BK_COLOR_1);
    GUI_Clear();
    //
    // Create Gradient
    //
    GUI_MEMDEV_Select(hMemGradient);
    GUI_DrawGradientV(0, 0, 0, CIRCLE_RADIUS, BK_COLOR_0, BK_COLOR_1);
    //
    // Get color and draw circles
    //
    pData = (U32 *)GUI_MEMDEV_GetDataPtr(hMemGradient);
    GUI_MEMDEV_Select(hMemCircle);
    for (i = 0; i < CIRCLE_RADIUS; i++, pData++) {
      GUI_SetColor(*pData);
      GUI_DrawCircle(CIRCLE_RADIUS, CIRCLE_RADIUS, i);
    }
    //
    // Stretch and display
    //
    GUI_MEMDEV_Select(hMemStretch);
    GUI_MEMDEV_DrawPerspectiveX(hMemCircle, 0, 0, ySize, ySize, xSize, 0);
    GUI_MEMDEV_Delete(hMemCircle);
    GUI_MEMDEV_Delete(hMemGradient);
    GUI_MEMDEV_Select(hMemOld);
  }
  GUI_MEMDEV_Write(hMemStretch);
  if (DrawLogo) {
    GUI_DrawBitmap(&bmSTLogo70x35, LOGO_DIST_BORDER, LOGO_DIST_BORDER);
  }
}
Пример #3
0
/**
  * @brief  Update the text area display
  * @param  None
  * @retval None
  */
void USER_LCD_LOG_UpdateDisplay (void)
{
  #ifndef __USER_USE_SOLID_BK_
  GUI_MEMDEV_Handle tempMem;    
  void *pbk;
  void *ptemp; 
  #endif
  uint8_t cnt = 0 ;
  uint16_t length = 0 ;
  uint16_t ptr = 0, index = 0;
  if((USER_LCD_CacheBuffer_yptr_bottom  < (USER_YWINDOW_SIZE -1)) && 
     (USER_LCD_CacheBuffer_yptr_bottom  >= USER_LCD_CacheBuffer_yptr_top))
  {
    if(u8_enable_display)
    {
      USER_LCD_LOG_DisplayStringAtLine ((USER_YWINDOW_MIN + Y0/GUI_GetFontSizeY()+ USER_LCD_CacheBuffer_yptr_bottom),
                           (char *)(USER_LCD_CacheBuffer[cnt + USER_LCD_CacheBuffer_yptr_bottom].line),
                             USER_LCD_CacheBuffer[cnt + USER_LCD_CacheBuffer_yptr_bottom].color);
    }
  }
  else
  {
    if(USER_LCD_CacheBuffer_yptr_bottom < USER_LCD_CacheBuffer_yptr_top)
    {
      /* Virtual length for rolling */
      length = USER_LCD_CACHE_DEPTH + USER_LCD_CacheBuffer_yptr_bottom ;
    }
    else
    {
      length = USER_LCD_CacheBuffer_yptr_bottom;
    }
    
    ptr = length - USER_YWINDOW_SIZE + 1;

    GUI_SetFont(&USER_LCD_LOG_TEXT_FONT);
    #ifdef __USER_USE_SOLID_BK_ 
    for  (cnt = 0 ; cnt < USER_YWINDOW_SIZE ; cnt ++)
      {        
        index = (cnt + ptr )% USER_LCD_CACHE_DEPTH ;
        if(u8_enable_display)
        {
          USER_LCD_LOG_DisplayStringAtLine ((cnt + Y0/(GUI_GetFontSizeY()) + USER_YWINDOW_MIN), 
                               (char *)(USER_LCD_CacheBuffer[index].line),
                                 USER_LCD_CacheBuffer[index].color); 
        }                       
      }
    #else 
    tempMem=GUI_MEMDEV_Create(GUI_MEMDEV_GetXPos(backgroundDisplayMem),GUI_MEMDEV_GetYPos(backgroundDisplayMem),GUI_MEMDEV_GetXSize(backgroundDisplayMem),GUI_MEMDEV_GetYSize(backgroundDisplayMem));
    if(tempMem)
    {
      pbk=GUI_MEMDEV_GetDataPtr(backgroundDisplayMem);
      ptemp=GUI_MEMDEV_GetDataPtr(tempMem);
    
      memcpy((uint8_t *)ptemp,(uint8_t *)pbk,4*GUI_MEMDEV_GetXSize(backgroundDisplayMem)*GUI_MEMDEV_GetYSize(backgroundDisplayMem));

      GUI_MEMDEV_Select(backgroundDisplayMem);
      
      for  (cnt = 0 ; cnt < USER_YWINDOW_SIZE ; cnt ++)
      {        
        index = (cnt + ptr )% USER_LCD_CACHE_DEPTH ;
        if(u8_enable_display)
        {
          USER_LCD_LOG_DisplayStringAtLine ((cnt + Y0/(GUI_GetFontSizeY()) + USER_YWINDOW_MIN), 
                               (char *)(USER_LCD_CacheBuffer[index].line),
                                 USER_LCD_CacheBuffer[index].color); 
        }                       
      }
      
      GUI_MEMDEV_CopyToLCD(backgroundDisplayMem);
      GUI_MEMDEV_Select(0);
      
      memcpy((uint8_t *)pbk,(uint8_t *)ptemp,4*GUI_MEMDEV_GetXSize(backgroundDisplayMem)*GUI_MEMDEV_GetYSize(backgroundDisplayMem));
      GUI_MEMDEV_Delete(tempMem);
      tempMem=0;
    }
    #endif
      
  }
  
}
Пример #4
0
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  WM_HWIN hWin;
  GUI_MEMDEV_Handle hMemWin;  // Memory device to be used in window
  GUI_MEMDEV_Handle hMemDraw; // Memory device for drawing operation
  U32 * pDataWin;
  U32 * pDataDraw;
  int i, yPos, Cnt, xSizeWindow, ySizeWindow, xPosWindow, yPosWindow, xSizeDisplay, ySizeDisplay;
  GUI_RECT Rect;

  xSizeDisplay = LCD_GetXSize();
  ySizeDisplay = LCD_GetYSize();
  xSizeWindow = 100;
  ySizeWindow = 100;
  xPosWindow = (xSizeDisplay - xSizeWindow) / 2;
  yPosWindow = (ySizeDisplay - ySizeWindow) / 2;
  Cnt = 0;
  Rect.y0 = 0;
  Rect.y1 = ySizeWindow - 1;
  WM_SetCreateFlags(WM_CF_MEMDEV);
  GUI_Init();
  WM_SetCallback(WM_HBKWIN, _cbBk);
  //
  // Create window
  //
  hWin = WINDOW_CreateUser(xPosWindow, yPosWindow, xSizeWindow, ySizeWindow, 0, WM_CF_SHOW, 0, 0, _cbWin, sizeof(hMemWin));
  //
  // Create a memory device for the window
  //
  hMemWin = GUI_MEMDEV_CreateFixed(0, 0, 100, 100, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUICC_8888);
  //
  // Attach memory device to window data
  //
  WINDOW_SetUserData(hWin, &hMemWin, sizeof(hMemWin));
  //
  // Create small memory device for drawing one line of gradient data
  // representing the real data to be used
  //
  hMemDraw = GUI_MEMDEV_CreateFixed(xPosWindow, yPosWindow, 1, ySizeWindow, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUICC_8888);
  //
  // Initialize random value
  //
  yPos = rand() % ySizeWindow;
  while (1) {
    //
    // Create some data to be added to the windows memory device
    //
    GUI_MEMDEV_Select(hMemDraw);
    GUI_DrawGradientV(xPosWindow, yPosWindow, xPosWindow, yPosWindow + yPos, GUI_RED, GUI_YELLOW);
    GUI_MEMDEV_Select(0);
    //
    // Get data pointers immediately before accessing data
    //
    pDataWin  = GUI_MEMDEV_GetDataPtr(hMemWin);
    pDataDraw = GUI_MEMDEV_GetDataPtr(hMemDraw);
    //
    // Initially clear memory device
    //
    if (Cnt == 0) {
      memset(pDataWin, 0, sizeof(U32) * xSizeWindow * ySizeWindow);
      WM_InvalidateWindow(hWin);
    }
    //
    // Copy data from drawing device into windows memory device
    //
    for (i = 0, pDataWin += xSizeWindow * (ySizeWindow - 1) + Cnt; i <= yPos; i++, pDataWin -= xSizeWindow, pDataDraw++) {
      *pDataWin = *pDataDraw;
    }
    //
    // Optimized invalidating, only the new line will be drawn
    //
    Rect.x0 = Rect.x1 = Cnt;
    WM_InvalidateRect(hWin, &Rect);
    //
    // Increment counter
    //
    Cnt++;
    Cnt = (Cnt >= 100) ? 0 : Cnt;
    //
    // Modify random value
    //
    yPos += (rand() % 5) - 2;
    yPos = (yPos < 0) ? 0 : (yPos >= ySizeWindow) ? ySizeWindow - 1 : yPos;
    //
    // Wait a while and redraw window
    //
    GUI_Delay(50);
  }
}