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

📄 radio.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 5 页
字号:
    case RADIO_MODE_NORMAL:
        _RADIO_NormalModeProcess(__bKey);
        break;
    case RADIO_MODE_FAVORITE:
        _RADIO_FavoriteModeProcess(__bKey);
        break;
    case RADIO_MODE_RECORD:        
        _RADIO_RecordModeProcess(__bKey);
        break;
    case RADIO_MODE_SCAN:	        
        break;
     case RADIO_MODE_SELECTION:		
        _RADIO_ModeSelectionProcess(__bKey);
        break;
    default:
        break;
    }

    return KEY_NO_KEY;
}

//*********************************************************************************************************
//  Function    :   RADIO_Recover
//  Abstract    :   The function is called by OSD to do the recovery of radio UI 
//  Arguments   :   bRecoverRegion, the recover region 
//                   :   OSD_RECOVER_ALL 
//                   :   OSD_RECOVER_UPPER_REGION, invalid
//                   :   OSD_RECOVER_BOTTOM_REGION, invalid
//  Return      :   TRUE, The region has been recovered.
//                 :   FALSE, The region doesn't need to be recovered in this UI.
//  Side Effect :   none.
//  Notes       :
//*********************************************************************************************************
BYTE RADIO_Recover(BYTE bRecoverRegion)
{
    if (bRecoverRegion != OSD_RECOVER_ALL) 
    {
    	return FALSE;
    }    

    //RADIO_ConfigOSDRegion();
    RADIO_Initial(FALSE);
    RADIO_ShowFrame();
    //Recover forever message (mute).
    OSD_RecoverNBForeverMsg();        	

    switch (_bRADIOMode)
    {
    case RADIO_MODE_NORMAL:       
    case RADIO_MODE_FAVORITE:
    case RADIO_MODE_SCAN:  
        break;
    case RADIO_MODE_RECORD:        
        _RADIO_UpdateFrequencyBar(TRUE, RADIO_COLOR_HIGHLIGHT);
        break;
     case RADIO_MODE_SELECTION:		
        _RADIO_UpdateFrequencyBar(TRUE, RADIO_COLOR_HIGHLIGHT);
        _RADIO_UpdateButtonCursor(_bRADIOButtonCursorIndex, RADIO_COLOR_HIGHLIGHT, RADIO_COLOR_HIGHLIGHT);	
        break;
    default:
        break;    
    }

    return TRUE;
}

//*********************************************************************************************************
//  Function    :   RADIO_Trigger
//  Abstract    :   This function will flash freq. arrow, record list, mode button, and RDS info.
//  Arguments   :   
//  Return	:               
//  Side Effect :   none.
//  Notes       :
//*********************************************************************************************************
void RADIO_Trigger(void)
{
    switch (_bRADIOMode)
    {
    case RADIO_MODE_NORMAL:       
    case RADIO_MODE_FAVORITE:
        //Flash the frequency arrow.            
        if ((OS_GetSysTimer()-_dwRadioFlashTime) > RADIO_CURSOR_FLASH_TIME)
        {
            if (_bRADIOFlash)
            {
                _RADIO_UpdateFrequencyBar(FALSE, RADIO_COLOR_NORMAL);
            }
            else
            {
                _RADIO_UpdateFrequencyBar(FALSE, RADIO_COLOR_HIGHLIGHT);
            }            
        }
#ifdef SUPPORT_RADIO_RDS		
        //Update RDS information.
        if ((OS_GetSysTimer() - _dwRDSFlashTime) > RADIO_RDS_FLASH_TIME)
        {           
            _RADIO_UpdateRDSInfo(FALSE);		
        }	
#endif		
        break;
    case RADIO_MODE_RECORD:        
        //Flash the record list.            
        if ((OS_GetSysTimer()-_dwRadioFlashTime) > RADIO_CURSOR_FLASH_TIME)
        {
            if (_bRADIOFlash)
            {
                _RADIO_UpdateRecordInfo(FALSE, RADIO_COLOR_HIGHLIGHT, RADIO_COLOR_NORMAL);
            }
            else
            {
                _RADIO_UpdateRecordInfo(FALSE, RADIO_COLOR_HIGHLIGHT, RADIO_COLOR_HIGHLIGHT);
            }            
        }
        break;
     case RADIO_MODE_SELECTION:		
        //Flash the mode button.            
        if ((OS_GetSysTimer()-_dwRadioFlashTime) > RADIO_CURSOR_FLASH_TIME)
        {
            if (_bRADIOFlash)
            {
                _RADIO_UpdateButtonCursor(_bRADIOButtonCursorIndex, RADIO_COLOR_HIGHLIGHT, RADIO_COLOR_NORMAL);
            }
            else
            {
                _RADIO_UpdateButtonCursor(_bRADIOButtonCursorIndex, RADIO_COLOR_HIGHLIGHT, RADIO_COLOR_HIGHLIGHT);
            }            
        }   
#ifdef SUPPORT_RADIO_RDS		
        if ((_bRADIOBackupMode == RADIO_MODE_NORMAL) || (_bRADIOBackupMode == RADIO_MODE_FAVORITE))	
        {
            //Update RDS information.
            if ((OS_GetSysTimer() - _dwRDSFlashTime) > RADIO_RDS_FLASH_TIME)
            {             
                _RADIO_UpdateRDSInfo(FALSE);		
            }	
        }
#endif		
        break;
    default:
        break;    
    }    
}

//*********************************************************************************************************
//  Function    :   RADIO_Exit
//  Abstract    :   This function will be called by OSD kernel to exit radio UI.
//  Arguments   :  bExitMode: OSD_UI_EXIT_ALL/OSD_UI_EXIT_CONTROL_ONLY
//  Return	:               
//  Side Effect :   none.
//  Notes       :
//*********************************************************************************************************
void RADIO_Exit(BYTE bExitMode)
{
#ifdef SUPPORT_RADIO_RDS
    //GDI_REGION_INFO RegionInfo;
#endif

    if (bExitMode == OSD_UI_EXIT_ALL)
    {
        //Clear all radio OSD region.
        GDI_ClearRegion(0);
    }
	
    __bPlayRadio = FALSE;
#ifdef WRITE_EEPROM_ENABLE //SYSTEM_8051
    // Save current playing radio frequency.
    _wRADIOBackupFreq = RADIODRV_GetFreq();
    HAL_WriteStorage(RADIO_ADDR_BACKUP_FREQ, (BYTE *)&_wRADIOBackupFreq, EPROM_BACKUP_FREQ_BYTE);
#endif //#ifdef WRITE_EEPROM_ENABLE 
    RADIODRV_PowerDown();

#ifdef SUPPORT_RADIO_RDS
    // Recover Region 2 (SP OSD).
    //RegionInfo.wWidth = GDI_SP_OSD_REGION_WIDTH;
    //RegionInfo.wHeight = GDI_SP_OSD_REGION_HEIGHT;
    //RegionInfo.bColorMode = GDI_OSD_2B_MODE;
    //RegionInfo.dwTAddr = DS_SP_OSD_ST;    
    //GDI_ConfigRegionInfo(2, &RegionInfo);     
#endif

    //Enable the main video.
    //DISP_DisplayCtrl(DISP_MAINVIDEO, TRUE);
    OSD_ChangeUI(OSD_UI_RADIO_TUNER, OSD_EXIT_UI);
}

//*********************************************************************************************************
//  Function    :   RADIO_Initial
//  Abstract    :   Call this function to initial radio device and set attribute for display volume status.
//  Arguments   :   bPowerUp: (TRUE) enter radio function in first time
//                                      (FALSE) enter radio function not in first time
//  Return	:   TRUE: initial radio device successful
//                    FALSE: initial radio device failed
//  Side Effect :   none.
//  Notes       :
//*********************************************************************************************************
BYTE RADIO_Initial(BYTE bPowerUp)
{
    if (bPowerUp)
    {
        if (!RADIODRV_Init()) // When tuner initial failed, return false.
        {
            printf("\n tuner initial failed!!");
            return FALSE;
        }
    
        _bRADIOFreqRange = RADIO_FREQ_RANGE_US_EUROPE;
        _bRADIOSpace = RADIO_FREQ_SPACE_100K;
    	
        RADIODRV_SETBand(_bRADIOFreqRange);
        RADIODRV_SETChanSpace(_bRADIOSpace);
#ifdef SUPPORT_RADIO_RDS	
        RADIODRV_RDSInit();
#endif

        HAL_IOMute(FALSE);

        if (__btMute)
        {
            RADIODRV_SetMute(!__btMute);
            OSD_OUTPUT_MACRO(MSG_MUTE, __btMute, 0xFF);
        } 
    
        if ((__dwVolAudio/VOLUME_GAP) < 2)
        {
            RADIODRV_SetVol((BYTE)(__dwVolAudio/VOLUME_GAP)&0x0F);
        }
        else
        {
            RADIODRV_SetVol((BYTE)((__dwVolAudio/VOLUME_GAP)-1)&0x0F);
        }		
    }

     //Disable the main video.
    //DISP_DisplayCtrl(DISP_MAINVIDEO, FALSE);
    POWERONMENU_ClearScreen();
	 
    //Set the attributes for volume message display.    
    __OSDNDBottomMsgAttr.wX = RADIO_VOLUME_START_H;
    __OSDNDBottomMsgAttr.wY = RADIO_VOLUME_START_V;
    //__OSDNDBottomMsgAttr.bBackground = RADIO_PALETTE_ENTRY_FRAME_BG;
    //__OSDNDBottomMsgAttr.bTextColor = RADIO_PALETTE_ENTRY_TEXT_BLACK;
    //__OSDNDBottomMsgAttr.bShadow1 = PAL_ENTRY_COLOR_TRANSPARENT;
    //__OSDNDBottomMsgAttr.bShadow2 = PAL_ENTRY_COLOR_TRANSPARENT;
    //__OSDNDBottomMsgAttr.bColorKey = 0;

    return TRUE;
}

void RADIO_ShowFrame(void)
{    
    _RADIO_InitPalette();
    _RADIO_DrawFrameBackground();
    _RADIO_UpdateContent(RADIO_ALL_REGION, FALSE, RADIO_COLOR_HIGHLIGHT);
}

//*********************************************************************************************************
//  Function    :   RADIO_AutoScan
//  Abstract    :   This function will do radio auto scan and save found station to favorite.
//  Arguments   :   
//  Return	:               
//  Side Effect :   none.
//  Notes       :
//*********************************************************************************************************
void RADIO_Scan(void)
{
    BYTE bIndex, bLoop;
    WORD wFreqTemp1, wFreqTemp2;

    if (!__btMute)
    {
        RADIODRV_SetMute(0); // Enable mute
    }
    
    bLoop = FALSE;
    wFreqTemp1 = RADIODRV_GetFreq();	// Save current frequency.
    wFreqTemp2 = wFreqTemp1;
    for (bIndex = 0; bIndex < RADIO_FAVORITE_NUM; bIndex++)
    {
        if (!RADIODRV_Seek(TRUE)) // Seek successful.
        {
            // Re-scan from the start point of the loop (8700~10800).
            if (RADIODRV_GetFreq() <= wFreqTemp2 && bLoop == FALSE)
            {
                bLoop = TRUE; 
            }
            // Already scan all frequency.
            else if (RADIODRV_GetFreq() <= wFreqTemp2 && bLoop == TRUE)
            {
                break;
            }
			
            // Already scan all frequency. 
            if (bLoop == TRUE && RADIODRV_GetFreq() >= wFreqTemp1)
            {
                if (RADIODRV_GetFreq() == wFreqTemp1)
                {
                    _bRADIOStationNum++;
                    _wRADIOFavorite[bIndex] = RADIODRV_GetFreq();
#ifdef WRITE_EEPROM_ENABLE //SYSTEM_8051
                    HAL_WriteStorage(RADIO_ADDR_FAVORITE+2*bIndex, (BYTE *)(_wRADIOFavorite)+2*bIndex, 2);
#endif //#ifdef WRITE_EEPROM_ENABLE 
                    _RADIO_UpdateContent(RADIO_FREQ_REGION, TRUE, RADIO_COLOR_HIGHLIGHT);
                    _RADIO_UpdateInfoRegion(FALSE, FALSE, RADIO_COLOR_NORMAL);
                }
				
                break; 
            }
			
            wFreqTemp2 = RADIODRV_GetFreq();
            _bRADIOStationNum++;
            _wRADIOFavorite[bIndex] = RADIODRV_GetFreq();
#ifdef WRITE_EEPROM_ENABLE //SYSTEM_8051
            HAL_WriteStorage(RADIO_ADDR_FAVORITE+2*bIndex, (BYTE *)(_wRADIOFavorite)+2*bIndex, 2);
#endif //#ifdef WRITE_EEPROM_ENABLE 
            _RADIO_UpdateContent(RADIO_FREQ_REGION, TRUE, RADIO_COLOR_HIGHLIGHT);
            _RADIO_UpdateInfoRegion(FALSE, FALSE, RADIO_COLOR_NORMAL);
        }
        else // Seek failed
        {
            break;
        }
    }

    if (!__btMute)
    {
        RADIODRV_SetMute(1); // Disable mute
    }	
    
    if (_bRADIOStationNum == 0) // Not find any stations.
    {
        _bRADIOFavoritePlay = _bRADIOStationNum;
    }
    else
    {
        _bRADIOFavoritePlay = _bRADIOStationNum - 1;
    }
    _bRADIOButtonCursorIndex = RADIO_MODE_FAVORITE; // Set the cursor index to favorite button.
    RADIODRV_tune(_wRADIOFavorite[_bRADIOFavoritePlay]);
    _bRADIOMode = RADIO_MODE_FAVORITE;
    _RADIO_UpdateContent(RADIO_ALL_REGION, TRUE, RADIO_COLOR_HIGHLIGHT);	
}

//********************************************************************************************************//  Function    :   RADIO_ClearRegion
//  Abstract    :   This function will be called by OSD to clear the normal bottom 
//              :   region if the UI accepts the normal display message is displayed in its UI.//  Arguments   :   bRegion: OSD_ND_BOTTOM_REGION.
//  Return		:   none.//  Side Effect :   none.//  Notes       :   //*********************************************************************************************************void RADIO_ClearRegion(BYTE bRegion)
{
    PARM_RECT NBRegionRect;

⌨️ 快捷键说明

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