/*********************************************************************
*
*       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);
  }
}
void GUIDEMO_Bitmap(void) {
    int XSize = LCD_GetXSize();
    int YSize = LCD_GetYSize();
    GUIDEMO_ShowIntro("Bitmaps",
                      "Showing"
                      "\ndifferent bitmaps with"
                      "\nand without compression");
    GUI_SetBkColor(GUI_BLUE);
    GUI_Clear();
#if GUI_WINSUPPORT & GUI_SUPPORT_MEMDEV
    WM_EnableMemdev(WM_HBKWIN);
#endif
#if GUIDEMO_LARGE
    GUI_DrawBitmap(&_bmLadyBug, 20, 50);
    GUI_SetFont(&GUI_Font13_1);
    GUI_DispStringAt("RLE Compressed bitmaps", 10, 10);
    GUIDEMO_Wait();
    GUI_Clear();
    GUI_DispStringAt("1/2/4/8 bpp bitmaps", 10, 10);
    GUI_DrawBitmap(&GUIDEMO_bm4bpp, 20, 50);
    GUIDEMO_Delay(4000);
    GUIDEMO_NotifyStartNext();
    /* Tile display with image */
    {
        int ix, iy;
        for (ix = 0; ix < XSize / GUIDEMO_bm4bpp.XSize + 1; ix++) {
            for (iy = 0; iy < YSize / GUIDEMO_bm4bpp.YSize + 1; iy++) {
                GUI_DrawBitmap(&GUIDEMO_bm4bpp,
                               GUIDEMO_bm4bpp.XSize * ix ,
                               GUIDEMO_bm4bpp.YSize * iy);
            }
        }
    }
    GUIDEMO_Delay(2000);
    GUIDEMO_NotifyStartNext();
    GUIDEMO_ShowInfo("Bitmaps may also be\nmagnified and rotated");
    GUI_SetTextMode(GUI_TM_TRANS);
    GUI_SetFont(&GUI_Font16_1);
    {
        int i, tm;
        double xMul, Angle;
        for (i = 200; (i < 3000) && !GUIDEMO_CheckCancel();) {
            tm = GUI_GetTime();
            GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, i, i);
            GUI_DispStringHCenterAt("Bitmaps can be magnified...", XSize / 2, 100);
            GUI_Exec();
            while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel());
            i += (GUI_GetTime() - tm) * 6;
        }
        GUIDEMO_Delay(2000);
        GUIDEMO_NotifyStartNext();
        GUI_Clear();
        GUI_DispStringHCenterAt("...and rotated.", XSize / 2, ((YSize + GUIDEMO_bm4bpp.YSize) >> 1) + 5);
        for (Angle = 0; Angle < PI4 && !GUIDEMO_CheckCancel();) {
            tm = GUI_GetTime();
            xMul = cos(Angle) * 1000;
            GUI_ClearRect((XSize - GUIDEMO_bm4bpp.XSize) >> 1, (YSize - GUIDEMO_bm4bpp.YSize) >> 1, (XSize + GUIDEMO_bm4bpp.XSize) >> 1, (YSize + GUIDEMO_bm4bpp.YSize) >> 1);
            GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, xMul, 1000);
            GUI_Exec();
            while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel());
            Angle += (GUI_GetTime() - tm) / 250.0f;
        }
        GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, 1000, 1000);
    }
    GUIDEMO_Wait();
#else
    {
        const GUI_BITMAP * pBm;
        int TextModeOld = GUI_SetTextMode(GUI_TM_XOR);
        GUI_SetFont(&GUI_Font8_ASCII);
        pBm = &_bmLadyBug;
        GUI_DrawBitmap(pBm, (XSize - (int)pBm->XSize) / 2, (YSize - (int)pBm->YSize) / 2);
        GUI_DispStringAt("RLE Compressed bitmaps", 8, 10);
        GUIDEMO_Wait();
        GUI_Clear();
        GUI_SetTextMode(GUI_TM_TRANS);
        pBm = &GUIDEMO_bm4bpp;
        GUI_DrawBitmap(pBm, (XSize - (int)pBm->XSize) / 2, (YSize - (int)pBm->YSize) / 2);
        GUI_DispStringAt("1/2/4/8 bpp bitmaps", 8, 10);
        GUIDEMO_Wait();
        GUI_Clear();
        {
            int i, tm;
            double xMul, Angle;
            for (i = 200; (i < 2000) && !GUIDEMO_CheckCancel();) {
                tm = GUI_GetTime();
                GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, i, i);
                GUI_DispStringAt("Bitmaps can be magnified...", 8, 10);
                GUI_Exec();
                while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel());
                i += (GUI_GetTime() - tm) * 6;
            }
            GUIDEMO_Delay(2000);
            GUIDEMO_NotifyStartNext();
            GUI_Clear();
            for (Angle = 0; Angle < PI4 && !GUIDEMO_CheckCancel();) {
                tm = GUI_GetTime();
                xMul = cos(Angle) * 1000;
                GUI_ClearRect((XSize - GUIDEMO_bm4bpp.XSize) >> 1, (YSize - GUIDEMO_bm4bpp.YSize) >> 1, (XSize + GUIDEMO_bm4bpp.XSize) >> 1, (YSize + GUIDEMO_bm4bpp.YSize) >> 1);
                GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, xMul, 1000);
                GUI_DispStringAt("...and rotated.", 8, 10);
                GUI_Exec();
                while ((GUI_GetTime() < (tm + 10)) && !GUIDEMO_CheckCancel());
                Angle += (GUI_GetTime() - tm) / 250.0f;
            }
            GUI_DrawBitmapEx(&GUIDEMO_bm4bpp, XSize / 2, YSize / 2, GUIDEMO_bm4bpp.XSize / 2, GUIDEMO_bm4bpp.YSize / 2, 1000, 1000);
            GUI_DispStringAt("...and rotated.", 8, 10);
        }
        GUIDEMO_Wait();
        GUI_SetTextMode(TextModeOld);
    }
#endif
#if GUI_WINSUPPORT & GUI_SUPPORT_MEMDEV
    WM_DisableMemdev(WM_HBKWIN);
#endif
}
/*********************************************************************
*
*       _DrawJPEGs
*
* Function description
*   Draws the given JPEG image.
*/
static void _DrawJPEGs(const char * sFileName) {
  static int      i;
  const char      acError[] = "There is possibly not enough memory to display this JPEG image.\n\nPlease assign more memory to emWin in GUIConf.c.";
  GUI_JPEG_INFO   Info;
  GUI_RECT        Rect;
  HANDLE          hFile;
  DWORD           NumBytesRead;
  DWORD           FileSize;
  char          * pFile;
  int             xSize,  ySize;
  int             xPos,   yPos;
  int             r;

  xSize = LCD_GetXSize();
  ySize = LCD_GetYSize();
  //
  // Display file name.
  //
  Rect.x0 = BORDER_SIZE;
  Rect.y0 = TITLE_HEIGHT;
  Rect.x1 = xSize - BORDER_SIZE - 1;
  Rect.y1 = YPOS_IMAGE - 1;
  GUI_ClearRectEx(&Rect);
  GUI_SetTextMode(GUI_TM_NORMAL);
  GUI_SetFont(&GUI_Font8x16);
  GUI_DispStringInRectWrap(sFileName, &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER, GUI_WRAPMODE_CHAR);
  //
  // Clear the area in which the JPEG files are displayed.
  //
  Rect.x0 = BORDER_SIZE;
  Rect.y0 = YPOS_IMAGE;
  Rect.x1 = xSize - BORDER_SIZE - 1;
  Rect.y1 = ySize - BORDER_SIZE - 1;
  GUI_ClearRectEx(&Rect);
  //
  // Load image.
  //
  hFile    = CreateFile(sFileName, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  FileSize = GetFileSize(hFile, NULL);
  pFile    = malloc(FileSize);
  ReadFile(hFile, pFile, FileSize, &NumBytesRead, NULL);
  CloseHandle(hFile);
  //
  // Check if the current JPEG image fits on the screen.
  //
  GUI_JPEG_GetInfo(pFile, FileSize, &Info);
  xSize -= BORDER_SIZE * 2 + 1;
  ySize -= YPOS_IMAGE + BORDER_SIZE + 1;
  //
  // Display the image centered.
  //
  xPos = BORDER_SIZE + (xSize - Info.XSize) / 2;
  yPos = YPOS_IMAGE  + (ySize - Info.YSize) / 2;
  GUI_SetClipRect(&Rect);
  r = GUI_JPEG_Draw(pFile, FileSize, xPos, yPos);
  GUI_SetClipRect(NULL);
  if (r) {
    //
    // The image could not be displayed successfully. Show an error message.
    //
    GUI_DispStringInRectWrap(acError, &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER, GUI_WRAPMODE_WORD);
  } else {
    GUI_Delay(2000);
    if ((Info.XSize > xSize) || (Info.YSize > ySize)) {
      //
      // Inform the user about the possibility of scaling JPEG images.
      //
      if (i == 0) {
        GUI_ClearRectEx(&Rect);
        GUI_DispStringInRectWrap("JPEG images can be scaled as it is shown in 2DGL_JPEG_DrawScaled.c.",  &Rect, GUI_TA_BOTTOM | GUI_TA_HCENTER, GUI_WRAPMODE_WORD);
        GUI_Delay(3000);
      }
      i++;
      if (i == NUM_IMAGES_UNTIL_HINT) {
        i = 0;
      }
    }
  }
  free(pFile);
}
/*********************************************************************
*
*       _cbCallback
*/
static void _cbCallback(WM_MESSAGE * pMsg) {
  WM_HWIN hWin = pMsg->hWin;
  #if GUIDEMO_LARGE
    int NCode, Id;
  #endif
  switch (pMsg->MsgId) {
    case WM_INIT_DIALOG:
      /* Initialize all widgets */
      #if GUIDEMO_TINY
        EDIT_SetText(WM_GetDialogItem(hWin, GUI_ID_EDIT0), "EDIT");
      #else
        EDIT_SetText(WM_GetDialogItem(hWin, GUI_ID_EDIT0), "EDIT widget 0");
        EDIT_SetText(WM_GetDialogItem(hWin, GUI_ID_EDIT1), "EDIT widget 1");
      #endif
      {
        #if GUIDEMO_LARGE
          WM_HWIN hListBox;
          EDIT_SetHexMode(WM_GetDialogItem(hWin, GUI_ID_EDIT2), 0x1234, 0, 0xffffff);
          EDIT_SetBinMode(WM_GetDialogItem(hWin, GUI_ID_EDIT3), 0x1234, 0, 0xffff);
          hListBox = WM_GetDialogItem(hWin, GUI_ID_LISTBOX0);
          LISTBOX_SetText(hListBox, _apListBox);
          SCROLLBAR_CreateAttached(hListBox, SCROLLBAR_CF_VERTICAL);
        #else
          GUI_RECT Rect;
          int x, y, ySize;
          ySize = LCD_GetYSize();
          if (ySize < 120) {
            WM_ResizeWindow(hWin, 0, -24);
          }
          WM_GetWindowRectEx(hWin, &Rect);
          x = (LCD_GetXSize() - (Rect.x1 - Rect.x0 + 1)) >> 1;
          y = (ySize          - (Rect.y1 - Rect.y0 + 1)) >> 1;
          #if GUIDEMO_TINY
            WM_MoveTo(hWin, x, y);
          #else
            WM_MoveTo(hWin, x, y - 4);
          #endif
        #endif
      }
      break;
    case WM_KEY:
      switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) {
      case GUI_KEY_ESCAPE:
        GUI_EndDialog(hWin, 1);
        break;
      case GUI_KEY_ENTER:
        GUI_EndDialog(hWin, 0);
        break;
      }
      break;
  #if GUIDEMO_LARGE
    case WM_NOTIFY_PARENT:
      Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
      NCode = pMsg->Data.v;               /* Notification code */
      switch (NCode) {
        case WM_NOTIFICATION_RELEASED:    /* React only if released */
          if (Id == GUI_ID_OK) {          /* OK Button */
            GUI_EndDialog(hWin, 0);
          }
          if (Id == GUI_ID_CANCEL) {      /* Cancel Button */
            GUI_EndDialog(hWin, 1);
          }
          break;
        case WM_NOTIFICATION_SEL_CHANGED: /* Selection changed */
          FRAMEWIN_SetText(hWin, "Dialog - sel changed");
          break;
        default:
          FRAMEWIN_SetText(hWin, "Dialog - notification received");
      }
      break;
  #endif
    default:
      WM_DefaultProc(pMsg);
  }
}
/**
  * @brief  Callback routine of the dialog
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN  hItem;
  int Id, NCode;

  static uint8_t sel = 0;
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:

    memset(Video_Path, 0, 256);   
    
    hItem = BUTTON_CreateEx(574, 0, 65, 65, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT);
    WM_SetCallback(hItem, _cbButton_exit); 
    
    hItem = ST_AnimatedIconView_CreateEx(100, 
                                         70, 
                                         LCD_GetXSize() - 0, 
                                         LCD_GetYSize() - 30, 
                                         pMsg->hWin, 
                                         WM_CF_SHOW | WM_CF_HASTRANS ,
                                         0,
                                         ID_ICONVIEW_SUBMENU, 
                                         200, 
                                         250, 5, 5);    
    
    
    ST_AnimatedIconView_SetDualFont(hItem, GUI_FONT_20_1, GUI_FONT_20_1);
    
    ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_Y, 5);
    ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_X, 25);
    ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_Y, 10);
    ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_X, 5);
    
    ST_AnimatedIconView_SetSel(hItem, -1);
    
    ST_AnimatedIconView_SetTextColor(hItem, ICONVIEW_CI_UNSEL, 0x00DCA939);
    ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_UNSEL, GUI_WHITE);
    ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_SEL, GUI_WHITE);
    
    ST_AnimatedIconView_SetDualTextColor(hItem, ICONVIEW_CI_SEL, 0x00DCA939, 0x00522000);  
    
    ST_AnimatedIconView_AddIcon(hItem, open_file, 0, "Play video");   
    ST_AnimatedIconView_AddIcon(hItem, add_video, 0, "Add to playlist");    
    
    break;     

  case WM_PAINT: 
    GUI_SetColor(GUI_BLACK);
    GUI_DrawLine(639, 0, 639, 480);   

    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
    NCode = pMsg->Data.v;               /* Notification code */   
    
    switch(Id) {
    case ID_BUTTON_EXIT: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break; 
      
      
    case ID_ICONVIEW_SUBMENU: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:      
        sel = ST_AnimatedIconView_GetSel(pMsg->hWinSrc);
        
        if(sel == 0)
        {

          osDelay(100);  
          /* Playlist not empty, so start play first item */
          if(VideoList.ptr > 0)
          {  
            GUI_SetLayerVisEx (1, 1);
            GUI_SelectLayer(1); 
            playbackwin = WM_CreateWindowAsChild(-1, 0, 640, 480, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbplaybackwin , 0);
            WM_CreateWindowAsChild(0, 70, 640, 300, WM_GetDesktopWindowEx(1), WM_CF_SHOW | WM_CF_HASTRANS, _cbTouch , 0);             
            GUI_SelectLayer(0);
            _StartPlay(&hvideo, (char *)VideoList.file[0].name, &Video_File, 0, 0);
            VideoPlayer_State = VIDEO_PLAY;
            hFrame = WM_CreateWindowAsChild(-1, 0, 640, 480,pMsg->hWin, WM_CF_SHOW, _cbVideoWindow , 0);    
            GUI_SelectLayer(1);
            
          }
          else
          {/* There is no item yet in the playlist: Show hint message */
            hItem = GUI_CreateDialogBox(_aFileInfoDialogCreate, 
                                GUI_COUNTOF(_aFileInfoDialogCreate), 
                                _cbFileInfoDialog, 
                                pMsg->hWin, 
                                100, 
                                80);
            WM_MakeModal(hItem);
          }
        }
        else /* Add file to playlist icon item action */
        {
            hItem = GUI_CreateDialogBox(_aPlaylistDialogCreate, 
                                GUI_COUNTOF(_aPlaylistDialogCreate), 
                                _cbPlaylistDialog, 
                                pMsg->hWin, 
                                100, 
                                80);
            WM_MakeModal(hItem);
        }
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }    
}
Beispiel #6
0
void GUIDEMO_Bitmap(void) {
  int XSize = LCD_GetXSize();
  int YSize = LCD_GetYSize();
  GUIDEMO_ShowIntro("Bitmaps",
                    "Showing different bitmaps"
                    "\nwith and without compression");
  GUI_SetBkColor(GUI_BLUE);
  GUI_Clear();
  #if GUIDEMO_LARGE
    GUI_DrawBitmap(&_bmLadyBug, 20, 50);
    GUI_SetFont(&GUI_Font13_1);
    GUI_DispStringAt("RLE Compressed bitmaps", 10, 10);
    GUIDEMO_Wait();
    GUI_Clear();
    GUI_DispStringAt("1/2/4/8 bpp bitmaps", 10, 10);
    GUI_DrawBitmap(&GUIDEMO_bm4bpp, 20, 50);
    GUIDEMO_Delay(500);
    GUIDEMO_NotifyStartNext();
    /* Tile display with image */
    { 
      int ix, iy;
      for (ix = 0; ix < XSize / GUIDEMO_bm4bpp.XSize + 1; ix++) {
        for (iy = 0; iy < YSize / GUIDEMO_bm4bpp.YSize + 1; iy++) {
          GUI_DrawBitmap(&GUIDEMO_bm4bpp, 
                         GUIDEMO_bm4bpp.XSize * ix , 
                         GUIDEMO_bm4bpp.YSize * iy);
        }
      }
    }
    GUIDEMO_Delay(2000);
    GUIDEMO_NotifyStartNext();
    GUIDEMO_ShowInfo("Bitmaps may also\nbe magnified");
    GUI_DrawBitmapMag(&GUIDEMO_bm4bpp, (XSize - GUIDEMO_bm4bpp.XSize * 3) / 2, 60, 3, 3);
    GUI_SetTextMode(GUI_TM_TRANS);
    GUI_SetFont(&GUI_Font16_1);
    GUI_DispStringHCenterAt("Bitmaps can be magnified", XSize / 2, 100);
    GUIDEMO_Wait();
  #else
    {
      const GUI_BITMAP * pBm;
      int TextModeOld = GUI_SetTextMode(GUI_TM_XOR);
      GUI_SetFont(&GUI_Font8_ASCII);
      pBm = &_bmLadyBug;
      GUI_DrawBitmap(pBm, (XSize - (int)pBm->XSize) / 2, (YSize - (int)pBm->YSize) / 2);
      GUI_DispStringAt("RLE Compressed bitmaps", 10, 10);
      GUIDEMO_Wait();
      GUI_Clear();
      pBm = &GUIDEMO_bm4bpp;
      GUI_DrawBitmap(pBm, (XSize - (int)pBm->XSize) / 2, (YSize - (int)pBm->YSize) / 2);
      GUI_DispStringAt("1/2/4/8 bpp bitmaps", 10, 10);
      GUIDEMO_Wait();
      /*
      {
        int i, nMax = 10;
        GUI_Clear();
        for (i = 2; i < nMax; i++) {
          GUI_DrawBitmapMag(pBm, (XSize - (int)pBm->XSize * i) / 2, (YSize - (int)pBm->YSize * i) / 2, i, i);
          GUI_DispStringAt("Bitmaps can be magnified", 10, 10);
          GUIDEMO_Delay(100);
        }
        for (i = nMax; i > 2; i--) {
          GUI_DrawBitmapMag(pBm, (XSize - (int)pBm->XSize * i) / 2, (YSize - (int)pBm->YSize * i) / 2, i, i);
          GUI_DispStringAt("Bitmaps can be magnified", 10, 10);
          GUIDEMO_Delay(100);
        }
      }
      */
      GUI_DrawBitmapMag(pBm, (XSize - (int)pBm->XSize * 2) / 2, (YSize - (int)pBm->YSize * 2) / 2, 2, 2);
      GUI_DispStringAt("Bitmaps can be magnified", 10, 10);
      GUIDEMO_Wait();
      GUI_SetTextMode(TextModeOld);
    }
  #endif
}
/**
  * @brief  Callback routine of dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE 
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int Id, NCode;
  TREEVIEW_ITEM_Handle  hTreeView;
  TREEVIEW_ITEM_INFO    Info;
  GUI_PID_STATE State;

  switch (pMsg->MsgId) 
  {
  case WM_INIT_DIALOG:
    
    pFileList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef));
    pFileList->ptr = 0;
    
    hPopUp = WM_CreateWindowAsChild(0,
                                    26,
                                    LCD_GetXSize(),
                                    LCD_GetYSize()-26,
                                    pMsg->hWin,
                                    WM_CF_SHOW | WM_CF_HASTRANS , 
                                    _cbPopup, 
                                    0);  
    
    WM_BringToBottom(hPopUp);
    
    hItem = pMsg->hWin;
    FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0);
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0);
    IMAGE_SetGIF(hItem, acfolder, sizeof(acfolder));    
    
    WM_CreateWindowAsChild(639, 460, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); 
    
    _RefreshBrowser(pMsg->hWin);
    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
    NCode = pMsg->Data.v;               /* Notification code */
    switch (NCode) {
      
    case WM_NOTIFICATION_CHILD_DELETED:
      
      k_free(pFileList);
      
      if(hFileInfo != 0)
      {
        hFileInfo = 0;
      }
      break;
       
    case WM_NOTIFICATION_CLICKED:      /* React only if released */
      switch (Id) {
       
      case ID_TREEVIEW:
        hTreeView = TREEVIEW_GetSel(pMsg->hWinSrc);
        TREEVIEW_ITEM_GetInfo(hTreeView, &Info);
        if(Info.IsNode == 0)
        {
          
          GUI_TOUCH_GetState(&State);


          State.x += 20;
          
          State.y-= 50;
            
          if(State.y > 150)
          {
            State.y -= 70;
          }
          
          _FindFullPath(pMsg->hWinSrc, hTreeView, SelectedFileName);
          
          /* Create popup menu after touching the display */
          _OpenPopup(hPopUp, 
                     _aMenuItems, 
                     GUI_COUNTOF(_aMenuItems),
                     State.x, 
                     State.y);  
          
        }
        break;
        
      case ID_BUTTON_REFRESH:
        _RefreshBrowser (pMsg->hWin);
        break;        

      }      
      break;
    }
    break;
    
  default:
    WM_DefaultProc(pMsg);
    break;      
  }
}
Beispiel #8
0
/*********************************************************************
*
*       _GraphDemo
*/
static void _GraphDemo(void) {
  const WIDGET_EFFECT * pEffectOld;
  GRAPH_DATA_Handle     hData[MAX_NUM_DATA_OBJ];
  GRAPH_Handle          hGraph;
  unsigned              i;
  int                   Graph_xSize;
  int                   Graph_ySize;
  int                   Graph_xPos;
  int                   Graph_yPos;
  int                   Data_ySize;
  int                   xSize;
  int                   ySize;

  xSize      = LCD_GetXSize();
  ySize      = LCD_GetYSize();
  pEffectOld = WIDGET_SetDefaultEffect(&WIDGET_Effect_Simple);
  //
  // Set Callback function for background window
  //
  WM_SetCallback(WM_HBKWIN, _cbBk);
  //
  // Determine size of GRAPH
  //
  Graph_xSize = xSize - (DIST_TO_BORDER << 1);            // xsize = Screen size subtracting twice the distance to the border of the screen
  Graph_ySize = ySize - INFO_SIZE_Y - (DIST_TO_WIN << 1); // ysize = Screen size subtracting the window sizes and twice the distance to the windows
  if (Graph_ySize > MAX_GRAPH_SIZE_Y) {
    Graph_ySize = MAX_GRAPH_SIZE_Y;
    if (Graph_xSize > (Graph_ySize * 20) / 11) {
      Graph_xSize = (Graph_ySize * 20) / 11;
    }
  }
  //
  // Create and configure GRAPH_WIDGET
  //
  Graph_xPos = (xSize - Graph_xSize) / 2;
  Graph_yPos = (ySize - Graph_ySize) / 2;
  if (Graph_yPos < INFO_SIZE_Y + DIST_TO_WIN) {
    Graph_yPos = INFO_SIZE_Y + DIST_TO_WIN;
  }
  hGraph = GRAPH_CreateEx(Graph_xPos, Graph_yPos, Graph_xSize, Graph_ySize, WM_HBKWIN, WM_CF_SHOW | WM_CF_CONST_OUTLINE, 0, 0);
  GRAPH_SetBorder(hGraph, BORDER_LEFT, BORDER_TOP, BORDER_RIGHT, BORDER_BOTTOM);
  WM_SetHasTrans (hGraph);
  GRAPH_SetColor (hGraph, COLOR_BK,     GRAPH_CI_BK);
  GRAPH_SetColor (hGraph, COLOR_BORDER, GRAPH_CI_BORDER);
  GRAPH_SetColor (hGraph, COLOR_FRAME,  GRAPH_CI_FRAME);
  GRAPH_SetColor (hGraph, COLOR_GRID,   GRAPH_CI_GRID);
  //
  // Adjust grid
  //
  GRAPH_SetGridVis  (hGraph, 1);
  GRAPH_SetGridDistX(hGraph, GRID_DIST_X);
  GRAPH_SetGridDistY(hGraph, GRID_DIST_Y);
  WM_BringToBottom  (hGraph);
  //
  // Create and configure GRAPH_DATA_YT object
  //
  for (i = 0; i < MAX_NUM_DATA_OBJ; i++) {
    hData[i] = GRAPH_DATA_YT_Create(_aColorData[i], xSize - (DIST_TO_BORDER << 1) - BORDER_LEFT, 0, 0);
  }
  Data_ySize = Graph_ySize - BORDER_BOTTOM;
  //
  // Create and configure GRAPH_SCALE objects
  //
  _hScaleH = GRAPH_SCALE_Create(BORDER_BOTTOM >> 1, GUI_TA_VCENTER, GRAPH_SCALE_CF_HORIZONTAL, TICK_DIST_H);
  _hScaleV = GRAPH_SCALE_Create(BORDER_LEFT   >> 1, GUI_TA_HCENTER, GRAPH_SCALE_CF_VERTICAL,   TICK_DIST_V);
  GRAPH_AttachScale(hGraph, _hScaleH);
  GRAPH_AttachScale(hGraph, _hScaleV);
  GRAPH_SCALE_SetPos(_hScaleH, Graph_ySize - SCALE_H_HEIGHT);
  GRAPH_SCALE_SetOff(_hScaleH, -5);
  //
  // Show some graphs
  //
  for (i = 0; i < GUI_COUNTOF(_aWave); i++) {
    GUIDEMO_ShowInfo(_aWave[i].pName);
    _DataAdjust = GUIDEMO_ShiftRight(Data_ySize * _aWave[i].DataVOff, GRAPH_DIV);
    GRAPH_SetGridOffY (hGraph, GUIDEMO_ShiftRight(Data_ySize * _aWave[i].GridVOff, GRAPH_DIV));
    GRAPH_SCALE_SetOff(_hScaleV, GUIDEMO_ShiftRight((Data_ySize - BORDER_BOTTOM) * _aWave[i].ScaleVOff, GRAPH_DIV));
    _ShowGraph(hGraph, hData, _aWave[i].NumWaves, _aWave[i].pfAddData);
  }
  //
  // Clean up
  //
  GRAPH_DetachScale(hGraph, _hScaleH);
  GRAPH_DetachScale(hGraph, _hScaleV);
  GRAPH_SCALE_Delete(_hScaleH);
  GRAPH_SCALE_Delete(_hScaleV);
  for (i = 0; i < MAX_NUM_DATA_OBJ; i++) {
    GRAPH_DATA_YT_Delete(hData[i]);
  }
  WM_DeleteWindow(hGraph);
  WIDGET_SetDefaultEffect(pEffectOld);
}
/**
  * @brief  Start play
  * @param  filename: pointer to the video file name
  * @retval None
  */
static uint8_t _StartPlay(char * filename) 
{
  int XPos, YPos, XSize, YSize, nx, ny, n;
  
  
  if(f_open(&Video_File, filename, FA_OPEN_EXISTING | FA_READ) == FR_OK)
  {
    GUI_MOVIE_GetInfoEx(_GetData, &Video_File, &Video_Info);
    
    if((Video_Info.xSize == 0) || (Video_Info.ySize == 0) || 
       (Video_Info.xSize > 1024) || (Video_Info.ySize > 768))
    {
      return 1;
    }
    
    hMovie = GUI_MOVIE_CreateEx(_GetData, &Video_File, _cbNotify);
    VideoPlayer_State = VIDEO_PLAY;
    
    if (FullScreen == 0)
    {
      __GetWindowRect(&XPos, &YPos, &XSize, &YSize);
      
      nx = (XSize * 1000) / Video_Info.xSize;
      ny = (YSize * 1000) / Video_Info.ySize; 
      
      if (nx < ny) {
        n = nx;
      } else {
        n = ny;
      }
      
      XPos = XPos + (XSize - ((Video_Info.xSize * n) / 1000)) / 2;
      YPos = YPos + (YSize - ((Video_Info.ySize * n) / 1000)) / 2;
      GUI_MOVIE_ShowScaled(hMovie, XPos, YPos, n, 1000, 0);
    }
    else
    {
      if((Video_Info.xSize != LCD_GetXSize()) ||(Video_Info.ySize != LCD_GetYSize()))
      {
        nx = (LCD_GetXSize() * 1000) / Video_Info.xSize;
        ny = (LCD_GetYSize() * 1000) / Video_Info.ySize; 
        
        if (nx < ny) {
          n = nx;
        } else {
          n = ny;
        }
        
        XPos = (LCD_GetXSize() - ((Video_Info.xSize * n) / 1000)) / 2;
        YPos = (LCD_GetYSize() - ((Video_Info.ySize * n) / 1000)) / 2;
        
        GUI_MOVIE_ShowScaled(hMovie, XPos, YPos, n, 1000, 0);
      }
      else
      {
        XPos = (LCD_GetXSize() - Video_Info.xSize) / 2;
        YPos = (LCD_GetYSize() - Video_Info.ySize) / 2;
        
        GUI_MOVIE_Show(hMovie, XPos, YPos, 0); 
      }
    }
  }
  return 0;
}
Beispiel #10
0
/*********************************************************************
*
*       MainTask
*/
void CALIBRATION_Check(void)
{

  int aPhysX[2], aPhysY[2], aLogX[2], aLogY[2], i;

  
//  data1.d32 = BACKUP_RestoreParameter(RTC_BKP_DR0);
//  data2.d32 = BACKUP_RestoreParameter(RTC_BKP_DR1);
  data1.d32 = 0;
  data2.d32 = 0;
  
  A2 = data2.b.A2 ;
  B2 = data2.b.B2 ;    
  A1 = data1.b.A1 ;
  B1 = data1.b.B1 ;
  
  if(data2.b.IsCalibrated == 0) /*触摸没有计算*/
  {
    GUI_SetBkColor(GUI_WHITE);
    GUI_Clear();
    GUI_SetColor(GUI_BLACK);
    GUI_SetFont(&GUI_Font20B_ASCII);
    _Explain();                 /*显示explain文字*/
    /* Set the logical values 在什么地方画圆,设置触摸点(15,15)(X-15,Y-15)两点 */
    aLogX[0] = 15;
    aLogY[0] = 15;
    aLogX[1] = LCD_GetXSize() - 15;
    aLogY[1] = LCD_GetYSize() - 15;
    /* Get the physical values of the AD converter for 2 positions */
    for (i = 0; i < 2; i++) {
      _GetPhysValues(aLogX[i], aLogY[i], &aPhysX[i], &aPhysY[i], _acPos[i]);
    }
    /* Use the physical values to calibrate the touch screen */
    
    A1 = (1000 * ( aLogX[1] - aLogX[0]))/ ( aPhysX[1] - aPhysX[0]); 
    B1 = (1000 * aLogX[0]) - A1 * aPhysX[0]; 
    
    A2 = (1000 * ( aLogY[1] - aLogY[0]))/ ( aPhysY[1] - aPhysY[0]); 
    B2 = (1000 * aLogY[0]) - A2 * aPhysY[0]; 
    
    data1.b.A1 = A1;
    data1.b.B1 = B1;
//    BACKUP_SaveParameter(RTC_BKP_DR0, data1.d32);
    
    data2.b.A2 = A2;
    data2.b.B2 = B2;
    data2.b.IsCalibrated = 1;
 //   BACKUP_SaveParameter(RTC_BKP_DR1, data2.d32);  
    
    /* Display the result */
    GUI_CURSOR_Show();  /*显示光标*/
    GUI_Clear();
    _DispStringCentered("Touch screen has been\n"
                        "calibrated. Please use\n"
                          "the cursor to test\n"
                            "the calibration...");
    

  }
  
  CALIBRATION_Done = 1;
  
  GUI_Delay(1000);
}
Beispiel #11
0
static void _cbDialog(WM_MESSAGE * pMsg) {
    int i;
    WM_HWIN hItem;
    int     NCode;
    int     Id;
    gui_msg_t msg;
    msg.exec = RT_NULL;
    
    switch (pMsg->MsgId)
    {
        case WM_INIT_DIALOG:
        hItem = pMsg->hWin;
        WM_EnableMemdev(hItem);
        //WM_MoveTo(hItem, 0, -30);
        //WM_MOTION_SetMoveable(hItem, WM_CF_MOTION_Y, 1);
        WINDOW_SetBkColor(hItem, GUI_WHITE);
        int fd;
        

        /* load APP */
        for(i=0;i<GUI_COUNTOF(UIApp);i++)
        {
            hItem = BUTTON_CreateAsChild(10, 10, 50, 50, pMsg->hWin, UIApp[i].GUID, WM_CF_SHOW);
            BUTTON_SetText(hItem, UIApp[i].text);
            WM_EnableMemdev(hItem);
            struct stat s;
            stat(UIApp[i].logoPath, &s);
            
            UIApp[i].plogo = rt_malloc(s.st_size);
            if(UIApp[i].plogo)
            {
                fd = open(UIApp[i].logoPath, O_RDONLY , 0);
                if(fd >=0)
                {
                    rt_kprintf("%s", UIApp[i].logoPath);
                    read(fd, UIApp[i].plogo, s.st_size);

                    
                    //WM_MoveTo(hItem, 0+(i%2)*120, (i/2)*120 + 0);
                    
                    WM_SetSize(hItem, GUI_BMP_GetXSize(UIApp[i].plogo), GUI_BMP_GetYSize(UIApp[i].plogo));
                    //xPos+= xSize;
                    //yPos+= ySize;
                    
                    
                    BUTTON_SetBMPEx(hItem, BUTTON_BI_UNPRESSED, UIApp[i].plogo ,0, 0);
                    BUTTON_SetBMPEx(hItem, BUTTON_BI_PRESSED, UIApp[i].plogo ,1, 1);
                    BUTTON_SetTextOffset(hItem, 0, 50);
                    close(fd);
                }
            }
            else
            {
                rt_kprintf("no mem!\r\n");
            }
        }
        
        /* algin Apps */
        int xPos, yPos, xSize, ySize;
        xPos = 0; xSize = 0;
        yPos = 0; ySize = 0;
        for(i=0;i<GUI_COUNTOF(UIApp);i++)
        {
            hItem = WM_GetDialogItem(pMsg->hWin, UIApp[i].GUID);
            xSize = GUI_BMP_GetXSize(UIApp[i].plogo);
            ySize = GUI_BMP_GetYSize(UIApp[i].plogo);
            
            if(xSize == 0 || xSize > 9999)
            {
                xSize = 60;
            }
            if(ySize == 0 || ySize > 9999)
            {
                ySize = 60;
            }
            
            if(abs(LCD_GetXSize() - xPos) >= xSize)
            {
                WM_MoveTo(hItem, xPos, yPos);
                xPos+=xSize;
            }
            else
            {
                xPos = 0;
                yPos+=ySize;
                WM_MoveTo(hItem, xPos, yPos);
                xPos+=xSize; 
            }
        }
    
//        char *p;
//        p = rt_malloc(38399);
//        fd = open("/SD/DESKTOP.JPG",O_RDONLY , 0);
//        read(fd, p, 38399);
//        hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0);
//        WM_EnableMemdev(hItem);
      //  IMAGE_SetJPEG(hItem, p, 38399);
        break;
    case WM_NOTIFY_PARENT:
        Id = WM_GetId(pMsg->hWinSrc);
        NCode = pMsg->Data.v;
    if(NCode == WM_NOTIFICATION_RELEASED)
    {
        for(i=0;i<GUI_COUNTOF(UIApp);i++)
        {
            if(Id == UIApp[i].GUID)
            {
                msg.exec = UIApp[i].exec;
                break;
            }
        }
        if(msg.exec != RT_NULL)
        {
            rt_mq_send(guimq, &msg, sizeof(msg));
        }
    }
    break;
    default:
        WM_DefaultProc(pMsg);
        break;
    }
}
Beispiel #12
0
/*********************************************************************
*
*       _TileScreen
*
*  Function description
*    Fills the screen with PNG-tiles from an OpenStreetMap-server.
*    Receiving the tiles works asynchronous with non blocking sockets.
*    Tiles are requested by the following GET request:
*
*    "GET <URL of TileServer>/<Zoom factor>/<X-value>/<Y-value>.png\r\nUser-Agent: xxx\r\n\r\n"
*
*  Parameters:
*    x    - X-value for URL of tile calculated by longitude and zoom factor
*    y    - Y-value for URL of tile calculated by latitude and zoom factor
*    Zoom - A value between 1-16 where 16
*/
static void _TileScreen(int x, int y, int Zoom) {
  TILE * pTileFirst;
  TILE * pTile;
  int xSize, ySize, xPos, yPos, nx, ny, i, j, Ready;
  U32 IPAddr;

  xSize = LCD_GetXSize();
  ySize = LCD_GetYSize();
  xPos = (xSize - TILE_SIZE) / 2;
  yPos = (ySize - TILE_SIZE) / 2;
  nx = ny = 1;
  while (xPos > 0) {
    nx += 2;
    xPos -= TILE_SIZE;
    x--;
  }
  while (yPos > 0) {
    ny += 2;
    yPos -= TILE_SIZE;
    y--;
  }
  pTileFirst = NULL;
  //
  // Create list of all tiles
  //
  for (i = 0; i < nx; i++) {
    for (j = 0; j < ny; j++) {
      pTile = calloc(1, sizeof(TILE));
      if (pTileFirst == NULL) {
        pTileFirst = pTile;
      } else {
        pTile->pNext = pTileFirst;
        pTileFirst = pTile;
      }
      pTileFirst->x = x + i;
      pTileFirst->y = y + j;
      pTileFirst->Zoom = Zoom;
      pTileFirst->xPos = xPos + i * TILE_SIZE;
      pTileFirst->yPos = yPos + j * TILE_SIZE;
    }
  }
  //
  // Request and drawing of all tiles
  //
  IPAddr = _GetIPAddr(TILE_SERVER_URL);
  do {
    Ready = 1;
    for (pTile = pTileFirst; pTile; pTile = pTile->pNext) {
      if (pTile->State < STATE_DRAW) {
        //
        // Tile not available: Keep receiving
        //
        _ReceiveTile(pTile, IPAddr);
        Ready = 0;
      } else {
        if (pTile->State == STATE_DRAW) {
          //
          // Tile already received: Draw and remove
          //
          GUI_PNG_Draw(pTile->pImage, pTile->SizeOfImage, pTile->xPos, pTile->yPos);
          free(pTile->pImage);
          pTile->State = STATE_DONE;
          Ready = 0;
        }
      }
    }
  } while (Ready == 0);
  //
  // Remove tiles
  //
  while (pTileFirst) {
    pTile = pTileFirst;
    pTileFirst = pTileFirst->pNext;
    free(pTile);
  }
}
Beispiel #13
0
/*******************************************************************
*
*       _DrawScale
*
* Function description
*   Drawing a scale using GUI-functions
*/
static void _DrawScale(void) {
  int XSize;
  int XMid; 
  int i;
  int r1;
  int r2;
  int rt;
  int y ;
  int step;
  int r;

  XSize = LCD_GetXSize();
  XMid  = XSize / 2;
  r1    = 110;
  r2    = 140;
  rt    = 100;
  y     = 240;
  step  =  15;
  r     = (r1 + r2) / 2;
  GUI_SetBkColor(GUI_BLACK);
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_SetTextAlign(GUI_TA_HCENTER);
  GUI_DispStringAt("DrawScale - Sample", 160, 5);
  while (1) {
    int c = 0;
    GUI_SetColor(GUI_WHITE);
    GUI_SetFont(&GUI_Font8x16);
    GUI_SetTextAlign(GUI_TA_LEFT);
    GUI_Delay(SPEED / 2);
    GUI_DispStringAtCEOL("using", 5, 40);
    GUI_DispStringAtCEOL("GUI_AA_DrawArc", 5, 55);
    GUI_Delay(SPEED * 2);
    GUI_SetPenSize(r2 - r1);
    GUI_SetColor(0x0000AA);
    GUI_AA_DrawArc(XMid, y, r, r, 45, 60);
    GUI_Delay(SPEED);
    GUI_SetColor(0x00AA00);
    GUI_AA_DrawArc(XMid, y, r, r, 60, 90);
    GUI_Delay(SPEED);
    GUI_SetPenSize(2);
    GUI_SetColor(GUI_WHITE);
    GUI_AA_DrawArc(XMid, y, r1, r1, 45, 135);
    GUI_Delay(SPEED);
    GUI_AA_DrawArc(XMid, y, r2, r2, 45, 135);
    GUI_Delay(SPEED);
    GUI_DispStringAtCEOL("", 5, 55);
    GUI_Delay(200);
    GUI_DispStringAtCEOL("using", 5, 40);
    GUI_DispStringAtCEOL("GUI_AA_DrawLine & GUI_DispCharAt", 5, 55);
    GUI_Delay(SPEED * 3);
    for (i = 45; i <= 135; i += step) {
      float co = cos(i * 3.1415926 / 180);
      float si = sin(i * 3.1415926 / 180);
      int   x1 = XMid - (int)(r1 * co);
      int   y1 = y    - (int)(r1 * si);
      int   x2 = XMid - (int)((r2 - 1) * co);
      int   y2 = y    - (int)((r2 - 1) * si);
      int   xt = XMid - (int)(rt * co);
      int   yt = y    - (int)(rt * si);
      GUI_SetColor(GUI_WHITE);
      GUI_SetPenSize(2);
      GUI_AA_DrawLine(x1, y1, x2, y2);
      GUI_SetColor(GUI_GREEN);
      GUI_SetFont(&GUI_Font8x8);
      GUI_DispCharAt('0' + c++, xt - 4, yt - 4);
      GUI_Delay(SPEED / 2);
    }
    GUI_Delay(SPEED * 3);
    GUI_ClearRect(0, 30, 320, 240);
  }
}
Beispiel #14
0
void GUIDEMO_ColorBar(void) {
  int nBars = 13;
  int NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS);
  int XSize = LCD_GetXSize();
  int i, yStep, y0, x0;
  int lcd_ysize;
  int BitsPerPixel;
  
  lcd_ysize = LCD_GetYSize();
  y0 = 70;
  x0 = 60;
  GUIDEMO_ShowIntro("Color bar",
                    "emWin features "
                    "\nan integrated color"
                    "\nmanagement"
                    "\nwill always find the best available color"
                    "\nfor any logical color");
	XSize -= x0;
  yStep = (lcd_ysize - y0 - 60) / nBars;
  GUI_SetColor(GUI_WHITE);
  GUI_SetBkColor(GUI_BLACK); 
  GUI_Clear();
	GUI_SetFont(&GUI_Font8x16);
	GUI_DispString("Color bars\n");
  GUI_SetFont(&GUI_Font8_ASCII);
  #ifdef LCD_CONTROLLER
    GUI_DispString("\nLCD_CONTROLLER: ");
    GUI_DispDecMin(LCD_CONTROLLER);
    GUI_DispString("\n");
  #endif
  BitsPerPixel = LCD_GetBitsPerPixel();
  GUI_DispDecMin(BitsPerPixel);
  GUI_DispString(" bpp");
  #ifdef LCD_BUSWIDTH
    GUI_DispString(", ");
    GUI_DispDecMin(LCD_BUSWIDTH);
    GUI_DispString(" bit bus");
  #endif
  GUI_DispString(", ");
  GUI_DispDecMin(NumColors);
  GUI_DispString(" colors\n");
  GUI_SetFont(&GUI_Font8x8);
  GUI_SetColor(GUI_WHITE);
  GUI_DispStringAt("Red",     0, y0 +      yStep);
  GUI_DispStringAt("Green",   0, y0 + 3  * yStep);
  GUI_DispStringAt("Blue",    0, y0 + 5  * yStep);
  GUI_DispStringAt("Grey",    0, y0 + 6  * yStep);
  GUI_DispStringAt("Yellow",  0, y0 + 8  * yStep);
  GUI_DispStringAt("Cyan",    0, y0 + 10 * yStep);
  GUI_DispStringAt("Magenta", 0, y0 + 12 * yStep);
  for (i = 0; (i < XSize) && !GUIDEMO_CheckCancel(); i++) {
    U16 cs = (255 * (U32)i) / XSize;
    U16 x = x0 + i;;
/* Red */
    GUI_SetColor(cs);
    GUI_DrawVLine(x, y0, y0 + yStep - 1);
    GUI_SetColor(0x0000ff + (255 - cs) * 0x10100L);
    GUI_DrawVLine(x, y0 + yStep, y0 + 2 * yStep - 1);
/* Green */
    GUI_SetColor(cs<<8);
    GUI_DrawVLine(x, y0 + 2 * yStep, y0 + 3 * yStep - 1);
    GUI_SetColor(0x00ff00 + (255 - cs) * 0x10001L);
    GUI_DrawVLine(x, y0 + 3 * yStep, y0 + 4 * yStep - 1);
/* Blue */
    GUI_SetColor(cs * 0x10000L);
    GUI_DrawVLine(x, y0 + 4 * yStep, y0 + 5 * yStep - 1);
    GUI_SetColor(0xff0000 + (255 - cs) * 0x00101L);
    GUI_DrawVLine(x, y0 + 5 * yStep, y0 + 6 * yStep - 1);
/* Gray */
    GUI_SetColor(cs * 0x10101L);
    GUI_DrawVLine(x, y0 + 6 * yStep, y0 + 7 * yStep - 1);
/* Yellow */
    GUI_SetColor(cs * 0x00101L);
    GUI_DrawVLine(x, y0 + 7 * yStep, y0 + 8 * yStep - 1);
    GUI_SetColor(0x00ffff + (255 - cs) * 0x10000L);
    GUI_DrawVLine(x, y0 + 8 * yStep, y0 + 9 * yStep - 1);
/* Cyan */
    GUI_SetColor(cs * 0x10100L);
    GUI_DrawVLine(x, y0 + 9 * yStep, y0 + 10 * yStep - 1);
    GUI_SetColor(0xffff00 + (255 - cs) * 0x00001L);
    GUI_DrawVLine(x, y0 + 10 * yStep, y0 + 11 * yStep - 1);
/* Magenta */
    GUI_SetColor(cs * 0x10001L);
    GUI_DrawVLine(x, y0 + 11 * yStep, y0 + 12 * yStep - 1);
    GUI_SetColor(0xff00ff + (255 - cs) * 0x00100L);
    GUI_DrawVLine(x, y0 + 12 * yStep, y0 + 13 * yStep - 1);
  }
  GUIDEMO_Wait();
}
/**
  * @brief  Start play
  * @param  filename: pointer to the video file name
  * @retval None
  */
static uint8_t _StartPlay(GUI_MOVIE_HANDLE *hmovie, char * filename, FIL * file, uint16_t x0, uint16_t y0) 
{

  static char tmp[FILEMGR_FILE_NAME_SIZE]; 
  uint32_t ms, frames, duration;  
  WM_HWIN  hItem;
  
  if(f_open(file, filename, FA_OPEN_EXISTING | FA_READ) == FR_OK)
  {
    
    
    PrevFrameIndex = 0;
    LostFrames = 0;
    previous_total = 0;
    
    GUI_MOVIE_GetInfoEx(_GetData, file, &Video_Info);
    
    *hmovie = GUI_MOVIE_CreateEx(_GetData, file, _cbNotify) ;
    GUI_MOVIE_SetPeriod (*hmovie, VIDEO_FRAME_TIME);
    
    if((Video_Info.xSize == 0) || (Video_Info.ySize == 0) || 
       (Video_Info.xSize > LCD_GetXSize()) || (Video_Info.ySize > LCD_GetYSize()))
    {
      _StopPlay(hmovie, file);
      VideoPlayer_State = VIDEO_STOP;
      
      hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_NAME);
      FILEMGR_GetFileOnly (tmp, filename);
      TEXT_SetText(hItem, tmp);
      
      hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME);
      TEXT_SetText(hItem, "00:00");
      WM_InvalidateWindow(hItem);
      WM_Paint(hItem);
      
      hItem = WM_GetDialogItem(playbackwin, ID_TIME);
      TEXT_SetText(hItem, "00:00");
      WM_InvalidateWindow(hItem);
      WM_Paint(hItem);
      
      hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_FORMAT);
      sprintf(tmp, "Format : UNSUPPORTED      [%lu/%d]", Video_FilePos + 1, VideoList.ptr) ;
      TEXT_SetText(hItem, tmp);
      WM_InvalidateWindow(hItem);
      WM_Paint(hItem);   
      return 1;
    }
    
    GUI_MOVIE_Show(*hmovie, ((LCD_GetXSize() - Video_Info.xSize)/2), ((LCD_GetYSize() - Video_Info.ySize)/2), 0); 
    
    hTimer = WM_CreateTimer(playbackwin, ID_TIMER_PROCESS, 1000, 0);  
    
    /* Update video total time */
    hItem = WM_GetDialogItem(playbackwin, ID_TIME);
    ms = Video_Info.msPerFrame;
    frames = Video_Info.NumFrames;
    duration = (frames * ms)/1000;
    sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
    TEXT_SetText(hItem, tmp);          
    WM_InvalidateWindow(playbackwin);  
    elapsed_time = 0;
    
    hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_NAME);
    FILEMGR_GetFileOnly (tmp, filename);
    TEXT_SetText(hItem, tmp);
    
    hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME);
    TEXT_SetText(hItem, "00:00");
    WM_InvalidateWindow(hItem);
    WM_Paint(hItem);
    
    hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_FORMAT);
    sprintf(tmp, "Format : MJPEG            [%lu/%d]", Video_FilePos + 1, VideoList.ptr) ;
    TEXT_SetText(hItem, tmp);
    WM_InvalidateWindow(hItem);
    WM_Paint(hItem);    
    
  }
  return 0;
}
Beispiel #16
0
void GUIDEMO_main(void) {
  #if GUI_WINSUPPORT
    int i;
    int xSize, ySize, xPos, yPos;
  #endif
  #if (GUI_SUPPORT_CURSOR|GUI_SUPPORT_TOUCH)
    GUI_CURSOR_Show();
  #endif
  GUI_Clear();
  #if GUI_WINSUPPORT
    #if LCD_NUM_DISPLAYS > 1
      FRAMEWIN_CreateAsChild(10, 10, 100, 100, WM_GetDesktopWindowEx(1), "Display 1", NULL, WM_CF_SHOW);
      WM_SetDesktopColorEx(GUI_RED, 1);
      GUI_Delay(1000);
    #endif
    WM_SetCreateFlags(WM_CF_MEMDEV);  /* Automatically use memory devices on all windows */
    /* Calculate position and size of FrameWin[1] */
    _ButtonSizeX = 30;
    _ButtonSizeY = 20;
    /* Create the control window incl. buttons */
    _ahFrameWin[1] = FRAMEWIN_Create("Control", NULL, WM_CF_SHOW | WM_CF_STAYONTOP,
                                                LCD_GetXSize() - 80, LCD_GetYSize() - 60, 80, 60);
    _ahInfoWin[1] = WM_CreateWindowAsChild( 0, 0, 0, 0, WM_GetFirstChild(_ahFrameWin[1]), WM_CF_SHOW | WM_CF_STAYONTOP, &_cbCmdWin, 0);
    _ahButton[0] = BUTTON_CreateAsChild(4, 20, _ButtonSizeX, _ButtonSizeY, _ahInfoWin[1], 
                                        'S' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV);
    _ahButton[1] = BUTTON_CreateAsChild(40, 20, _ButtonSizeX, _ButtonSizeY, _ahInfoWin[1], 
                                        'N' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV);
    BUTTON_SetText(_ahButton[0], "Stop");
    BUTTON_SetText(_ahButton[1], "Next");
    _UpdateCmdWin();
    WM_ExecIdle();
  #endif
  /* Show Intro */
  GUIDEMO_Intro();
  #if GUI_WINSUPPORT
    /* Calculate position and size of FrameWin[0] */
    xSize = LCD_GetXSize() / 2;
    ySize = 65;
    xPos  = LCD_GetXSize() - xSize;
    yPos  = 0;
    /* Create info window and run the individual demos */
    _ahFrameWin[0] = FRAMEWIN_Create("µC/GUI Demo", NULL, WM_CF_STAYONTOP, 
                                     xPos, yPos, xSize, ySize);
//    _ahInfoWin[0] = WM_GetFirstChild(_ahFrameWin[0]);
    _ahInfoWin[0] = WM_CreateWindowAsChild(0, 0, 0, 0, WM_GetFirstChild(_ahFrameWin[0]), WM_CF_SHOW | WM_CF_STAYONTOP, 0, 0);
    WM_ExecIdle();
  #endif
  /* Run the individual demos !  */
  for (_iTest = 0; _apfTest[_iTest]; _iTest++) {
    GUI_CONTEXT ContextOld;
    GUI_SaveContext(&ContextOld);
    _iTestMinor = 0;
    _UpdateCmdWin();
    (*_apfTest[_iTest])();
    _CmdNext = 0;
    GUI_RestoreContext(&ContextOld);
  }
  /* Cleanup */
  #if GUI_WINSUPPORT
    for (i = 0; i < countof(_ahFrameWin); i++) {
      WM_DeleteWindow(_ahFrameWin[i]);
    }
    for (i = 0; i < countof(_ahInfoWin); i++) {
      WM_DeleteWindow(_ahInfoWin[i]);
    }
  #endif
}
/**
  * @brief  Callback routine of the video main dialog
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN  hItem;
  int Id, NCode;

  static uint8_t sel = 0;
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:

    memset(Video_Path, 0, 256);   
    
    hItem = BUTTON_CreateEx(700, 0, 100, 100, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT);
    WM_SetCallback(hItem, _cbButton_exit); 
    
    hItem = ST_AnimatedIconView_CreateEx(120, 
                                         50, 
                                         LCD_GetXSize() - 220, 
                                         LCD_GetYSize() - 150, 
                                         pMsg->hWin, 
                                         WM_CF_SHOW | WM_CF_HASTRANS ,
                                         0,
                                         ID_ICONVIEW_SUBMENU, 
                                         240, 
                                         300, 100, 5);    
    
    
    ST_AnimatedIconView_SetDualFont(hItem, &GUI_FontLubalGraph24, &GUI_FontLubalGraph24);
    
    ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_Y, 5);
    ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_X, 25);
    ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_Y, 10);
    ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_X, 5);
    
    ST_AnimatedIconView_SetSel(hItem, -1);
    
    ST_AnimatedIconView_SetTextColor(hItem, ICONVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
    ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_UNSEL, GUI_WHITE);
    ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_SEL, GUI_WHITE);
    
    ST_AnimatedIconView_SetDualTextColor(hItem, ICONVIEW_CI_SEL, GUI_STCOLOR_LIGHTBLUE, GUI_STCOLOR_DARKBLUE);  
    
    ST_AnimatedIconView_AddIcon(hItem, open_file, 0, "Play video");   
    ST_AnimatedIconView_AddIcon(hItem, add_video, 0, "Open playlist");    
    
    break;     

  case WM_PAINT: 
    GUI_SetColor(GUI_BLACK);
    GUI_DrawLine(799, 0, 799, 480);   

    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);    /* Id of widget */
    NCode = pMsg->Data.v;               /* Notification code */   
    
    switch(Id) {
    case ID_BUTTON_EXIT: 
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        /* avoid icon view animation */
        hItem = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_SUBMENU);
        WM_HideWindow(hItem);
        break;
        
      case WM_NOTIFICATION_MOVED_OUT:
        hItem = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_SUBMENU);
        WM_ShowWindow(hItem);        
        break;
        
      case WM_NOTIFICATION_RELEASED:
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break; 
      
      
    case ID_ICONVIEW_SUBMENU: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:      
        sel = ST_AnimatedIconView_GetSel(pMsg->hWinSrc);
        
        if(sel == 0)
        {
          if(VNC_IsRunning() == 0)
          {
            /* Playlist not empty, so start play first item */
            if(VideoList.ptr > 0)
            {  
              GUI_SetLayerVisEx (1, 1);
              GUI_SelectLayer(1); 
              playbackwin = WM_CreateWindowAsChild(0, 0, 800, 480, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbplaybackwin , 0);
              WM_CreateWindowAsChild(100, 100, 600, 280, WM_GetDesktopWindowEx(1), WM_CF_SHOW | WM_CF_HASTRANS, _cbTouch , 0);             
              GUI_SelectLayer(0);
              _StartPlay(&hvideo, (char *)VideoList.file[0].name, &Video_File, 0, 0);
              VideoPlayer_State = VIDEO_PLAY;
              hFrame = WM_CreateWindowAsChild(0, 0, 800, 480,pMsg->hWin, WM_CF_SHOW, _cbVideoWindow , 0);    
              GUI_SelectLayer(1);
              
            }
            else 
            {/* There is no item yet in the playlist: Show hint message */
              hItem = GUI_CreateDialogBox(_aFileInfoDialogCreate, 
                                          GUI_COUNTOF(_aFileInfoDialogCreate), 
                                          _cbFileInfoDialog, 
                                          pMsg->hWin, 
                                          100, 50);
              WM_MakeModal(hItem);            
            }
          }
          else
          {
              hItem = GUI_CreateDialogBox(_aFileErrorDialogCreate, 
                                          GUI_COUNTOF(_aFileErrorDialogCreate), 
                                          _cbFileInfoDialog, 
                                          pMsg->hWin, 
                                          100, 50);
              WM_MakeModal(hItem);
          }
        }
        else if(sel == 1)
        {
            hPlaylistWin = GUI_CreateDialogBox(_aPlaylistDialogCreate, 
                                GUI_COUNTOF(_aPlaylistDialogCreate), 
                                _cbPlaylistDialog, 
                                pMsg->hWin, 
                                100, 50);
            WM_MakeModal(hPlaylistWin);
        }
        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }    
}
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  TREEVIEW_ITEM_Handle hNode;
  WM_HWIN              hTree;
  int                  xSize;
  int                  ySize;
  int                  yPos;
  int                  r;
  int                  TimeStart;
  int                  TimeUsed;
  int                  ySizeText;
  U32                  BytesFree;
  U32                  BytesUsed;
  char                 acBuffer[(TREEVIEW_DEPTH << 1) + 1];
  char                 acNumNodes[30]  = "Nodes:  ";
  char                 acNumLeaves[30] = "Leaves: ";
  char                 acNumTotal[30]  = "Total:  ";
  char                 acTimeUsed[30]  = "Time:   ";
  char                 acBytesUsed[30] = "Memory: ";

  //
  // Initialize emWin
  //
  WM_SetCreateFlags(WM_CF_MEMDEV);
  GUI_Init();
  xSize = LCD_GetXSize();
  ySize = LCD_GetYSize();
  //
  // Set defaults for background and widgets
  //
  WM_SetDesktopColor(GUI_BLACK);
  SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX);
  SCROLLBAR_SetDefaultWidth(20);
  SCROLLBAR_SetThumbSizeMin(25);
  TEXT_SetDefaultFont(GUI_FONT_6X8);
  //
  // Draw info message before creating the widgets
  //
  GUI_DrawGradientV(0, 0, xSize - 1, ySize - 1, GUI_BLUE, GUI_BLACK);
  GUI_SetFont(GUI_FONT_20F_ASCII);
  GUI_DispStringHCenterAt("Filling TREEVIEW widget...", xSize >> 1, ySize / 3);
  GUI_X_Delay(1000);
  //
  // Create TREEVIEW
  //
  hTree = TREEVIEW_CreateEx(0, 0, xSize, ySize, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_TREEVIEW0);
  TREEVIEW_SetAutoScrollV(hTree, 1);//管理自动使用垂直滚动条。
  TREEVIEW_SetSelMode(hTree, TREEVIEW_SELMODE_ROW);
  //
  // Fill TREEVIEW
  //
  hNode = TREEVIEW_InsertItem(hTree, TREEVIEW_ITEM_TYPE_NODE, 0, 0, "Tree");
  BytesFree = GUI_ALLOC_GetNumFreeBytes();
  TimeStart = GUI_GetTime();
  r = _FillNode(hTree, hNode, NUM_CHILD_NODES, NUM_CHILD_ITEMS, TREEVIEW_DEPTH, TREEVIEW_DEPTH, acBuffer, acBuffer);
  TimeUsed = GUI_GetTime() - TimeStart;
  BytesUsed = BytesFree - GUI_ALLOC_GetNumFreeBytes();
  if (r) {
    //
    // Error message
    //
    WM_DeleteWindow(hTree);
    GUI_MessageBox("Error", "Not enough memory available!", 0);
  } else {
    //
    // Show result
    //
    yPos = 20;
    ySizeText = GUI_GetYDistOfFont( TEXT_GetDefaultFont()) + 5;
    _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acNumNodes, _NumNodes);
    _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acNumLeaves, _NumLeaves);
    _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acNumTotal, _NumNodes + _NumLeaves);
    _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acTimeUsed, TimeUsed);
    _MakeNumberText(hTree, xSize >> 1, &yPos, xSize >> 1, ySizeText, acBytesUsed, BytesUsed);
    WM_SetFocus(hTree);
  }
  while (1) {
    GUI_Delay(100);
  }
}
Beispiel #19
0
void GUIDEMO_DemoProgBar(void) {
  int i, iRep;
  int XMid = LCD_GetXSize() / 2;
  int YMid = LCD_GetYSize() / 2;
  int Length[2] = {100, 140};
  int Height[2] = {20, 10};
  #if GUIDEMO_LARGE
    int MaxReps = 2;
  #else
    int MaxReps = 1;
  #endif
  PROGBAR_Handle ahProgBar[2];
  GUIDEMO_ShowIntro("Widgets", 
                    "\nProgressbars in"
                    "\nall variations");
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_Font8x16);
  GUI_DispStringHCenterAt("Progress bar", XMid, YMid - 40);
  /* Create `em */  
  ahProgBar[0] = PROGBAR_Create(XMid - Length[0] / 2,
                                YMid - 15,
                                Length[0], 
                                Height[0], 
                                WM_CF_SHOW);
  ahProgBar[1] = PROGBAR_Create(XMid - Length[1] / 2,
                                YMid + 20,
                                Length[1], 
                                Height[1], 
                                WM_CF_SHOW);
  /* Use memory device (optional, for better looks) */
  #if GUI_SUPPORT_MEMDEV
    PROGBAR_EnableMemdev(ahProgBar[0]);
    PROGBAR_EnableMemdev(ahProgBar[1]);
  #endif
  GUIDEMO_Delay (1000);
  PROGBAR_SetMinMax(ahProgBar[1], 0, 500);
  for (iRep = 0; iRep < MaxReps; iRep++) {
    PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16);
    #if   (LCD_BITSPERPIXEL == 2)
      PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_BLACK);
      PROGBAR_SetBarColor(ahProgBar[1], 0, GUI_BLACK);
      PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY);
    #elif (LCD_BITSPERPIXEL <= 4)
      PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_DARKGRAY);
      PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY);
    #else
      PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_GREEN);
      PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_RED);
    #endif
    for (i = 0; (i <= 100) && !GUIDEMO_CheckCancel(); i++) {
      PROGBAR_SetValue(ahProgBar[0], i);
      PROGBAR_SetValue(ahProgBar[1], i);
      GUI_Delay(5);
    }
    PROGBAR_SetText(ahProgBar[0], "Tank empty");
    for (; (i >= 0)&& !GUIDEMO_CheckCancel(); i--) {
      PROGBAR_SetValue(ahProgBar[0], i);
      PROGBAR_SetValue(ahProgBar[1], 200 - i);
      GUI_Delay(5);
    }
    PROGBAR_SetText(ahProgBar[0], "Any text ...");
    PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_LEFT);
    for (; (i <= 100)&& !GUIDEMO_CheckCancel(); i++) {
      PROGBAR_SetValue(ahProgBar[0], i);
      PROGBAR_SetValue(ahProgBar[1], 200 + i);
      GUI_Delay(5);
    }
    for (; (i >= 0)&& !GUIDEMO_CheckCancel(); i--) {
      PROGBAR_SetValue(ahProgBar[0], i);
      PROGBAR_SetValue(ahProgBar[1], 400 - i);
      GUI_Delay(5);
    }
    PROGBAR_SetFont(ahProgBar[0], &GUI_FontComic18B_1);
    PROGBAR_SetText(ahProgBar[0], "Any font ...");
    for (; (i <= 100)&& !GUIDEMO_CheckCancel(); i++) {
      PROGBAR_SetValue(ahProgBar[0], i);
      PROGBAR_SetValue(ahProgBar[1], 400 + i);
      GUI_Delay(5);
    }
    GUIDEMO_Delay(1000);
  }
  GUIDEMO_Delay(1000);
  PROGBAR_Delete(ahProgBar[0]);
  PROGBAR_Delete(ahProgBar[1]);
  GUIDEMO_Delay(1000);
  GUI_SetFont(&GUI_Font10S_ASCII);
}
void GUIDEMO_main(void) {
  #if GUI_WINSUPPORT
    int i;
  #endif
  GUI_Clear();
  #if GUI_WINSUPPORT
    WM_SetCreateFlags(WM_CF_MEMDEV);  /* Automatically use memory devices on all windows */
    /* Calculate position and size of FrameWin[1] */
    _FrameWinSizeX[1] = 80;
    _FrameWinSizeY[1] = 60;
    _FrameWinPosX[1] = LCD_GetXSize() - _FrameWinSizeX[1];
    _FrameWinPosY[1] = LCD_GetYSize() - _FrameWinSizeY[1];
    _ButtonSizeX = (_FrameWinSizeX[1] - 20) / 2;
    _ButtonSizeY = 20;
    /* Create the control window incl. buttons */
    _ahFrameWin[1] = FRAMEWIN_Create("Control", NULL, WM_CF_SHOW | WM_CF_STAYONTOP,
                                     _FrameWinPosX[1], _FrameWinPosY[1],
                                     _FrameWinSizeX[1], _FrameWinSizeY[1]);
    _ahInfoWin[1] = WM_CreateWindowAsChild(0, 0, 0, 0, _ahFrameWin[1], 
                                           WM_CF_SHOW | WM_CF_STAYONTOP, 0, 0);
    _ahButton[0] = BUTTON_CreateAsChild(_FrameWinSizeX[1] / 20,
                                 + 20, _ButtonSizeX, _ButtonSizeY, _ahFrameWin[1], 
                                 'H' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV);
    _ahButton[1] = BUTTON_CreateAsChild(_FrameWinSizeX[1] / 2,
                                 + 20, _ButtonSizeX, _ButtonSizeY, _ahFrameWin[1], 
                                 'N' , WM_CF_SHOW | WM_CF_STAYONTOP | WM_CF_MEMDEV);
    BUTTON_SetText(_ahButton[0], "Stop");
    BUTTON_SetText(_ahButton[1], "Next");
    _UpdateCmdWin();
    WM_ExecIdle();
  #endif
  /* Show Intro */
  GUIDEMO_Intro();
  #if GUI_WINSUPPORT
    /* Calculate position and size of FrameWin[0] */
    _FrameWinSizeX[0] = LCD_GetXSize() / 2;
    _FrameWinSizeY[0] = 65;
    _FrameWinPosX[0] = LCD_GetXSize() - _FrameWinSizeX[0];
    _FrameWinPosY[0] = 0;
    /* Create info window and run the individual demos */
    _ahFrameWin[0] = FRAMEWIN_Create("ARMSYS Demo", NULL, WM_CF_STAYONTOP, 
                                     _FrameWinPosX[0], _FrameWinPosY[0], _FrameWinSizeX[0], _FrameWinSizeY[0]);
    _ahInfoWin[0] = WM_CreateWindowAsChild(0, 0, 0, 0, _ahFrameWin[0], WM_CF_STAYONTOP, 0, 0);
    WM_ExecIdle();
  #endif
  /* Run the individual demos !  */
  for (_iTest = 0; _apfTest[_iTest]; _iTest++) {
    GUI_CONTEXT ContextOld;
    GUI_SaveContext(&ContextOld);
    _iTestMinor = 0;
    _UpdateCmdWin();
    (*_apfTest[_iTest])();
    _CmdNext = 0;
    GUI_RestoreContext(&ContextOld);
  }
  /* Cleanup */
  #if GUI_WINSUPPORT
    for (i = 0; i < countof(_ahFrameWin); i++) {
      WM_DeleteWindow(_ahFrameWin[i]);
    }
    for (i = 0; i < countof(_ahInfoWin); i++) {
      WM_DeleteWindow(_ahInfoWin[i]);
    }
  #endif
}
Beispiel #21
0
/**
  * @brief  Callback function of the MJPEG frame
  * @param  pMsg: pointer to a data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbVideoWindow(WM_MESSAGE * pMsg) 
{
  char temp[20];
  static WM_HTIMER hTimerTime;
  WM_HWIN hItem;  
  const GUI_PID_STATE * pState;
  
  GUI_RECT r;
  WM_GetInsideRect(&r);
  
  switch (pMsg->MsgId) 
  {
    
  case  WM_TOUCH:
    if(VideoPlayer_State == VIDEO_PLAY)
    {
      pState = (const GUI_PID_STATE *)pMsg->Data.p;
      if (pState) {
        if (pState->Pressed == 1) {
          VIDEO_Enlarge ^= 1;
          if(VIDEO_Enlarge)
          {
            GUI_SetOrientation(GUI_SWAP_XY | GUI_MIRROR_Y);
            TS_Orientation = 1;
            WM_AttachWindowAt(pMsg->hWin, WM_GetDesktopWindowEx(1), 0, 0);
            WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize());
          }
          else
          {
            WM_AttachWindow(pMsg->hWin, bkparent);
            GUI_SetOrientation(0);
            TS_Orientation = 0;
            WM_InvalidateWindow(bkparent);    
            
            WM_AttachWindowAt(pMsg->hWin, VIDEO_hWin, 5, 16);
            WM_SetSize(pMsg->hWin,230, 170);
            do_clear = 1;
          }
        }
      }
    }
    break;
    
    
  case WM_CREATE:
    /* Create timer */
    hTimerTime = WM_CreateTimer(pMsg->hWin, 0, 50, 0);        
    break;
    
  case WM_TIMER:
    WM_InvalidateWindow(pMsg->hWin);
    WM_RestartTimer(pMsg->Data.v, 0);
    
    break; 
    
  case WM_DELETE:
    WM_DeleteTimer(hTimerTime);
    break;

    
  case WM_PAINT:
    
    if(do_clear)
    {
      GUI_ClearRectEx(&r);
      do_clear = 0;
    } 
    
    if(VideoPlayer_State == VIDEO_PLAY)
    {
      if(_PlayMJPEG(&Video_File) < 0)
      {
        VideoPlayer_State = VIDEO_PLAY;
        ImageOffset = 0; 
        time_start = GUI_GetTime();    
        f_close(&Video_File);
        goto_next_file();      
        hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_FILE);
        TEXT_SetText(hItem, (char *)FILEMGR_FileList.file[FILEMGR_FileList.idx].line);        
      }
      
      hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_PROGRESS);
      
      if (progress_bar == 0)
      {
        SLIDER_SetValue(hItem, (ImageOffset * 100 )/ Video_File.fsize);
      }
      
      hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_VIDEO_DURATION);
      
      duration = (GUI_GetTime() - time_start )/1000;
      if(duration < 0) duration = 0;
      sprintf(temp,"%02d:%02d", duration/60, duration%60); 
      TEXT_SetText(hItem, temp);  
    }
    else if(VideoPlayer_State == VIDEO_IDLE)
    {
      GUI_ClearRectEx(&r);
    }
    
    break;
    
  default:
    WM_DefaultProc(pMsg);
  }
  
}
Beispiel #22
0
static void _Show_Sensor_Graph(GRAPH_Handle hGraph, GRAPH_DATA_Handle hData[])
{
  int xSize      = LCD_GetXSize();
  int Data_xSize = xSize - (DIST_TO_BORDER << 1) - (BORDER_LEFT + BORDER_RIGHT);
  int Count      = 0;

  //
  // Attach data objects
  //
  GRAPH_AttachData(hGraph, hData[0]);
  GRAPH_AttachData(hGraph, hData[1]);
  GRAPH_AttachData(hGraph, hData[2]);
  //
  // Add values before GRAPH is displayed
  //
  while (Count < Data_xSize) {
    GRAPH_DATA_YT_AddValue(hData[0], (I16)0);
    GRAPH_DATA_YT_AddValue(hData[1], (I16)0);
    GRAPH_DATA_YT_AddValue(hData[2], (I16)0);
    Count++;
  }

  sensor_all_open();

  // uint32_t lux_senser;
  // get_als_data(&lux_senser);
  int32_t x,y,z;
  uint32_t setp;
  //
  // Add values depending on time
  //
  // int TimeStart, TimeDiff, TimeStep;
  // int NextState, Flag;
  // lighten GS LED
  hal_gpio_output_low(&brd_gpio_table[GPIO_LED_GS]);

  // TimeStart = GUIDEMO_GetTime();
  int Flag = 1;
  do {
    get_acc_data(&x,&y,&z,&setp);
    // TimeDiff = GUIDEMO_GetTime() - TimeStart;
    GRAPH_DATA_YT_AddValue(hData[0], ((I16)x >> 5) + 78);
    GRAPH_DATA_YT_AddValue(hData[1], ((I16)y >> 5) + 78);
    GRAPH_DATA_YT_AddValue(hData[2], ((I16)z >> 5) + 78);

    if (Flag) {
      Flag = 0;
      GUI_Exec();
      GRAPH_DetachScale(hGraph, _hScaleH_sensor);
      GRAPH_DetachScale(hGraph, _hScaleV_sensor);
      WM_ValidateWindow(hGraph);
    }
    /*
    NextState = GUIDEMO_CheckCancel();
    TimeStep  = GUIDEMO_GetTime() - TimeStart;
    if ((TimeStep - TimeDiff) < TIME_STEP) {
      GUI_Delay(TIME_STEP - (TimeStep - TimeDiff));
    }*/
    GUI_Delay(100);
  } while (key_flag == GUI_DEMO_PAGE_3);

  GRAPH_DetachData(hGraph, hData[0]);
  GRAPH_DetachData(hGraph, hData[1]);
  GRAPH_DetachData(hGraph, hData[2]);

  // GUIDEMO_NotifyStartNext();

  // shutdown GS LED
  hal_gpio_output_high(&brd_gpio_table[GPIO_LED_GS]);
}
/*********************************************************************
*
*       GUIDEMO_Speed
*/
void GUIDEMO_Speed(void) {
  int      TimeStart, i;
  U32      PixelsPerSecond;
  unsigned aColorIndex[8];
  int      xSize, ySize, vySize;
  GUI_RECT Rect, ClipRect;
  char     cText[40] = { 0 };

  xSize  = LCD_GetXSize();
  ySize  = LCD_GetYSize();
  vySize = LCD_GetVYSize();
#if GUI_SUPPORT_CURSOR
  GUI_CURSOR_Hide();
#endif
  if (vySize > ySize) {
    ClipRect.x0 = 0;
    ClipRect.y0 = 0;
    ClipRect.x1 = xSize;
    ClipRect.y1 = ySize;
    GUI_SetClipRect(&ClipRect);
  }
  GUIDEMO_ShowIntro("High speed",
                    "Multi layer clipping\n"
                    "Highly optimized drivers");
  for (i = 0; i< 8; i++) {
    aColorIndex[i] = GUI_Color2Index(_aColor[i]);
  }  
  TimeStart = GUIDEMO_GetTime();
  for (i = 0; ((GUIDEMO_GetTime() - TimeStart) < 5000) && (GUIDEMO_CheckCancel() == 0); i++) {
    GUI_SetColorIndex(aColorIndex[i&7]);
    //
    // Calculate random positions
    //
    Rect.x0 = rand() % xSize - xSize / 2;
    Rect.y0 = rand() % ySize - ySize / 2;
    Rect.x1 = Rect.x0 + 20 + rand() % xSize;
    Rect.y1 = Rect.y0 + 20 + rand() % ySize;
    GUI_FillRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1);
    //
    // Clip rectangle to visible area and add the number of pixels (for speed computation)
    //
    if (Rect.x1 >= xSize) {
      Rect.x1 = xSize - 1;
    }
    if (Rect.y1 >= ySize) {
      Rect.y1 = ySize - 1;
    }
    if (Rect.x0 < 0 ) {
      Rect.x0 = 0;
    }
    if (Rect.y1 < 0) {
      Rect.y1 = 0;
    }
    GUI_Exec();
    //
    // Allow short breaks so we do not use all available CPU time ...
    //
  }
  GUIDEMO_NotifyStartNext();
  PixelsPerSecond = _GetPixelsPerSecond();
  GUI_SetClipRect(NULL);
  GUIDEMO_DrawBk(0);
  GUI_SetColor(GUI_WHITE);
  GUI_SetTextMode(GUI_TM_TRANS);
  GUI_SetFont(&GUI_FontRounded22);
  GUI_DrawBitmap(&bmSTLogo70x35, 5, 5);
  GUIDEMO_AddStringToString(cText, "Pixels/sec: ");
  GUIDEMO_AddIntToString(cText, PixelsPerSecond);
  GUI_DispStringHCenterAt(cText, xSize >> 1, (ySize - GUI_GetFontSizeY()) >> 1);
  GUIDEMO_Delay(4000);
#if GUI_SUPPORT_CURSOR
  GUI_CURSOR_Show();
#endif
}
Beispiel #24
0
static void _Graph_Sensor_Demo()
{
  const WIDGET_EFFECT * pEffectOld;
  GRAPH_Handle          hGraph;
  GRAPH_DATA_Handle     hData[3];
  // GRAPH_DATA_Handle     hData;
  int                   xSize, ySize, i;
  int                   Graph_xSize, Graph_ySize, Data_ySize;
  int                   Graph_xPos, Graph_yPos;

  // set back screen black
  // GUI_SetColor(GUI_BLACK);
  // GUIDEMO_DrawBk(1);

  xSize      = LCD_GetXSize();
  ySize      = LCD_GetYSize();  // 256
  pEffectOld = WIDGET_SetDefaultEffect(&WIDGET_Effect_Simple);
  // Return a poninter to the previous callback routine
  // Set Callback function for background window
  // The given window will be invalidated. This makes sure the window will be redrawn
  WM_SetCallback(WM_HBKWIN, _cbBk_test);
  //
  // Determine size of GRAPH
  //
  Graph_xSize = xSize - (DIST_TO_BORDER << 1);            // xsize = Screen size subtracting twice the distance to the border of the screen
  Graph_ySize = ySize - INFO_SIZE_Y - (DIST_TO_WIN << 1); // ysize = Screen size subtracting the window sizes and twice the distance to the windows
  if (Graph_ySize > MAX_GRAPH_SIZE_Y) {  // 181
    Graph_ySize = MAX_GRAPH_SIZE_Y;  // 140
    if (Graph_xSize > (Graph_ySize * 20) / 11) {
      Graph_xSize = (Graph_ySize * 20) / 11;
    }
  }
  //
  // Create and configure GRAPH_WIDGET
  //
  Graph_xPos = (xSize - Graph_xSize) >> 1;
  Graph_yPos = (ySize - Graph_ySize) >> 1;
  if (Graph_yPos < INFO_SIZE_Y + DIST_TO_WIN) {
    Graph_yPos = INFO_SIZE_Y + DIST_TO_WIN;
  }
  // create a graph widget
  hGraph = GRAPH_CreateEx(Graph_xPos, Graph_yPos, Graph_xSize, Graph_ySize, WM_HBKWIN, WM_CF_SHOW | WM_CF_CONST_OUTLINE, 0, 0);
  GRAPH_SetBorder(hGraph, BORDER_LEFT, BORDER_TOP, BORDER_RIGHT, BORDER_BOTTOM);  // set width of border
  WM_SetHasTrans (hGraph);  // enbale tansparency for the given window
  GRAPH_SetColor (hGraph, COLOR_BK,     GRAPH_CI_BK);  // Sets the desired color of the given GRAPH widget
  GRAPH_SetColor (hGraph, COLOR_BORDER, GRAPH_CI_BORDER);
  GRAPH_SetColor (hGraph, COLOR_FRAME,  GRAPH_CI_FRAME);
  GRAPH_SetColor (hGraph, COLOR_GRID,   GRAPH_CI_GRID);
  //
  // Adjust grid
  //
  GRAPH_SetGridVis  (hGraph, 1);  // set grid visible
  GRAPH_SetGridDistX(hGraph, GRID_DIST_X);  // set horizontal grid spacing
  GRAPH_SetGridDistY(hGraph, GRID_DIST_Y);  // set vertical grid spacing
  WM_BringToBottom  (hGraph);  // Places hGraph underneath its siblings
  //
  // Create and configure GRAPH_DATA_YT object
  //

  for (i = 0; i < 3; i++) {
    // Create a point valude which include a X-axis value on the Y-axis
    hData[i] = GRAPH_DATA_YT_Create(_aColorData_sensor[i], xSize - (DIST_TO_BORDER << 1) - BORDER_LEFT, 0, 0);
  }

  // hData = GRAPH_DATA_YT_Create(_aColorData_sensor[0], xSize - (DIST_TO_BORDER << 1) - BORDER_LEFT, 0, 0);
  Data_ySize = Graph_ySize - BORDER_BOTTOM;  // 131
  //
  // Create and configure GRAPH_SCALE objects
  //
  _hScaleH_sensor = GRAPH_SCALE_Create(BORDER_BOTTOM >> 1, GUI_TA_VCENTER, GRAPH_SCALE_CF_HORIZONTAL, TICK_DIST_H);
  _hScaleV_sensor = GRAPH_SCALE_Create(BORDER_LEFT   >> 1, GUI_TA_HCENTER, GRAPH_SCALE_CF_VERTICAL,   TICK_DIST_V);
  GRAPH_SCALE_SetPos(_hScaleH_sensor, Graph_ySize - 4);  // Sets the vertical position for showing the scale object with in the GRAPH widget
  GRAPH_SCALE_SetOff(_hScaleH_sensor, -5);  // Sets an horizontal offset used to 'shift' the scale object in positive or negative direction

  // show sensor graph
  GUIDEMO_ShowInfo("sensor demo");
  GRAPH_AttachScale(hGraph, _hScaleH_sensor);
  GRAPH_AttachScale(hGraph, _hScaleV_sensor);
  // _Data_Sensor_Adjust = (Data_ySize * 100) >> GRAPH_DIV;
  // (Data_ySize * 21) >> GRAPH_DIV
  GRAPH_SetGridOffY (hGraph, 6);  // Add an offset used to show the horizontal grid lines
  // (((Data_ySize - BORDER_BOTTOM) * 260) >> GRAPH_DIV)
  GRAPH_SCALE_SetOff(_hScaleV_sensor, 75);

  _Show_Sensor_Graph(hGraph, hData);

  //
  // Clean up
  //
  GRAPH_DetachScale(hGraph, _hScaleH_sensor);
  GRAPH_DetachScale(hGraph, _hScaleV_sensor);
  GRAPH_SCALE_Delete(_hScaleH_sensor);
  GRAPH_SCALE_Delete(_hScaleV_sensor);

  for (i = 0; i < 3; i++) {
    GRAPH_DATA_YT_Delete(hData[i]);
  }
  // GRAPH_DATA_YT_Delete(hData);
  WM_DeleteWindow(hGraph);
  WIDGET_SetDefaultEffect(pEffectOld);

}
/**
  * @brief  Callback function of the image frame
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbImageWindow(WM_MESSAGE * pMsg)
{
  WM_HWIN  hItem;
  GUI_RECT r;
  int Id;
  const GUI_PID_STATE * pState;
  
  switch (pMsg->MsgId)
  {
  case  WM_TOUCH:
    pState = (const GUI_PID_STATE *)pMsg->Data.p;
    if(pImageList->ptr > 0)
    {
      if (pState) {
        if (pState->Pressed == 1)
        {
          IMAGE_Enlarge ^= 1;
          if (IMAGE_Enlarge)
          {
            WM_AttachWindowAt(pMsg->hWin, WM_HBKWIN, 0, 0);
            WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize());
          }
          else
          {
            WM_AttachWindowAt(pMsg->hWin, IMAGE_hWin, 15, 15);
            WM_SetSize(pMsg->hWin, 420, 370);
          }
          WM_InvalidateWindow(pMsg->hWin);
        }
      }
    }
    break;
      
    
  case WM_PAINT:
    WM_GetInsideRect(&r);
    GUI_ClearRectEx(&r);
    if (pImageList->ptr > 0)
    {
      if(_DrawImage(&Image_File, IMAGE_Enlarge, IMAGE_Type) > 0)
      {
        f_close(&Image_File);
                  
        GUI_ClearRectEx(&r);
        GUI_DispStringAt("Error : Image cannot be displayed", 35,  100); 
        if(hTimerTime != 0)
        {
          slideshow_state = OFF;
          
          hItem = WM_GetDialogItem(IMAGE_hWin, ID_SLIDE_BUTTON);
          WM_InvalidateWindow(hItem);
          WM_Update(hItem);
          
          WM_DeleteTimer(hTimerTime);
          hTimerTime = 0;

        }        
      }
    }
    break;
    
  case WM_TIMER:
    
   Id = WM_GetTimerId(pMsg->Data.v);
            
   if(Id == ID_SLIDER_TIMER)
   {
     if(pImageList->ptr > 1)
     {
       if (file_pos < (pImageList->ptr - 1))
       {
         file_pos++;
       }
       else if (file_pos == (pImageList->ptr - 1))
       {
         file_pos=0;
       }
       
       if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
       {
         IMAGE_Type = IMAGE_TYPE_BMP;
       }
       else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
       {
         IMAGE_Type = IMAGE_TYPE_JPG;
       }
       
       f_close(&Image_File);
       f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
       WM_InvalidateWindow(imFrame);
       hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
       LISTBOX_SetSel(hItem, file_pos);
     }
     
     WM_RestartTimer(pMsg->Data.v, (ImSettings.b.ss_timer * 1000));
   }
   else if (Id == ID_PLAYLIST_TIMER)
   {
     playlist_select = 0;
   }    
   break;
    
  case WM_DELETE:
    if(hTimerTime != 0)
    {
      WM_DeleteTimer(hTimerTime);
      hTimerTime = 0;
    }
    break;
    
  default:
    WM_DefaultProc(pMsg);
  }
  
}
Beispiel #26
0
void GUIDEMO_Unclassified(void) {
  int xSize = LCD_GetXSize();
	int32_t acc_adc_data[3] = {0};
	float acc_nkg[3] = {0};
	uint32_t baro_data = 0;
	int32_t temp_data = 0;
	uint32_t humi_data = 0;
	uint32_t als_data = 0;
	uint32_t ps_data = 0;
  uint32_t step = 0;
#if 0
	if (sensor_all_open() != 0)
		return;
#endif
  sensor_all_open();

  // lighten GS-LED and ALS-LED
  hal_gpio_output_low(&brd_gpio_table[GPIO_LED_GS]);
  hal_gpio_output_low(&brd_gpio_table[GPIO_LED_ALS]);

  // set back screen black

  // GUIDEMO_HideInfoWin();
  // GUIDEMO_ShowControlWin();
  // GUI_Exec();
  GUIDEMO_DrawBk(1);
  GUI_SetColor(GUI_BLACK);
  GUIDEMO_DrawBk(1);

  // set font
	GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_Font16_ASCII);

  GUI_DispStringAt("step",                GUIDEMO_UNCLASSIFIED_OFFSET, Y_START);
  GUI_DispStringAt("acc_x",               GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  2);
  GUI_DispStringAt("acc_y",               GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  4);
  GUI_DispStringAt("acc_z",               GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  6);
#if 0
  GUI_DispStringAt("barometer",     GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  6);
  GUI_DispStringAt("temperature",   GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  8);
  GUI_DispStringAt("humidity",      GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  10);
#endif
  GUI_DispStringAt("als",                  GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  8);
	GUI_DispStringAt("proximity",            GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  10);
  GUI_DispStringAt("sensor data upload:",  GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  12);


  // GUI_HWIN hWnd;

  do{
      // print value
      // GUI_SetOrientation(GUI_SWAP_XY);

   //   hWnd = WM_CreateWindow(10, 10, 200, 200, WM_CF_HIDE, _cbDesktop, 0);
   //   HAL_Delay(1000);
   //   WM_DeleteWindow(hWnd);

      // print value type

      if (!get_acc_data(&acc_adc_data[0], &acc_adc_data[1], &acc_adc_data[2], &step)) {
				acc_nkg[0] = (float)acc_adc_data[0] * 9.8 / 1024;
				acc_nkg[1] = (float)acc_adc_data[1] * 9.8 / 1024;
				acc_nkg[2] = (float)acc_adc_data[2] * 9.8 / 1024;
				GUI_GotoXY((xSize >> 1) + GUIDEMO_UNCLASSIFIED_OFFSET, Y_START);
        GUI_DispDec(step, DEC_LEN_DEF);
				GUI_GotoXY((xSize >> 1) + GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  2);
				GUI_DispFloatFix(acc_nkg[0], 7, 3);
				GUI_DispString(" N/kg");
				GUI_GotoXY((xSize >> 1) + GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  4);
				GUI_DispFloatFix(acc_nkg[1], 7, 3);
				GUI_DispString(" N/kg");
				GUI_GotoXY((xSize >> 1) + GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  6);
				GUI_DispFloatFix(acc_nkg[2], 7, 3);
				GUI_DispString(" N/kg");
      }
      else {
        GUI_DispStringAt("unknow", (xSize >> 1) + GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  2);
        GUI_DispStringAt("unknow", (xSize >> 1) + GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  4);
        GUI_DispStringAt("unknow", (xSize >> 1) + GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  6);
      }
#if 0
      if (!get_baro_data(&baro_data)) {
        GUI_GotoXY((xSize >> 1) + GUIDEMO_UNCLASSIFIED_OFFSET, Y_START + Y_STEP *  6);
        GUI_DispDec(baro_data, DEC_LEN_DEF);
      }
Beispiel #27
0
void colorbar(void)
{
	#define X_START 60   //????? X ??
	#define Y_START 40  //????? Y ??
	typedef struct {
	int NumBars;
	GUI_COLOR Color;
	const char * s;
	} BAR_DATA; 
	static const BAR_DATA _aBarData[] = {
	{ 2, GUI_RED     , "Red" },
	{ 2, GUI_GREEN   , "Green" },
	{ 2, GUI_BLUE    , "Blue" },
	{ 1, GUI_WHITE   , "Grey" },
	{ 2, GUI_YELLOW , "Yellow" },
	{ 2, GUI_CYAN    , "Cyan" },
	{ 2, GUI_MAGENTA, "Magenta" },
	};
	static const GUI_COLOR _aColorStart[] = { GUI_BLACK, GUI_WHITE };
	GUI_RECT Rect;
	int  yStep;
	int       i;
	int       j;
	int       xSize;
	int       ySize;
	int       NumBars;     //????????? 2+2+2+1+2+2+2=13
	int       NumColors;   //????????,??? 7 ?
	//??????

	GUI_SetBkColor(GUI_BLUE);
	GUI_SetColor(GUI_YELLOW);
	GUI_Clear();
	GUI_SetFont(&GUI_Font24_ASCII);
	GUI_SetTextMode(GUI_TM_TRANS);  //????
	GUI_DispStringHCenterAt("COLOR_BAR TEST!",120,0);

	xSize = LCD_GetXSize();
	ySize = LCD_GetYSize();
	//????????
	NumColors = GUI_COUNTOF(_aBarData);  
	for (i = NumBars = 0, NumBars = 0; i < NumColors; i++) {
		NumBars += _aBarData[i].NumBars;
	}
	yStep = (ySize -  Y_START) / NumBars;
	//????
	Rect.x0 = 0;
	Rect.x1 = X_START - 1;
	Rect.y0 = Y_START;
	GUI_SetFont(&GUI_Font8x16);
	for (i = 0; i < NumColors; i++) {
		Rect.y1 = Rect.y0 + yStep * _aBarData[i].NumBars - 1; 
		GUI_DispStringInRect(_aBarData[i].s, &Rect, GUI_TA_LEFT | GUI_TA_VCENTER);  
		Rect.y0 = Rect.y1 + 1;
	}
	//????
	Rect.x0 = X_START;
	Rect.x1 = xSize - 1;
	Rect.y0 = Y_START;
	for (i = 0; i < NumColors; i++) {
		for (j = 0; j < _aBarData[i].NumBars; j++) {
			Rect.y1 = Rect.y0 + yStep - 1;
			GUI_DrawGradientH(Rect.x0, Rect.y0, Rect.x1, Rect.y1,_aColorStart[j], _aBarData[i].Color); //????
			Rect.y0 = Rect.y1 + 1;
		}
	}
}
Beispiel #28
0
static void _Draw2(void * p) {
  PARAM * pParam = (PARAM *)p;
  _Draw(p);
  GUI_SetColor(COLOR_GRAPH1);
  GUI_DrawGraph(pParam->aY+15, (LCD_GetXSize() - 20), 19, (LCD_GetYSize() - 20) - _YSize);
}
void GUIDEMO_ColorBar(void) {
  GUI_COLOR ColorStartBlack, ColorStartWhite;
  char      acText[80] = { 0 };
  int       NumColors, BitsPerPixel, xSize, ySize;
  int       Time, TimeStart;
  int       Dir, Index;

  xSize = LCD_GetXSize();
  ySize = LCD_GetYSize();
  GUIDEMO_ShowIntro("Color bar",
                    "STemWin features an integrated\n"
                    "color management which automatically finds\n"
                    "the best available color for any logical color");
  GUIDEMO_DrawBk(1);
  //
  // Heading
  //
	GUI_SetColor(GUI_WHITE);
	GUI_SetFont(&GUI_FontRounded22);
	GUI_DispStringHCenterAt("Color bars", xSize >> 1, 12);
  GUI_SetFont(&GUI_Font16_ASCII);
  //
  // Colors
  //
  GUI_DispStringAt("Red",     1, Y_START);
  GUI_DispStringAt("Green",   1, Y_START + Y_STEP *  2);
  GUI_DispStringAt("Blue",    1, Y_START + Y_STEP *  4);
  GUI_DispStringAt("Grey",    1, Y_START + Y_STEP *  5 + (Y_STEP >> 1));
  GUI_DispStringAt("Yellow",  1, Y_START + Y_STEP *  7);
  GUI_DispStringAt("Cyan",    1, Y_START + Y_STEP *  9);
  GUI_DispStringAt("Magenta", 1, Y_START + Y_STEP * 11);
  //
  // Additional Information
  //
  GUI_SetFont(&GUI_Font8_ASCII);
  //
  // LCD Controller
  //
  #ifdef LCD_CONTROLLER
    GUIDEMO_AddStringToString(acText, "LCD Controller: ");
    GUIDEMO_AddStringToString(acText, LCD_CONTROLLER);
    GUI_DispStringAt         (acText, 12, ySize - 45);
    GUIDEMO_ClearText        (acText);
  #endif
  //
  // BPP and number of colors
  //
  BitsPerPixel = LCD_GetBitsPerPixel();
  GUIDEMO_AddIntToString   (acText, BitsPerPixel);
  GUIDEMO_AddStringToString(acText, " bpp");
  NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS);
  if (NumColors) {
    GUIDEMO_AddStringToString(acText, ", ");
    GUIDEMO_AddIntToString   (acText, NumColors);
    GUIDEMO_AddStringToString(acText, " colors");
  }
  GUI_DispStringAt(acText, 12, ySize - 25);
  //
  // Gradients
  //
  TimeStart = GUIDEMO_GetTime();
  while (((GUIDEMO_GetTime() - TimeStart) < TIME_RUN) && (GUIDEMO_CheckCancel() == 0)) {
    Time  = (GUIDEMO_GetTime() - TimeStart) % ((TIME_PAUSE + TIME_STEP) << 1);
    Dir   = Time / (TIME_PAUSE + TIME_STEP);
    Time -= Dir * (TIME_PAUSE + TIME_STEP);
    if (Time > TIME_PAUSE) {
      continue;
    }
    Index = ((Time * 0xFF) / TIME_STEP) ^ (Dir * 0xFF);
    ColorStartBlack = 0x000000 + 0x010101 * Index;
    ColorStartWhite = 0xFFFFFF - ColorStartBlack;
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  0, xSize, (Y_START + Y_STEP *  1) - 1, GUI_RED,     ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  1, xSize, (Y_START + Y_STEP *  2) - 1, GUI_RED,     ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  2, xSize, (Y_START + Y_STEP *  3) - 1, GUI_GREEN,   ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  3, xSize, (Y_START + Y_STEP *  4) - 1, GUI_GREEN,   ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  4, xSize, (Y_START + Y_STEP *  5) - 1, GUI_BLUE,    ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  5, xSize, (Y_START + Y_STEP *  6) - 1, GUI_BLUE,    ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  6, xSize, (Y_START + Y_STEP *  7) - 1, GUI_GRAY,    ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  7, xSize, (Y_START + Y_STEP *  8) - 1, GUI_YELLOW,  ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  8, xSize, (Y_START + Y_STEP *  9) - 1, GUI_YELLOW,  ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP *  9, xSize, (Y_START + Y_STEP * 10) - 1, GUI_CYAN,    ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP * 10, xSize, (Y_START + Y_STEP * 11) - 1, GUI_CYAN,    ColorStartBlack);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP * 11, xSize, (Y_START + Y_STEP * 12) - 1, GUI_MAGENTA, ColorStartWhite);
    GUI_DrawGradientH(GRADIENT_START_X, Y_START + Y_STEP * 12, xSize, (Y_START + Y_STEP * 13) - 1, GUI_MAGENTA, ColorStartBlack);
    GUI_Exec();
  }
}
Beispiel #30
0
/*********************************************************************
*
*       _DemoBarGraph
*/
static void _DemoBarGraph(void) {
  GUI_MEMDEV_Handle hMem;
  int               ayOrg[] = { 10, 20, 40, 50, 90, 100, 80, 30, 20, 10 };
  int               ayCur[] = { 10, 20, 40, 50, 90, 100, 80, 30, 20, 10 };
  int               aAdd[GUI_COUNTOF(ayOrg)];
  int               NextState;
  int               TimeStart;
  int               xPosGraph;
  int               yPosGraph;
  int               AddBlend;
  int               NumItems;
  int               TimeDiff;
  int               TimeStep;
  int               Blend;
  int               xSize;
  int               ySize;
  int               i;

  //
  // Initialize values; 
  //
  AddBlend  = 1;
  Blend     = 64;
  NumItems  = GUI_COUNTOF(ayOrg);
  xSize     = LCD_GetXSize();
  ySize     = LCD_GetYSize();
  xPosGraph = (xSize - GRAPH_WIDTH)  / 2;
  yPosGraph = (ySize - GRAPH_HEIGHT) / 2;
  //
  // Create MEMDEV
  //
  hMem = GUI_MEMDEV_Create(xPosGraph, yPosGraph, GRAPH_WIDTH + 7 + 1, GRAPH_HEIGHT + 1);
  if (hMem == 0) {
    return;
  }
  GUI_MEMDEV_CopyFromLCD(hMem);
  for (i = 0; i < NumItems; i++) {
    aAdd[i] = (i & 1) * 2 - 1;
  }
  _DrawLabel(0, xPosGraph, yPosGraph);
  TimeStart = GUIDEMO_GetTime();
  do {
    TimeDiff = GUIDEMO_GetTime() - TimeStart;
    _DrawDiagramAt(hMem, xPosGraph, yPosGraph, ayCur, Blend);
    Blend += AddBlend;
    if ((Blend >= 164) || (Blend <= 8)) {
      AddBlend = -AddBlend;
    }
    for (i = 0; i < NumItems; i++) {
      *(ayCur + i) += *(aAdd + i);
      if ((*(ayCur + i) > (*(ayOrg + i) + 10)) || (*(ayCur + i) < (*(ayOrg + i) - 10))) {
        *(aAdd + i) = -*(aAdd + i);
      }
    }
    TimeStep = GUIDEMO_GetTime() - TimeStart;
    if ((TimeStep - TimeDiff) < TIME_STEP) {
      GUI_Delay(TIME_STEP - (TimeStep - TimeDiff));
    } else {
      GUI_Exec();
    }
    NextState = GUIDEMO_CheckCancel();
  } while ((TimeDiff < SHOW_TIME) && (NextState == 0));
  GUI_MEMDEV_Delete(hMem);
}