Пример #1
0
/**
  * @brief  Initialization of calibration
  * @param  None.
  * @retval None
  */
void k_CalibrationInit(void)
{
  int aPhysX[2], aPhysY[2], aLogX[2], aLogY[2], i;

  data1.d32 = k_BkupRestoreParameter(RTC_BKP_DR0);
  data2.d32 = k_BkupRestoreParameter(RTC_BKP_DR1);
  
  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_Font13B_ASCII);
    _Explain();
    /* Set the logical values */
    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;
    k_BkupSaveParameter(RTC_BKP_DR0, data1.d32);
    
    data2.b.A2 = A2;
    data2.b.B2 = B2;
    data2.b.IsCalibrated = 1;
    k_BkupSaveParameter(RTC_BKP_DR1, data2.d32);  
    
    /* Display the result */
    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);
}
Пример #2
0
/**
  * @brief  set the GUI profile
  * @param  None.
  * @retval None
  */
void k_SetGuiProfile(void)
{

  settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP);

  if(settings.b.disable_flex_skin == 0)
  {
    FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX);
    PROGBAR_SetDefaultSkin(PROGBAR_SKIN_FLEX);
    RADIO_SetDefaultSkin(RADIO_SKIN_FLEX);
    SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX);
    SLIDER_SetDefaultSkin(SLIDER_SKIN_FLEX);
    SPINBOX_SetDefaultSkin(SPINBOX_SKIN_FLEX);
    BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX);
    DROPDOWN_SetDefaultSkin(DROPDOWN_SKIN_FLEX);

    FRAMEWIN_SetDefaultTextColor(0, GUI_DARKGRAY);
    FRAMEWIN_SetDefaultTextColor(1, GUI_DARKGRAY);
  }
  else
  {
    FRAMEWIN_SetDefaultTextColor(0, GUI_WHITE);
    FRAMEWIN_SetDefaultTextColor(1, GUI_WHITE);
  }

  FRAMEWIN_SetDefaultFont(GUI_FONT_24_ASCII);

  FRAMEWIN_SetDefaultClientColor(GUI_LIGHTGRAY | 0x20F50000);
  FRAMEWIN_SetDefaultTitleHeight(25);

  TREEVIEW_SetDefaultBkColor(TREEVIEW_CI_SEL, GUI_LIGHTGRAY | 0x20E50000);
  TREEVIEW_SetDefaultBkColor(TREEVIEW_CI_UNSEL, GUI_LIGHTGRAY | 0x20E50000);
  TREEVIEW_SetDefaultTextColor(TREEVIEW_CI_SEL, GUI_BLUE);
  TREEVIEW_SetDefaultFont(GUI_FONT_20_ASCII);

  WINDOW_SetDefaultBkColor(GUI_LIGHTGRAY | 0x20E50000);
  MULTIPAGE_SetDefaultBkColor(GUI_LIGHTGRAY | 0x20E50000, 0);
  MULTIPAGE_SetDefaultBkColor(GUI_LIGHTGRAY | 0x20E50000, 1);
  MULTIPAGE_SetDefaultFont(GUI_FONT_20_ASCII);
  CHECKBOX_SetDefaultBkColor(GUI_LIGHTGRAY | 0x20E50000);

  CALENDAR_SetDefaultSize(CALENDAR_SI_HEADER, 40 );
  CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_X, 33 );
  CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_Y, 33 );

  MULTIPAGE_SetDefaultBkColor (GUI_WHITE, 1);

  SPINBOX_SetDefaultButtonSize(25);
  LISTVIEW_SetDefaultGridColor(GUI_WHITE);
  SCROLLBAR_SetDefaultWidth(16);

  HEADER_SetDefaultBkColor(0x00C5903E);
  HEADER_SetDefaultTextColor(GUI_WHITE);
  SCROLLBAR_SetDefaultColor(GUI_LIGHTGRAY | 0x20F50000, SCROLLBAR_CI_THUMB);
  SCROLLBAR_SetDefaultColor(GUI_LIGHTGRAY | 0x20F50000, SCROLLBAR_CI_SHAFT);
  SCROLLBAR_SetDefaultColor(GUI_LIGHTGRAY | 0x20F50000, SCROLLBAR_CI_ARROW);
  CHOOSEFILE_SetDelim('/');
  GUI_SetDefaultFont(GUI_FONT_13_ASCII);
}
Пример #3
0
/**
  * @brief  Initializes the menu.
  * @param  None.
  * @retval None.
  */
void k_InitMenu(void) 
{

  WM_HWIN  hItem;
  uint8_t i = 0;
  GUI_SetLayerVisEx (0, 0);
  GUI_DrawBitmap(&bmbackground, 0,0);     
  
  settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP);
  
  GUI_SetLayerVisEx (0, 1);
  GUI_SelectLayer(1);
  GUI_Clear();

  WM_SetCallback(WM_HBKWIN, _cbBk);
  
  WM_CreateWindowAsChild(0,
                         0,
                         LCD_GetXSize(),
                         25,
                         WM_HBKWIN, 
                         WM_CF_SHOW | WM_CF_HASTRANS , 
                         _cbStatus, 
                         0);
     
  hIcon = ICONVIEW_CreateEx(0, 
                            26, 
                            LCD_GetXSize(), 
                            LCD_GetYSize()- 26, 
                            WM_HBKWIN, 
                            WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND ,
                            ICONVIEW_CF_AUTOSCROLLBAR_V,
                            ID_ICONVIEW_MENU, 
                            112, 
                            105);
  
  ICONVIEW_SetFont(hIcon, &GUI_Font13B_ASCII);
  
  ICONVIEW_SetBkColor(hIcon, ICONVIEW_CI_SEL, GUI_LIGHTBLUE |GUI_TRANSPARENT);
  
  ICONVIEW_SetSpace(hIcon, GUI_COORD_Y, 10);
  
  ICONVIEW_SetFrame(hIcon, GUI_COORD_Y, 10);
    
  for (i = 0; i < k_ModuleGetNumber(); i++)
  {
    ICONVIEW_AddBitmapItem(hIcon,module_prop[i].module->icon, (char *)module_prop[i].module->name);
  }

  if(settings.b.enable_sprite)
  {
    _ShowSprites();
  }
  
  hItem = BUTTON_CreateEx(0, 0, 40, 23, WM_HBKWIN, WM_CF_SHOW, 0, ID_BUTTON_BKGND);
  WM_SetCallback(hItem, _cbButton);
}
/**
  * @brief  Initializes the menu.
  * @param  None.
  * @retval None
  */
void k_InitMenu(void) 
{

  WM_HWIN  hItem;
  uint8_t i = 0;
  
  
  settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP);

  WM_SetCallback(WM_HBKWIN, _cbBk);
  
  hStatusWin = WM_CreateWindowAsChild(0,
                         0,
                         LCD_GetXSize(),
                         25,
                         WM_HBKWIN, 
                         WM_CF_SHOW | WM_CF_LATE_CLIP , 
                         _cbStatus, 
                         0);
     
  hIcon = ICONVIEW_CreateEx(0, 
                            26, 
                            LCD_GetXSize(), 
                            LCD_GetYSize()- 26, 
                            WM_HBKWIN, 
                            WM_CF_SHOW | WM_CF_HASTRANS,
                            ICONVIEW_CF_AUTOSCROLLBAR_V,
                            ID_ICONVIEW_MENU, 
                            92, 
                            90);
  
    
  ICONVIEW_SetFont(hIcon, &GUI_Font13B_ASCII);
  

  
  ICONVIEW_SetTextColor(hIcon, ICONVIEW_CI_UNSEL, GUI_BLUE);
  ICONVIEW_SetTextColor(hIcon, ICONVIEW_CI_SEL, GUI_BLUE);
  
    ICONVIEW_SetBkColor(hIcon, ICONVIEW_CI_SEL, GUI_LIGHTBLUE |GUI_TRANSPARENT);
  
  ICONVIEW_SetSpace(hIcon, GUI_COORD_Y, 10);
  
  ICONVIEW_SetFrame(hIcon, GUI_COORD_Y, 10);
          
  for (i = 0; i < k_ModuleGetNumber(); i++)
  {  
    ICONVIEW_AddBitmapItem(hIcon,module_prop[i].module->icon, (char *)module_prop[i].module->name); 
  }

  hItem = BUTTON_CreateEx(0, 0, 40, 23, WM_GetDesktopWindowEx(0), WM_CF_SHOW, 0, ID_BUTTON_BKGND);
  WM_SetCallback(hItem, _cbButton);

}
Пример #5
0
/**
  * @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, hClient;
  int      NCode;
  int      Id, Index, newpos;
  GUI_RECT r;
  int  ItemNbr;
  int      result;  
  static char tmp[FILEMGR_FILE_NAME_SIZE];  
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:

    
    pVideoList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef));
    pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO));
    pVideoList->ptr = 0;
    
    
    PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_VIDEOPLAYER_SETTING_BKP);
    
    /* Initialization of 'Listview' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
    LISTVIEW_AddColumn(hItem, 165, "Video", GUI_TA_VCENTER | GUI_TA_LEFT);
    LISTVIEW_SetGridVis(hItem, 0);
    LISTVIEW_SetAutoScrollV(hItem, 1);
    LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_BLACK);
    LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_CYAN);

    hItem = BUTTON_CreateEx( 240,  202, 35,  35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON);
    WM_SetCallback(hItem, _cbButton_stop);    
    
    hItem = BUTTON_CreateEx(92, 202, 35,  35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON);
    WM_SetCallback(hItem, _cbButton_previous);     
    
    hItem = BUTTON_CreateEx(137, 195, 50,  45, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON);
    WM_SetCallback(hItem, _cbButton_play);
    
    hItem = BUTTON_CreateEx(195, 202, 35,  35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON);
    WM_SetCallback(hItem, _cbButton_next);
    
    hItem = BUTTON_CreateEx(47,  205, 30,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON);
    WM_SetCallback(hItem, _cbButton_repeat);
    
    hItem = BUTTON_CreateEx(315, 205, 70,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON);
    WM_SetCallback(hItem, _cbButton_open); 

    hItem = BUTTON_CreateEx(375, 205, 70,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON);
    WM_SetCallback(hItem, _cbButton_add);    
    
    hItem = BUTTON_CreateEx(440,  202, 30,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON);
    WM_SetCallback(hItem, _cbButton_close);    
    
    hItem = BUTTON_CreateEx(281,  172, 25,  25, pMsg->hWin, WM_CF_SHOW, 0, ID_FULL_SCREEN_BUTTON);
    WM_SetCallback(hItem, _cbButton_fullscreen);      
    
    hClient = WM_GetClientWindow(pMsg->hWin);
    WM_GetClientRectEx(hClient, &r);
    hFrame = WM_CreateWindowAsChild(r.x0 + 5, r.y0 + 5, r.x1 - 179, r.y1 - 75, hClient, WM_CF_SHOW, _cbVideoWindow , 0);
    hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);    
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGRESS_SLIDER);
    SLIDER_SetNumTicks(hItem, 25);
    
    hItem = WM_CreateWindowAsChild(05,
                                   163,
                                   275,
                                   20,
                                   pMsg->hWin, 
                                   WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND,
                                   _cbDrawProgressSlider, 
                                   0);
    
     WM_CreateWindowAsChild(479, 250, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); 
    break;
    

    
  case WM_PAINT:
    
    DrawRect3D(05, 193, 300, 50);
    DrawRect3D(310, 193, 165, 50); 
    
    break;    
    
    
    
  case WM_TIMER:
    Id = WM_GetTimerId(pMsg->Data.v);
    if (Id == ID_PLAYLIST_TIMER)
    {
      playlist_select = 0;
    }    
    break; 
    
  case WM_DELETE:       
    k_BkupSaveParameter(CALIBRATION_VIDEOPLAYER_SETTING_BKP, PlayerSettings.d32);    
    WM_DeleteTimer(hPlaylistTimer);
    break;

    
case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    
    switch(Id) {
      
      /* Notification sent by "Close Button" */  
    case ID_FULL_SCREEN_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_RELEASED:
        if( VideoPlayer_State != VIDEO_IDLE)
        {
          _ShowFullScreen();
        }
        break;
      }
      break;
      
    /* Notifications sent by 'Add' Button */
    case ID_ADD_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        pFileInfo->pfGetData = k_GetData;
        pFileInfo->pMask = acMask_video;     
        hItem = CHOOSEFILE_Create(pMsg->hWin,  47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add video file to playlist", 0, pFileInfo);        
        
        if(VideoPlayer_State == VIDEO_PLAY)
        {
          GUI_MOVIE_Pause(hMovie);
        } 
        WM_MakeModal(hItem);          
        result = GUI_ExecCreatedDialog(hItem);
        if (result == 0) 
        {     
          if((strstr(pFileInfo->pRoot, ".emf")) || (strstr(pFileInfo->pRoot, ".EMF")))
          {
            if(pVideoList->ptr < FILEMGR_LIST_DEPDTH)
            {
              strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot);
              FILEMGR_GetFileOnly ((char *)tmp, (char *)pFileInfo->pRoot);
              hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
              
              LISTVIEW_AddRow(hItem, NULL);         
              LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, tmp);
              pVideoList->ptr++;
            }
          }
          
          WM_InvalidateWindow(hFrame);          
        }   
        if(VideoPlayer_State == VIDEO_PLAY)
        {
          GUI_MOVIE_Play(hMovie);  
        } 
        break;   
      }
      break;       
      
    /* Notifications sent by 'Open' Button */
    case ID_OPEN_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        pFileInfo->pfGetData = k_GetData;
        pFileInfo->pMask = acMask_dir;     
        hItem = CHOOSEFILE_Create(pMsg->hWin,  47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add a folder", 0, pFileInfo);        
        if(VideoPlayer_State == VIDEO_PLAY)
        {
          GUI_MOVIE_Pause(hMovie);
        }
        WM_MakeModal(hItem);
        result = GUI_ExecCreatedDialog(hItem);
        if (result == 0) 
        {  
          _AddEntireFolder(pFileInfo->pRoot);
          
          WM_InvalidateWindow(hFrame);        
        }
        if(VideoPlayer_State == VIDEO_PLAY)
        {
          GUI_MOVIE_Play(hMovie);
        }
        break;
      }
      break;      
      
      /* Notification sent by "Full Screen button" */  
    case ID_CLOSE_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_RELEASED:
        k_free(pVideoList); 
        k_free(pFileInfo);   
        _StopPlay();
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break;      
      
      /* Notification sent by "Play Button" */  
    case ID_PLAY_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        if(VideoPlayer_State == VIDEO_IDLE)
        {
          if (pVideoList->ptr > 0)
          {
            _StartPlay((char *)pVideoList->file[file_pos].name);
            LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos);
          }
          else
          {
            pFileInfo->pfGetData = k_GetData;
            pFileInfo->pMask = acMask_video;     
            hItem = CHOOSEFILE_Create(pMsg->hWin,  47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Open a video file", 0, pFileInfo);
            WM_MakeModal(hItem);
            result = GUI_ExecCreatedDialog(hItem);
            if (result == 0) 
            {
              if((strstr(pFileInfo->pRoot, ".emf")) || (strstr(pFileInfo->pRoot, ".EMF")))
              {                   
                pVideoList->ptr = 0;
                
                strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot);
                FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot);
                hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
                
                /* Update Play list */
                strcpy((char *)pVideoList->file[pVideoList->ptr].name, pFileInfo->pRoot);
                
                ItemNbr = LISTVIEW_GetNumRows(hItem);
                while(ItemNbr--)
                {
                  LISTVIEW_DeleteRow(hItem, ItemNbr);
                }
                
                LISTVIEW_AddRow(hItem, NULL);         
                LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, tmp);
                pVideoList->ptr++;  
                file_pos = 0;
                LISTVIEW_SetSel(hItem, 0);
                _StartPlay((char *)pVideoList->file[file_pos].name);
                WM_InvalidateWindow(hFrame);
                
              }
            }
          }        
          
        }
        else if(VideoPlayer_State == VIDEO_PLAY)
        {
          _PausePlay();         
        }
        else if(VideoPlayer_State == VIDEO_PAUSE)
        {
          _ResumePlay();  
        }        
        break;
      }
      break;

    case ID_REPEAT_BUTTON:      
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_BUTTON);   
        
        if(PlayerSettings.b.repeat == REPEAT_NONE)
        {
          PlayerSettings.b.repeat = REPEAT_ONCE;
        }
        else if(PlayerSettings.b.repeat == REPEAT_ONCE)
        {
          PlayerSettings.b.repeat = REPEAT_ALL;
        }
        else if(PlayerSettings.b.repeat == REPEAT_ALL)
        {
          PlayerSettings.b.repeat = REPEAT_NONE;
        }
      }
      break;
      
    case ID_STOP_BUTTON:
      _StopPlay();  
      hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PROGRESS_SLIDER);
      SLIDER_SetValue(hItem, 0);
      WM_InvalidateWindow(hFrame);
      break;
      
    case ID_NEXT_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        if(file_pos < (pVideoList->ptr - 1))
        {
          /* Play Next */
          file_pos++;
          LISTVIEW_IncSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST)); 
        }
        else if(PlayerSettings.b.repeat == REPEAT_ALL)
        {
          file_pos = 0; 
          LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos);
        }           

        if(VideoPlayer_State == VIDEO_PLAY)
        {
          _StopPlay();
          _StartPlay((char *)pVideoList->file[file_pos].name);
          WM_InvalidateWindow(hFrame);
        }
        break;
      }
      break;
      
      
    case ID_PREVIOUS_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        if( pVideoList->ptr > 0)
        {
          if(file_pos > 0)
          {   
            file_pos--;
            LISTVIEW_DecSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST));             
          }
          else if(PlayerSettings.b.repeat == REPEAT_ALL)
          {
            file_pos = (pVideoList->ptr - 1); 
            LISTVIEW_SetSel(WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST), file_pos);
          } 
          if(VideoPlayer_State == VIDEO_PLAY)
          {
            _StopPlay();
            _StartPlay((char *)pVideoList->file[file_pos].name);
            WM_InvalidateWindow(hFrame);
          }
        }    
        break;
        
      }
      break;
      
    /* Notifications sent by 'progress' Slider */
    case ID_PROGRESS_SLIDER: 
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        if(VideoPlayer_State != VIDEO_IDLE)
        {
          GUI_MOVIE_Pause(hMovie);
          hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGRESS_SLIDER);
          newpos = (SLIDER_GetValue(hItem) * Video_Info.NumFrames)/100;
          GUI_MOVIE_GotoFrame(hMovie, newpos);
          if(VideoPlayer_State == VIDEO_PLAY)
          {
            GUI_MOVIE_Play(hMovie);
          }
        }
      }
      break;
      
    /* Notifications sent by 'ListView' Slider */
    case ID_VIDEO_LIST: 
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
        Index = LISTVIEW_GetSel(hItem);
        
        if(Index < pVideoList->ptr)
        {
          file_pos = Index;
          
          if(playlist_select == 0)
          {
            hPlaylistTimer = WM_CreateTimer(pMsg->hWin, ID_PLAYLIST_TIMER, 500, 0);           
            playlist_select = (Index + 1);
          }
          
          else if(playlist_select == (Index + 1))
          {
            WM_DeleteTimer(hPlaylistTimer); 
            hPlaylistTimer = 0;          
            playlist_select = 0;
            
            if(Index < pVideoList->ptr)
            {
              if(VideoPlayer_State != VIDEO_IDLE)
              {
                _StopPlay();
              } 
              
              _StartPlay((char *)pVideoList->file[Index].name); 
              hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_PLAY_BUTTON);
              WM_InvalidateWindow(hItem);
              WM_Update(hItem); 
              WM_InvalidateWindow(hFrame);
            }
          }
        }
      }
      break;   
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Пример #6
0
/**
  * @brief  GUI task
  * @param  argument: pointer that is passed to the thread function as start argument.
  * @retval None
  */
void GUIThread(void const * argument)
{
	static uint32_t WinNumberICO;

	TesterStatus.mode = 0;
	TesterStatus.error = 0;
	
	// wait for others task init
  wt_StartUp();	
	
	// self check
	osMessagePut(WireSelfCheckEvent, WIRESELFCHECK_START_EVENT, 0);//开始自检
	
	/* Add Modules*/
  k_ModuleInit();
	k_ModuleAdd(&wt_test);
	k_ModuleAdd(&wt_study);
	k_ModuleAdd(&wt_find);
	k_ModuleAdd(&wt_edit);
	k_ModuleAdd(&wt_self);
	k_ModuleAdd(&wt_setting);
	k_ModuleAdd(&wt_info);
	k_ModuleAdd(&wt_print);

	/* Set General Graphical proprieties */
  wt_SetGuiProfile();
    
//  if(k_CalibrationIsDone() == 0)
//  {
//    GUI_SelectLayer(1);
//    k_CalibrationInit();
//    GUI_SelectLayer(0);
//  }
	settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP);
  
	Number_Windos = 0;	//当前显示窗口编号
	WinNumberICO = 1;
	
	// Init Back Ground & Patch the bug of Listview Grid
	wt_InitBackGround();
	LISTVIEW_SetDefaultGridColor(GUI_GRAY);
  
  /* Gui background Task */
  while(1)
  {
		// show the windows
    switch(Number_Windos)
		{
			case 0:
				TesterStatus.mode = 0;
				WT_Windows_Menu(&WinNumberICO);
				break;
			
			case 1:
				// update Tester_Status
				switch (WinNumberICO)
				{
					//0:待机状态;1:正常运行测试程序;2:正在运行自学习程序;
					//3:正在运行找点程序;4:正在运行自检程序;5:正在运行调试程序;
					case 0:
						TesterStatus.mode = 1;
						break;
					case 1:
						TesterStatus.mode = 2;
						break;
					case 2:
						TesterStatus.mode = 3;
						break;
					case 4:
						TesterStatus.mode = 4;
						break;
					case 7:
						TesterStatus.mode = 5;
						break;
					default:
						TesterStatus.mode = 0;
						break;
				}
				module_prop[WinNumberICO].module->startup(WM_HBKWIN, 0, 25);
				
				break;
			
			default:
				Number_Windos = 0;	//显示menu
				break;	
		}
		// system delay
		GUI_Exec();
		osDelay(30); 
	}
}
/**
  * @brief  Callback routine of the dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg)
{
  WM_HWIN  hItem;
  GUI_RECT r;
  int      result;
  int      Id, NCode, Index;
  char tmp[FILEMGR_FILE_NAME_SIZE];

  switch (pMsg->MsgId)
  {
  case WM_INIT_DIALOG:


    pImageList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef));
    pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO));

    pImageList->ptr = 0;
    file_pos = 0;
    effects = 0;

    ImSettings.d32 = k_BkupRestoreParameter(CALIBRATION_IMAGE_SETTINGS_BKP);
    if(ImSettings.b.ss_timer == 0)
    {
      ImSettings.b.ss_timer = 1;
    }


    /* Image frame initialization */
    IMAGE_Enlarge = 0;
    hItem = WM_GetClientWindow(pMsg->hWin);
    WM_GetClientRectEx(hItem, &r);
    imFrame = WM_CreateWindowAsChild(r.x0 + 6, r.y0 + 6, r.x1 - 98, r.y1 - 78, hItem, WM_CF_SHOW, _cbImageWindow, 0);

    /* Buttons initialization */

    hItem = BUTTON_CreateEx(47, 155, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON);
    WM_SetCallback(hItem, _cbButton_previous);

    hItem = BUTTON_CreateEx(94, 148, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDE_BUTTON);
    WM_SetCallback(hItem, _cbButton_play);
    slideshow_state = OFF;

    hItem = BUTTON_CreateEx(154, 155, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON);
    WM_SetCallback(hItem, _cbButton_next);


    hItem = BUTTON_CreateEx(242, 145, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON);
    WM_SetCallback(hItem, _cbButton_add);

    hItem = BUTTON_CreateEx(242, 175, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON);
    WM_SetCallback(hItem, _cbButton_open);

    hItem = BUTTON_CreateEx(196, 174, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_SETTINGS_BUTTON);
    WM_SetCallback(hItem, _cbButton_settings);

    hItem = BUTTON_CreateEx(10, 174, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON);
    WM_SetCallback(hItem, _cbButton_close);

    hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST);
    LISTBOX_SetBkColor(hItem, LISTBOX_CI_SEL, GUI_BLUE);
    LISTBOX_SetTextColor(hItem, LISTBOX_CI_SEL, GUI_WHITE);
    LISTBOX_SetBkColor(hItem, LISTBOX_CI_UNSEL, GUI_BLACK);
    LISTBOX_SetTextColor(hItem, LISTBOX_CI_UNSEL, GUI_CYAN);
    LISTBOX_SetAutoScrollV(hItem, 1);

    break;

  case WM_TIMER:
    playlist_select = 0;
    break;

 case WM_PAINT:
    DrawRect3D(5, 140, 222, 67);
    DrawRect3D(230, 140, 83, 67);

    break;
  case WM_NOTIFY_PARENT:
    Id = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;

    switch (Id) {
    /* Notification sent by "Button_Settings" */
    case ID_SETTINGS_BUTTON:
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
        GUI_CreateDialogBox(_aSettingsDialogCreate, GUI_COUNTOF(_aSettingsDialogCreate), _cbSettingsDialog, IMAGE_hWin, 0, 0);
        break;
      }
      break;

     /* Notifications sent by 'ListView' Slider */
    case ID_IMAGE_LIST:
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST);
        Index = LISTBOX_GetSel(hItem);

        if(Index < pImageList->ptr)
        {
          if(playlist_select == 0)
          {
            hPlaylistTimer = WM_CreateTimer(pMsg->hWin, ID_PLAYLIST_TIMER, 500, 0);
            playlist_select = (Index + 1);
          }

          else if(playlist_select == (Index + 1))
          {
            WM_DeleteTimer(hPlaylistTimer);
            hPlaylistTimer = 0;
            playlist_select = 0;

            if(Index < pImageList->ptr)
            {
              file_pos = Index;
              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);
            }
          }
        }
      }
      break;

    /* Notification sent by "Button_Close" */
    case ID_CLOSE_BUTTON:
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
        f_close(&Image_File);
        k_free(pImageList);
        k_free(pFileInfo);
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break;

    /* Notification sent by "Button_Open" */
    case ID_OPEN_BUTTON:
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:

        pFileInfo->pfGetData = k_GetData;
        pFileInfo->pMask = acMask_dir;
        hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "add a folder", 0, pFileInfo);
        WM_MakeModal(hItem);
        result = GUI_ExecCreatedDialog(hItem);
        if (result == 0)
        {

          if(pImageList->ptr == 0)
          {
            _AddEntireFolder(pFileInfo->pRoot);
            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_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
            WM_InvalidateWindow(imFrame);
          }
          else
          {
            _AddEntireFolder(pFileInfo->pRoot);
          }
        }

        break;
      }
      break;

      /* Notification sent by "Button_Open" */
    case ID_ADD_BUTTON:
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:

        pFileInfo->pfGetData = k_GetData;
        pFileInfo->pMask = acMask_img;
        hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "Add an image to playlist", 0, pFileInfo);
        WM_MakeModal(hItem);
        result = GUI_ExecCreatedDialog(hItem);
        if (result == 0)
        {

          if((strstr(pFileInfo->pRoot, ".jpg")) || (strstr(pFileInfo->pRoot, ".bmp")) || (strstr(pFileInfo->pRoot, ".JPG")) || (strstr(pFileInfo->pRoot, ".BMP")))
          {
            strcpy((char *)pImageList->file[pImageList->ptr].name, pFileInfo->pRoot);
            FILEMGR_GetFileOnly(tmp, (char *)pFileInfo->pRoot);
            hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
            LISTBOX_AddString(hItem, tmp);
            LISTBOX_SetSel(hItem, pImageList->ptr);
            pImageList->ptr++;
            file_pos = pImageList->ptr - 1;
            f_close(&Image_File);

            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_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
            WM_InvalidateWindow(imFrame);
          }
        }
        break;
      }
      break;

    /* Notification sent by "Button_SlideShow" */
    case ID_SLIDE_BUTTON:
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
        if(pImageList->ptr > 1)
        {
          f_close(&Image_File);
          f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);

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

          WM_InvalidateWindow(imFrame);
          if (slideshow_state == OFF)
          {
            hTimerTime = WM_CreateTimer(imFrame, ID_SLIDER_TIMER, (ImSettings.b.ss_timer * 1000) , 0);
          }
          else if(hTimerTime != 0)
          {
            WM_DeleteTimer(hTimerTime);
            hTimerTime = 0;
          }

          slideshow_state = (slideshow_state == OFF ? ON : OFF);
        }
        break;
      }
      break;

    /* Notification sent by "Button_Next" */
    case ID_NEXT_BUTTON:
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:

        if(pImageList->ptr > 0)
        {
          if (file_pos < (pImageList->ptr - 1))
          {
            file_pos++;
            f_close(&Image_File);
          }
          else
          {
            file_pos = 0;
            f_close(&Image_File);
          }

          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_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);

        }

        break;
      }
      break;

    /* Notification sent by "Button_Previous" */
    case ID_PREVIOUS_BUTTON:
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:

        if(pImageList->ptr > 0)
        {
          if (file_pos > 0 )
          {
            file_pos--;
            f_close(&Image_File);
          }
          else
          {
            file_pos = (pImageList->ptr - 1);
            f_close(&Image_File);
          }

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

        break;
      }
      break;
    }
    break;
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
/**
  * @brief  Callback function of the settings frame
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbSettingsDialog(WM_MESSAGE * pMsg)
{
  int     Id, NCode;
  WM_HWIN hItem;
  uint32_t tmp_param = 0;


  switch (pMsg->MsgId)
  {
  case WM_INIT_DIALOG:

    WM_MakeModal(pMsg->hWin);
    /* Settings frame initialization */
    hItem = pMsg->hWin;
    FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0);

    /* Create and attache the MULTIPAGE dialog windows */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE);

    /* 'OK' button initialization */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK);
    BUTTON_SetFont(hItem, GUI_FONT_13B_1);

    /* 'Cancel' button initialization */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
    BUTTON_SetFont(hItem, GUI_FONT_13B_1);

    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetFont(hItem, GUI_FONT_13B_1);

    hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0);

    SPINBOX_SetRange(hItem, 1, 10);

    if(ImSettings.b.ss_timer > 0)
    {
       SPINBOX_SetValue(hItem, ImSettings.b.ss_timer);
    }
    else
    {
      ImSettings.b.ss_timer = 1;
      SPINBOX_SetValue(hItem, 1);
    }

    break;

  case WM_NOTIFY_PARENT:
    Id = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;

    switch (Id)
    {
    /* Notification sent by "OK" button */
    case ID_BUTTON_OK:
      switch (NCode) {

      case WM_NOTIFICATION_RELEASED:

        /* Save image settings before delete settings frame */
        hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0);
        ImSettings.b.ss_timer = SPINBOX_GetValue(hItem);

        WM_RestartTimer(hTimerTime, (ImSettings.b.ss_timer * 1000));

        tmp_param = k_BkupRestoreParameter(CALIBRATION_IMAGE_SETTINGS_BKP);

        /* check if new settings have to be saved */
        if(ImSettings.d32 != tmp_param)
        {
          k_BkupSaveParameter(CALIBRATION_IMAGE_SETTINGS_BKP, ImSettings.d32);
        }

        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break;
    /* Notification sent by "Cancel" button */
    case ID_BUTTON_CANCEL:
      switch (NCode) {
      case WM_NOTIFICATION_RELEASED:
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break;
    }
    break;

  }
}
Пример #9
0
/**
  * @brief  Callback routine of the dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id, ItemNbr;
  int      result;  
  int duration, volume, index;
  static char tmp[FILEMGR_FILE_NAME_SIZE];  
  
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
      
    pWavList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef));
    pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO));
    pWavList->ptr = 0;
      
    /* Initialization of 'Listview' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
    LISTVIEW_AddColumn(hItem, 132, "Track", GUI_TA_VCENTER | GUI_TA_LEFT);
    LISTVIEW_AddColumn(hItem, 55, "Duration", GUI_TA_VCENTER | GUI_TA_RIGHT);
    LISTVIEW_SetGridVis(hItem, 0);
    LISTVIEW_SetAutoScrollV(hItem, 1);
    LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_BLACK);
    LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_CYAN);
    
    /* Title Initialization in play list */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE_CAPTION);
    TEXT_SetText(hItem, "TITLE:");
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Title Initialization in play list */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE);
    TEXT_SetTextColor(hItem, GUI_CYAN);    
    
    /* Duration */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
    TEXT_SetText(hItem, "00:00");
    TEXT_SetFont(hItem, GUI_FONT_20B_1);
    TEXT_SetTextColor(hItem, GUI_LIGHTGRAY);
    
    /* Author initialization */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR_CAPTION);
    TEXT_SetText(hItem, "AUTHOR:");
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Author */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR);
    TEXT_SetText(hItem, "");
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Sampling Rate */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_CAPTION);
    TEXT_SetText(hItem, "SAMPLING:");
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Sampling Rate Value */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_VALUE);
    TEXT_SetText(hItem, "");
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Duration */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TOTAL_TIME);
    TEXT_SetText(hItem, "00:00");
    TEXT_SetTextColor(hItem, GUI_CYAN);
    
    /* Initialization of 'WAV' Button */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_WAV_BUTTON);
    BUTTON_SetFont(hItem, GUI_FONT_24_1);
    
    /* Initialization of 'Play List' Button */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_LIST_BUTTON);
    BUTTON_SetFont(hItem, GUI_FONT_24_1);
    
    /* Initialization of 'Add' Button */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_ADD_BUTTON);
    BUTTON_SetFont(hItem, GUI_FONT_24_1);
    
    volume = AUDIOPLAYER_GetVolume();
    hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER);
    SLIDER_SetValue(hItem, volume);
    
    hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER);
    SLIDER_SetNumTicks(hItem, 25);
    
    PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP);
    PlayerSettings.b.mute = MUTE_OFF;  
    PlayerSettings.b.pause = PLAY_ACTIVE;  
      
    hItem = BUTTON_CreateEx(25,  100, 30,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON);
    WM_SetCallback(hItem, _cbButton_repeat);
    
    hItem = BUTTON_CreateEx(100,  95, 40,  40, pMsg->hWin, WM_CF_SHOW, 0, ID_MUTE_BUTTON);
    WM_SetCallback(hItem, _cbButton_speaker);    
    
    hItem = BUTTON_CreateEx(22,  147, 35,  35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON);
    WM_SetCallback(hItem, _cbButton_stop);    
       
    hItem = BUTTON_CreateEx(89, 147, 35,  35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON);
    WM_SetCallback(hItem, _cbButton_previous);   
    
    hItem = BUTTON_CreateEx(148, 140, 50,  50, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON);
    WM_SetCallback(hItem, _cbButton_play);
    
    hItem = BUTTON_CreateEx(222, 147, 35,  35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON);
    WM_SetCallback(hItem, _cbButton_next);
    
    hItem = WM_GetClientWindow(pMsg->hWin);
    hItem = BUTTON_CreateEx(20, 205, 50,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_WAV_BUTTON);
    WM_SetCallback(hItem, _cbButton_open); 
    
    hItem = BUTTON_CreateEx(80, 205, 50,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON);
    WM_SetCallback(hItem, _cbButton_add);      
       
    hItem = BUTTON_CreateEx(235,  205, 30,  30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON);
    WM_SetCallback(hItem, _cbButton_close);
    
    hTimerWin = WM_CreateWindowAsChild(0,
                           100,
                           10,
                           10,
                           pMsg->hWin, 
                           WM_CF_SHOW | WM_CF_HASTRANS,
                           _cbAudioProcess, 
                           0);
    
    hItem = WM_CreateWindowAsChild(15,
                                   75,
                                   255,
                                   20,
                                   pMsg->hWin, 
                                   WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND,
                                   _cbDrawProgressSlider, 
                                   0);
    
    hItem = WM_CreateWindowAsChild(145,
                                   
                                   105,
                                   125,
                                   20,
                                   pMsg->hWin, 
                                   WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND,
                                   _cbDrawVolumeSlider, 
                                   0);    
    
    WM_CreateWindowAsChild(479, 250, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0); 
    
    break;
    
  case WM_PAINT:
    
    GUI_SetBkColor(GUI_BLACK);
    GUI_ClearRect(15, 6, 270, 70); 
    DrawRect3D(15, 135, 255, 60);
    DrawRect3D(15, 200, 255, 40);
    break;
    
  case WM_DELETE:
    AUDIOPLAYER_DeInit();
    
    k_free(pWavList);
    k_free(pFileInfo);
    
    pWavList->ptr = 0;
    PlayerSettings.b.mute = MUTE_OFF;       
    PlayerSettings.b.pause = PLAY_ACTIVE;        
    k_BkupSaveParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP, PlayerSettings.d32);
    break;
    
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;

    switch(Id) {
      
    /* Notification sent by "Button_Close" */  
    case ID_CLOSE_BUTTON: 
      switch (NCode) {
      case WM_NOTIFICATION_CLICKED:
        break;
      case WM_NOTIFICATION_RELEASED:
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
      break;
      
    /* Notifications sent by 'Repeat' Button */
    case ID_REPEAT_BUTTON:
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_BUTTON);   
        
        if(PlayerSettings.b.repeat == REPEAT_NONE)
        {
          PlayerSettings.b.repeat = REPEAT_ONCE;
        }
        else if(PlayerSettings.b.repeat == REPEAT_ONCE)
        {
          PlayerSettings.b.repeat = REPEAT_ALL;
        }
        else if(PlayerSettings.b.repeat == REPEAT_ALL)
        {
          PlayerSettings.b.repeat = REPEAT_NONE;
        }
      }
      break;
      
    /* Notifications sent by 'Mute' Button */
    case ID_MUTE_BUTTON: 
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_MUTE_BUTTON);         
        if(PlayerSettings.b.mute == MUTE_OFF)
        {          
          AUDIOPLAYER_Mute(MUTE_ON);
          PlayerSettings.b.mute = MUTE_ON;
        }
        else
        {         
          AUDIOPLAYER_Mute(MUTE_OFF);
          PlayerSettings.b.mute = MUTE_OFF;
        }
      }
      break;
      
      
    /* Notifications sent by 'Volume' Slider */
    case ID_VOLUME_SLIDER: 
      if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER);
        AUDIOPLAYER_SetVolume(SLIDER_GetValue(hItem));
        if(PlayerSettings.b.mute == MUTE_ON)
        {          
          AUDIOPLAYER_Mute(MUTE_OFF);
          PlayerSettings.b.mute = MUTE_OFF;
        }
      }
      break;
      
      
    /* Notifications sent by 'progress' Slider */
    case ID_DURATION_SLIDER: 
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER);
        AUDIOPLAYER_SetPosition(SLIDER_GetValue(hItem));
        
        if(PlayerSettings.b.mute == MUTE_ON)
        {
          AUDIOPLAYER_Mute(MUTE_ON);
        }
      }
      break;
      
      
    /* Notifications sent by 'ListView' Slider */
    case ID_WAVFILE_LIST: 
      if(NCode == WM_NOTIFICATION_CLICKED)
      {
        hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
        index = LISTVIEW_GetSel(hItem);
        
        if(index < pWavList->ptr)
        {
          if(playlist_select == 0)
          {
            hPlaylistTimer = WM_CreateTimer(hTimerWin, ID_PLAYLIST_TIMER, 500, 0);           
            playlist_select = (index + 1);
          }
          
          else if(playlist_select == (index + 1))
          {
            WM_DeleteTimer(hPlaylistTimer); 
            hPlaylistTimer = 0;          
            playlist_select = 0;
            
            if(index < pWavList->ptr)
            {
                
              if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
              {             
                AUDIOPLAYER_Stop();
              }
              
              PlayerSettings.b.pause = PLAY_ACTIVE;
              hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
              WM_InvalidateWindow(hItem);
              WM_Update(hItem);
              
              file_pos = index;
              _PlayFile((char *)pWavList->file[index].name); 
            }
          }
        }
      }
      break;
      
    /* Notifications sent by 'Play' Button */
    case ID_PLAY_BUTTON: 
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        
        if(AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP)
        {
          if(pWavList->ptr > 0)
          {
            _PlayFile((char *)pWavList->file[file_pos].name);
            LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos);
          }
          else
          {
            pFileInfo->pfGetData = k_GetData;
            pFileInfo->pMask = acMask_audio;     
            hItem = CHOOSEFILE_Create(pMsg->hWin,  47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Open an audio file", 0, pFileInfo); 
            WM_MakeModal(hItem);
            result = GUI_ExecCreatedDialog(hItem);
            if (result == 0) 
            { 
              if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV")))
              {         
                if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0)
                {
                  if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
                  {
                    /* Stop current audio sample */
                    AUDIOPLAYER_Stop();   
                  }
                  
                  pWavList->ptr = 0;
                  file_pos = 0;
                  
                  strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot);
                  FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot);
                  hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
                  
                  /* Update Play list */
                  strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot);
                  
                  ItemNbr = LISTVIEW_GetNumRows(hItem);
                  while(ItemNbr--)
                  {
                    LISTVIEW_DeleteRow(hItem, ItemNbr);
                  }
                  
                  LISTVIEW_AddRow(hItem, NULL);         
                  LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp);
                  duration = WavInfo.FileSize / WavInfo.ByteRate; 
                  sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 );
                  LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp);
                  pWavList->ptr++;  
                  
                  LISTVIEW_SetSel(hItem, 0);
                  _PlayFile(pFileInfo->pRoot);              
                }
              }
            }
          }
        }
        else if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
        {
          PlayerSettings.b.pause = (PlayerSettings.b.pause == PLAY_ACTIVE ? PAUSE_ACTIVE : PLAY_ACTIVE);
          
          if(PlayerSettings.b.pause == PAUSE_ACTIVE)
          {            
            AUDIOPLAYER_Pause();
          }
          else if(PlayerSettings.b.pause == PLAY_ACTIVE)
          {            
            AUDIOPLAYER_Resume();
          }
        }
      }
      break;
      
      
    /* Notifications sent by 'STOP' Button */
    case ID_STOP_BUTTON: 
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
        {
          if(PlayerSettings.b.pause == PAUSE_ACTIVE)
          {  
            PlayerSettings.b.pause = PLAY_ACTIVE;
          } 
          AUDIOPLAYER_Stop();
          hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
          TEXT_SetText(hItem, "00:00");            
          
          hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
          WM_InvalidateWindow(hItem);
          WM_Update(hItem);          
        }
      }
      break;
      
      
    /* Notifications sent by 'Next' Button */
    case ID_NEXT_BUTTON: 
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        if( pWavList->ptr > 0)
        {        
          if(file_pos < (pWavList->ptr - 1))
          {
            file_pos++; 
          }
          else if(PlayerSettings.b.repeat == REPEAT_ALL)
          {
            file_pos = 0; 
          }
          LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos); 
          
          if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
          {    
            if(PlayerSettings.b.pause == PAUSE_ACTIVE)
            {  
              PlayerSettings.b.pause = PLAY_ACTIVE;
              hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
              WM_InvalidateWindow(hItem);
              WM_Update(hItem);
            }
            
            AUDIOPLAYER_Stop();
            _PlayFile((char *)pWavList->file[file_pos].name); 
          }
        }
      }
      break;
      
      /* Notifications sent by 'Previous' Button */
    case ID_PREVIOUS_BUTTON: 
      if(NCode == WM_NOTIFICATION_RELEASED)
      {
        if( pWavList->ptr > 0)
        {
          if(file_pos > 0)
          {   
            file_pos--;           
          }
          else if(PlayerSettings.b.repeat == REPEAT_ALL)
          {
            file_pos = (pWavList->ptr - 1); 
          }          
          LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos);          
          
          if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
          {  
            if(PlayerSettings.b.pause == PAUSE_ACTIVE)
            {  
              PlayerSettings.b.pause = PLAY_ACTIVE;
              hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
              WM_InvalidateWindow(hItem);
              WM_Update(hItem);
            }
            
            AUDIOPLAYER_Stop();
            _PlayFile((char *)pWavList->file[file_pos].name);              
          }
        }
      }
      break;    
      
    /* Notifications sent by 'Open' Button */
    case ID_WAV_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        
        break;
      case WM_NOTIFICATION_RELEASED:
        
        pFileInfo->pfGetData = k_GetData;
        pFileInfo->pMask = acMask_dir;     
        hItem = CHOOSEFILE_Create(pMsg->hWin,  47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add a folder", 0, pFileInfo);        
        WM_MakeModal(hItem);
        result = GUI_ExecCreatedDialog(hItem);
        if (result == 0) 
        { 
          _AddEntireFolder(pFileInfo->pRoot);
        }
        break;
      }
      break;
            
    /* Notifications sent by 'Add' Button */
    case ID_ADD_BUTTON: 
      switch(NCode) {
      case WM_NOTIFICATION_RELEASED:
        
        pFileInfo->pfGetData = k_GetData;
        pFileInfo->pMask = acMask_audio;     
        hItem = CHOOSEFILE_Create(pMsg->hWin,  47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add to playlist", 0, pFileInfo);
        WM_MakeModal(hItem);
        result = GUI_ExecCreatedDialog(hItem);
        if (result == 0) 
        { 
          if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV")))
          {
            if(pWavList->ptr < FILEMGR_LIST_DEPDTH)
            {
              strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot);
              FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot);
              hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
              
              if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0)
              {
                LISTVIEW_AddRow(hItem, NULL);         
                LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp);
                duration = WavInfo.FileSize / WavInfo.ByteRate; 
                sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 );
                LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp);
                pWavList->ptr++;      
              }
            }
          }
        }  
      }
      break;      
    }
    break;
    
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
Пример #10
0
/**
  * @brief  Main program
  * @param  None
  * @retval int
  */
int main(void)
{
  RCC_ClkInitTypeDef RCC_ClkInitStruct;
  RCC_OscInitTypeDef RCC_OscInitStruct;
  uint32_t FLatency;
  SystemSettingsTypeDef setting;    
  osTimerId lcd_timer;  
  
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
  */
  HAL_Init();
 
  /* Configure the system clock to 168 MHz */
  SystemClock_Config();
  
  /* Initialize Joystick, Touch screen and LEDs */
  k_BspInit();
  k_LogInit(); 
  
  /* Initialize memory pools */
  k_MemInit();  
  
  /* Initialize audio Interface */
  k_BspAudioInit();  
  
  /* Initialize RTC */
  k_CalendarBkupInit();  

  /* Add Modules */
  k_ModuleInit();  
  
  /* Create GUI task */
  osThreadDef(GUI_Thread, GUIThread, osPriorityHigh, 0, 2048);
  osThreadCreate (osThread(GUI_Thread), NULL); 
  
  k_ModuleAdd(&video_player);
  k_ModuleOpenLink(&video_player, "emf");
  k_ModuleOpenLink(&video_player, "EMF");
  k_ModuleAdd(&image_browser);  
  k_ModuleOpenLink(&image_browser, "jpg"); 
  k_ModuleOpenLink(&image_browser, "JPG");
  k_ModuleOpenLink(&image_browser, "bmp"); 
  k_ModuleOpenLink(&image_browser, "BMP");
  k_ModuleAdd(&audio_player);  
  k_ModuleOpenLink(&audio_player, "wav"); 
  k_ModuleOpenLink(&audio_player, "WAV"); 
  k_ModuleAdd(&camera_capture);    
  k_ModuleAdd(&system_info);
  k_ModuleAdd(&file_browser);  
  k_ModuleAdd(&cpu_bench);  
  k_ModuleAdd(&game_board);  
  k_ModuleAdd(&usb_device);   
  
  /* Initialize GUI */
  GUI_Init();
  WM_MULTIBUF_Enable(1);  
  
  /* Set General Graphical proprieties */
  k_SetGuiProfile();  

  /* Get General settings */
  setting.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP);
    
  if(setting.b.use_180Mhz)
  {
    HAL_RCC_GetClockConfig(&RCC_ClkInitStruct, &FLatency);
    /* Select HSE as system clock source */
    RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK);
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
    HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);

    HAL_RCC_GetOscConfig(&RCC_OscInitStruct);  
    RCC_OscInitStruct.PLL.PLLM = 25;
    RCC_OscInitStruct.PLL.PLLN = 360;
    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
    RCC_OscInitStruct.PLL.PLLQ = 7;
    HAL_RCC_OscConfig(&RCC_OscInitStruct);
    
    HAL_PWREx_EnableOverDrive();
    
    /* Select PLL as system clock source */
    RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK);
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
    HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
  }  
  
  /* Create Touch screen Timer */
  osTimerDef(TS_Timer, TimerCallback);
  lcd_timer =  osTimerCreate(osTimer(TS_Timer), osTimerPeriodic, (void *)0);

  /* Start the TS Timer */
  osTimerStart(lcd_timer, 55);

  GUI_X_InitOS();  
  
  /* Start scheduler */
  osKernelStart();
    
  /* We should never get here as control is now taken by the scheduler */
  for( ;; );
}
Пример #11
0
/**
  * @brief  Initializes audio
  * @param  None.
  * @retval Audio state.
  */
AUDIOPLAYER_ErrorTypdef  AUDIOPLAYER_Init(uint8_t volume)
{
#if (!defined ( __GNUC__ ))  
  uint32_t index = 0;
  __IO uint32_t ldness_value;
#endif
  
   /* Try to Init Audio interface in diffrent config in case of failure */
  BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_AUTO, volume, I2S_AUDIOFREQ_48K);
  BSP_AUDIO_OUT_SetAudioFrameSlot(CODEC_AUDIOFRAME_SLOT_02);
  
  /* Initialize internal audio structure */
  haudio.out.state  = AUDIOPLAYER_STOP;
  haudio.out.mute   = MUTE_OFF;
  haudio.out.volume = volume;  
  
  
#if (!defined ( __GNUC__ ))  
  /* Enable the Eq */
  SpiritEQ_Init((TSpiritEq *)AUDIO_EqInstance, I2S_AUDIOFREQ_48K);
  
  
  /* Retreive stored settings and set band params */
  SpiritEQ_FltGet((TSpiritEq *)AUDIO_EqInstance, &AUDIO_EQ_Bands[0], 0 );
  AUDIO_EQ_Bands[0].gainDb = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_EQU1_BKP);
  SET_BAND_PRMS(&AUDIO_EQ_Bands[0], SPIRIT_EQ_FLT_TYPE_SHELVING_LOWPASS , 0, 1000, AUDIO_EQ_Bands[0].gainDb);
  
  SpiritEQ_FltGet((TSpiritEq *)AUDIO_EqInstance, &AUDIO_EQ_Bands[1], 1 );
  AUDIO_EQ_Bands[1].gainDb = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_EQU2_BKP);    
  SET_BAND_PRMS(&AUDIO_EQ_Bands[1], SPIRIT_EQ_FLT_TYPE_PEAKING , 2000, 1000, AUDIO_EQ_Bands[1].gainDb);
  
  SpiritEQ_FltGet((TSpiritEq *)AUDIO_EqInstance, &AUDIO_EQ_Bands[2], 2 );
  AUDIO_EQ_Bands[2].gainDb = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_EQU3_BKP);   
  SET_BAND_PRMS(&AUDIO_EQ_Bands[2], SPIRIT_EQ_FLT_TYPE_PEAKING , 5000, 3000, AUDIO_EQ_Bands[2].gainDb);
  
  SpiritEQ_FltGet((TSpiritEq *)AUDIO_EqInstance, &AUDIO_EQ_Bands[3], 3 );
  AUDIO_EQ_Bands[3].gainDb = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_EQU4_BKP);;  
  SET_BAND_PRMS(&AUDIO_EQ_Bands[3], SPIRIT_EQ_FLT_TYPE_PEAKING , 10000, 6000, AUDIO_EQ_Bands[3].gainDb);
  
  SpiritEQ_FltGet((TSpiritEq *)AUDIO_EqInstance, &AUDIO_EQ_Bands[4], 4 );
  AUDIO_EQ_Bands[4].gainDb = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_EQU5_BKP);  
  SET_BAND_PRMS(&AUDIO_EQ_Bands[4], SPIRIT_EQ_FLT_TYPE_SHELVING_HIPASS , 15000, 2000, AUDIO_EQ_Bands[4].gainDb);

  for (index = 0; index < SPIRIT_EQ_MAX_BANDS ; index++)
  {
    tmpEqBand = &AUDIO_EQ_Bands[index];
    SpiritEQ_FltSet((TSpiritEq *)AUDIO_EqInstance, tmpEqBand, index);
  }
  
  /* Enable Loundness Control */
  SpiritLdCtrl_Init((TSpiritLdCtrl*)AUDIO_LdCtrlPersistance, I2S_AUDIOFREQ_48K);
  SpiritLdCtrl_GetPrms((TSpiritLdCtrl*)AUDIO_LdCtrlPersistance, &AUDIO_LdCtrlInstanceParams);
  ldness_value = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_LOUD_BKP);
  AUDIO_LdCtrlInstanceParams.gainQ8 = PERC_TO_LDNS_DB(ldness_value);
  SpiritLdCtrl_SetPrms((TSpiritLdCtrl*)AUDIO_LdCtrlPersistance, &AUDIO_LdCtrlInstanceParams);
#endif  
  
  /* Register audio BSP drivers callbacks */
  AUDIO_IF_RegisterCallbacks(AUDIO_TransferComplete_CallBack, 
                             AUDIO_HalfTransfer_CallBack, 
                             AUDIO_Error_CallBack);
    
    
  /* Create Audio Queue */
  osMessageQDef(AUDIO_Queue, 1, uint16_t);
  AudioEvent = osMessageCreate (osMessageQ(AUDIO_Queue), NULL); 
  
  /* Create Audio task */
  osThreadDef(osAudio_Thread, Audio_Thread, osPriorityRealtime, 0, 256);
  AudioThreadId = osThreadCreate (osThread(osAudio_Thread), NULL);  

  return AUDIOPLAYER_ERROR_NONE;
}
Пример #12
0
/**
  * @brief  Start task
  * @param  argument: pointer that is passed to the thread function as start argument.
  * @retval None
  */
static void StartThread(void const * argument)
{
  RCC_ClkInitTypeDef RCC_ClkInitStruct;
  RCC_OscInitTypeDef RCC_OscInitStruct;
  uint32_t FLatency;
  SystemSettingsTypeDef settings;
  osTimerId lcd_timer;
       
  /* Initialize Joystick, Touch screen and LEDs */
  k_BspInit();
  k_LogInit();
  
  /* Initialize GUI */
  GUI_Init();
  WM_MULTIBUF_Enable(1);
  GUI_SelectLayer(1);
  
  /* Initialize RTC */
  k_CalendarBkupInit();
  
  /* Get General settings */
  settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP);
    
  if(settings.b.use_180Mhz)
  {
    HAL_RCC_GetClockConfig(&RCC_ClkInitStruct, &FLatency);
    /* Select HSE as system clock source */
    RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK);
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
    HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);

    HAL_RCC_GetOscConfig(&RCC_OscInitStruct);  
    RCC_OscInitStruct.PLL.PLLM = 8;
    RCC_OscInitStruct.PLL.PLLN = 360;
    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
    RCC_OscInitStruct.PLL.PLLQ = 7;
    HAL_RCC_OscConfig(&RCC_OscInitStruct);
    
    HAL_PWREx_EnableOverDrive();
    
    /* Select PLL as system clock source */
    RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK);
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
    HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
  }
  
  k_StartUp();
  
  /* Initialize Storage Units */
  k_StorageInit();
  
  /*Initialize memory pools */
  k_MemInit();
  
  /* Add Modules*/
  k_ModuleInit();
  
  k_ModuleAdd(&video_player);
  k_ModuleOpenLink(&video_player, "emf");
  k_ModuleOpenLink(&video_player, "EMF");
  k_ModuleAdd(&image_browser);  
  k_ModuleOpenLink(&image_browser, "jpg"); 
  k_ModuleOpenLink(&image_browser, "JPG");
  k_ModuleOpenLink(&image_browser, "bmp"); 
  k_ModuleOpenLink(&image_browser, "BMP");
  k_ModuleAdd(&system_info);
  k_ModuleAdd(&file_browser);
  k_ModuleAdd(&cpu_bench);
  k_ModuleAdd(&game_board);
  
  /* Create GUI task */
  osThreadDef(GUI_Thread, GUIThread, osPriorityHigh, 0, 15 * configMINIMAL_STACK_SIZE);
  osThreadCreate (osThread(GUI_Thread), NULL); 

  /* Create Touch screen Timer */
  osTimerDef(TS_Timer, TimerCallback);
  lcd_timer =  osTimerCreate(osTimer(TS_Timer), osTimerPeriodic, (void *)0);

  /* Start the TS Timer */
  osTimerStart(lcd_timer, 100);
  
  for( ;; )
  {
        /* Toggle LED3 and LED4 */
        BSP_LED_Toggle(LED3);
        BSP_LED_Toggle(LED4);    
        osDelay(250);
  }
}
Пример #13
0
/**
  * @brief  Callback routine of the dialog
  * @param  pMsg: pointer to data structure of type WM_MESSAGE
  * @retval None
  */
static void _cbDialog(WM_MESSAGE * pMsg)
{
  WM_HWIN  hItem, Hint;
  GUI_RECT r;
  int NCode, Id;
  uint32_t tmp_param = 0;
  
  switch (pMsg->MsgId)
  {
  case WM_INIT_DIALOG:
  
    pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO));
    CameraSettings.d32 = k_BkupRestoreParameter(CALIBRATION_CAMERA_SETTING_BKP);
    
    /* Initialization of 'Image' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE);
    IMAGE_SetBitmap(hItem, &bmwizard);
    
    /* Initialization of 'Effects' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT);
    TEXT_SetFont(hItem, GUI_FONT_16B_1);
    
    /* Initialization of 'Radio' */
    hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO);
    RADIO_SetText(hItem, "None", 0);
    RADIO_SetText(hItem, "B&W", 1);
    RADIO_SetText(hItem, "Negative", 2);
    RADIO_SetText(hItem, "Antique", 3);
    RADIO_SetText(hItem, "Blue", 4);
    RADIO_SetText(hItem, "Green", 5);
    RADIO_SetText(hItem, "Red", 6);
    
    /* Camera frame initialization */
    hItem = WM_GetClientWindow(pMsg->hWin);
    WM_GetClientRectEx(hItem, &r);
    hCameraFrame = WM_CreateWindowAsChild(r.x0 + 79, 
                                          r.y0 + 49, r.x1 - 159, 
                                          r.y1 - 93, 
                                          hItem, 
                                          WM_CF_SHOW | WM_CF_LATE_CLIP, 
                                          _cbCameraWindow, 
                                          0);
    
    /* Buttons initialization */
    hItem = BUTTON_CreateEx(266, 175, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_CLOSE);
    WM_SetCallback(hItem, _cbButton_close);
    
    hItem = BUTTON_CreateEx(256, 79, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_CAPTURE);
    WM_SetCallback(hItem, _cbButton_capture);
    
    hItem = BUTTON_CreateEx(266, 14, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_SETTINGS);
    WM_SetCallback(hItem, _cbButton_settings);
    
    _Check_DefaultPath (capture_folder);
    FrameAvailable = 0;
    break;

  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    
    if(hSettings == 0)
    {
      switch(Id)
      {
      case ID_RADIO:
        if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
        {
          hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO);
          if(CAMERA_GetState() != CAMERA_ERROR)
          {
            CAMERA_SelectEffect(RADIO_GetValue(hItem));
          }
        }
        break;
      case ID_BUTTON_CLOSE: /* Notifications sent by 'Close' */
        switch(NCode)
        {
        case WM_NOTIFICATION_RELEASED:
          k_free(pFileInfo);
          CAMERA_Stop();
          GUI_EndDialog(pMsg->hWin, 0);
          break;
        }
        break;
      case ID_BUTTON_CAPTURE: /* Notifications sent by 'OK' */
        switch(NCode)
        {
        case WM_NOTIFICATION_RELEASED:
          /* Show Hint */
          if(CAMERA_GetState() == CAMERA_OK)
          {
            
            Hint = WM_CreateWindowAsChild(100,
                                          90,
                                          120, 32,
                                          pMsg->hWin,
                                          WM_CF_SHOW , 
                                          _cbHint, 
                                          0);
            
            GUI_Exec();
            if(CAMERA_GetState() == CAMERA_OK)
            {             
              CAMERA_SaveToFile(capture_folder);
            }
            WM_DeleteWindow(Hint);
          }
          break;
        }
        break;
      case ID_BUTTON_SETTINGS: /* Notifications sent by 'Settings' */
        switch(NCode)
        {
        case WM_NOTIFICATION_RELEASED:
          camera_disabled = 1;
          hSettings = GUI_CreateDialogBox(_aSettingsDialogCreate, GUI_COUNTOF(_aSettingsDialogCreate), _cbSettingsDialog, CAMERA_hWin, 0, 0);
          break;
        }
        break;
      }
    }
    break;
  case WM_DELETE:
    tmp_param = k_BkupRestoreParameter(CALIBRATION_CAMERA_SETTING_BKP);
    
    /* check if new settings have to be saved */
    if(CameraSettings.d32 != tmp_param)
    {
      k_BkupSaveParameter(CALIBRATION_CAMERA_SETTING_BKP, CameraSettings.d32); 
    }
    break;
    
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}