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

📄 radio.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 5 页
字号:
#endif //#ifdef WRITE_EEPROM_ENABLE 
}

void _RADIO_DrawFrameBackground(void)
{    
    PARM_DRAW_BITMAP DrawBitmap;          
   
    // Draw radio background photo.
    DrawBitmap.bBitmapID = 0;        
    DrawBitmap.wDestX = RADIO_BG_PHOTO_START_H;
    DrawBitmap.wDestY = RADIO_BG_PHOTO_START_V;        
    DrawBitmap.bDestRegion = 0;
    
    GDI_DrawZipBitmap(&DrawBitmap, _aRADIOArray, (PBYTE)RADIO_UNZIP_ADDR, RADIO_UNZIP_WINDOW_ADDR);
 
    _RADIO_DrawFreqFrame();
    _RADIO_ShowModeButton();
}

void _RADIO_DrawFreqFrame(void)
{
    BYTE i;
    PARM_RECT FreqRect;
    PARM_DRAW_STRING FreqStrAttr;
    WORD BarWidthTemp, BarStartHTemp;

    FreqRect.bColor = RADIO_PALETTE_ENTRY_FREQ_FRAME_BG;
    FreqRect.rect.wLeft = RADIO_BAND_FRAME_START_H;
    FreqRect.rect.wTop = RADIO_BAND_FRAME_START_V;
    FreqRect.rect.wRight = FreqRect.rect.wLeft+RADIO_BAND_FRAME_WIDTH-1;
    FreqRect.rect.wBottom = FreqRect.rect.wTop+RADIO_BAND_FRAME_HEIGHT-1;
    // Fill band frame.
    GDI_FillRoundRect(0, RADIO_BAND_FRAME_ARC_VALUE, &FreqRect);

    FreqRect.bColor = RADIO_PALETTE_ENTRY_FREQ_FRAME_BG_OUTLINE;
    FreqRect.rect.wLeft = FreqRect.rect.wLeft-RADIO_ARC_PIXEL;
    FreqRect.rect.wTop = FreqRect.rect.wTop-RADIO_ARC_PIXEL;
    FreqRect.rect.wRight = FreqRect.rect.wRight+RADIO_ARC_PIXEL;
    FreqRect.rect.wBottom = FreqRect.rect.wBottom+RADIO_ARC_PIXEL;
    // Draw band frame ourter line.
    GDI_DrawRoundRect(0, RADIO_BAND_FRAME_OUTER_ARC_VALUE, RADIO_BAND_FRAME_ARC_VALUE, &FreqRect);

    FreqRect.bColor = RADIO_PALETTE_ENTRY_FREQ_BAR_NORMAL;
    FreqRect.rect.wLeft = RADIO_FREQ_BAR_START_H;
    FreqRect.rect.wTop = RADIO_FREQ_BAR_START_V;
    FreqRect.rect.wRight = FreqRect.rect.wLeft+RADIO_FREQ_BAR_WIDTH+RADIO_DISTANCE_OFFSET20-1;
    FreqRect.rect.wBottom = FreqRect.rect.wTop+RADIO_FREQ_BAR_HEIGHT-1;
    // Fill frequency bar.
    GDI_FillRect(0, &FreqRect);

    FreqRect.bColor = RADIO_PALETTE_ENTRY_FREQ_BAR_HIGHLIGHT;
    FreqRect.rect.wLeft = RADIO_FREQ_BAR_START_H-RADIO_DISTANCE_OFFSET20;
    FreqRect.rect.wRight = RADIO_FREQ_BAR_START_H-1;
    // Fill frequency bar.
    GDI_FillRect(0, &FreqRect);

    FreqRect.bColor = RADIO_PALETTE_ENTRY_TEXT_BLACK;    
    FreqRect.rect.wTop = RADIO_FREQ_BAR_START_V+RADIO_FREQ_BAR_HEIGHT;
    FreqRect.rect.wBottom = FreqRect.rect.wTop+12-1;

    FreqStrAttr.bTextColor = RADIO_PALETTE_ENTRY_TEXT_BLACK;
    FreqStrAttr.bBackground = RADIO_PALETTE_ENTRY_FREQ_FRAME_BG;
    FreqStrAttr.bColorKey = 0;
    FreqStrAttr.bShadow1 = PAL_ENTRY_COLOR_TRANSPARENT;
    FreqStrAttr.bShadow2 = PAL_ENTRY_COLOR_TRANSPARENT;
    FreqStrAttr.wY = FreqRect.rect.wTop+RADIO_DISTANCE_OFFSET10;    

    BarWidthTemp = RADIO_FREQ_BAR_WIDTH*200/205;
    BarStartHTemp = RADIO_FREQ_BAR_START_H+RADIO_FREQ_BAR_WIDTH-BarWidthTemp-1;

    FreqRect.rect.wLeft = RADIO_FREQ_BAR_START_H;
    FreqRect.rect.wRight = FreqRect.rect.wLeft+1;
    // Fill the first frequency large scale (87.5MHz).
    GDI_FillRect(0, &FreqRect);
    FreqStrAttr.wX = FreqRect.rect.wLeft-(GDI_GetStringWidth(_aRADIOUSEuropeBand[0])>>1);        
    // Show the value of frequency scale.
    GDI_DrawString_909(0, &FreqStrAttr, _aRADIOUSEuropeBand[0]); 

    for (i = 1; i < 5; i++)
    {        
        FreqRect.rect.wLeft = BarStartHTemp+(i*(BarWidthTemp>>2));       
        FreqRect.rect.wRight = FreqRect.rect.wLeft+1;        
        // Fill frequency large scale.
        GDI_FillRect(0, &FreqRect);       
        FreqStrAttr.wX = FreqRect.rect.wLeft-(GDI_GetStringWidth(_aRADIOUSEuropeBand[i])>>1);        
        // Show the value of frequency scale.
        GDI_DrawString_909(0, &FreqStrAttr, _aRADIOUSEuropeBand[i]);      
    }
    
    FreqRect.rect.wBottom = FreqRect.rect.wTop+5-1;
	
    for (i = 0; i < 4; i++)
    {        
        FreqRect.rect.wLeft = BarStartHTemp+(BarWidthTemp>>3)+(i*(BarWidthTemp>>2));       
        FreqRect.rect.wRight = FreqRect.rect.wLeft+1;        
        // Fill frequency small scale.
        GDI_FillRect(0, &FreqRect);
    }  
}

void _RADIO_ShowModeButton(void)
{
    //PARM_DRAW_BITMAP DrawButton;
    PARM_RECT ButtonRect;
    PARM_DRAW_STRING ButtonStrAttr;
    BYTE bButtonIndex;         

    MAINMENU_UseColorKey(&ButtonStrAttr);
    ButtonStrAttr.bTextColor = RADIO_PALETTE_ENTRY_TEXT_WHITE;
    ButtonRect.bColor = RADIO_BUTTON_HEIGHT;
    ButtonRect.bShadePtr = _bRADIONormalButtonPalette;

    //DrawButton.bBitmapID = 4;
    for (bButtonIndex = 0; bButtonIndex < RADIO_MODE_NUM; bButtonIndex++)
    {
/*
        // Draw radio background photo.                
        DrawButton.wDestX = RADIOModeButton[bButtonIndex].wStartH;
        DrawButton.wDestY = RADIOModeButton[bButtonIndex].wStartV;        
        DrawButton.bDestRegion = 0;
    
        GDI_DrawZipBitmap(&DrawButton, _aRADIOArray, (PBYTE)RADIO_UNZIP_ADDR, RADIO_UNZIP_WINDOW_ADDR);
*/             
        ButtonRect.rect.wLeft = RADIOModeButton[bButtonIndex].wStartH;
        ButtonRect.rect.wTop = RADIOModeButton[bButtonIndex].wStartV;
        ButtonRect.rect.wRight = ButtonRect.rect.wLeft+RADIO_BUTTON_WIDTH-1;
        ButtonRect.rect.wBottom = ButtonRect.rect.wTop+RADIO_BUTTON_HEIGHT-1;
        // Fill button.
        GDI_FillRoundRect(0|GDI_SHADING_OPERATION, RADIO_BUTTON_ARC_VALUE, &ButtonRect);  

        ButtonRect.bColor = RADIO_PALETTE_ENTRY_NBUTTON_OUTLINE;
        ButtonRect.rect.wLeft = ButtonRect.rect.wLeft-RADIO_ARC_PIXEL;
        ButtonRect.rect.wTop = ButtonRect.rect.wTop-RADIO_ARC_PIXEL;
        ButtonRect.rect.wRight = ButtonRect.rect.wRight+RADIO_ARC_PIXEL;
        ButtonRect.rect.wBottom = ButtonRect.rect.wBottom+RADIO_ARC_PIXEL;
        // Draw button ourter line.
        GDI_DrawRoundRect(0, RADIO_BUTTON_OUTER_ARC_VALUE, RADIO_BUTTON_ARC_VALUE, &ButtonRect);

        ButtonStrAttr.wX = RADIOModeButton[bButtonIndex].wStartH+((RADIO_BUTTON_WIDTH-GDI_GetStringWidth(RADIOModeButton[bButtonIndex].pwText))>>1);
        ButtonStrAttr.wY = RADIOModeButton[bButtonIndex].wStartV+((RADIO_BUTTON_HEIGHT-GDI_GetStringHeight(RADIOModeButton[bButtonIndex].pwText))>>1);    
        // Show mode name.
        GDI_DrawString_909(0, &ButtonStrAttr, RADIOModeButton[bButtonIndex].pwText);	

/*		
        ButtonStrAttr.wX = DrawButton.wDestX+((RADIO_BUTTON_WIDTH-GDI_GetStringWidth(RADIOModeButton[bButtonIndex].pwText))>>1);
        ButtonStrAttr.wY = DrawButton.wDestY+((RADIO_BUTTON_HEIGHT-GDI_GetStringHeight(RADIOModeButton[bButtonIndex].pwText))>>1);    
        // Show mode name.
        GDI_DrawString_909(0, &ButtonStrAttr, RADIOModeButton[bButtonIndex].pwText);  
*/
    }    
}

void _RADIO_UpdateContent(BYTE bRegion, BYTE bClear, BYTE bArrowType)
{
    switch (bRegion)
    {    
    case RADIO_MODE_NAME_REGION:
        _RADIO_UpdateTitle(bClear);        
        break;
    case RADIO_FREQ_REGION:
        _RADIO_UpdateFreqString(bClear);
        _RADIO_UpdateFrequencyBar(bClear, bArrowType);
        break;
    case RADIO_INFO_REGION:
        _RADIO_UpdateInfoRegion(bClear, TRUE, RADIO_COLOR_HIGHLIGHT);
        break;
    case RADIO_ALL_REGION:
        _RADIO_UpdateTitle(bClear);
        _RADIO_UpdateFreqString(bClear);
        _RADIO_UpdateFrequencyBar(bClear, bArrowType);
        _RADIO_UpdateInfoRegion(bClear, TRUE, RADIO_COLOR_HIGHLIGHT);
        break;		
    default:
        break;
    }    
}

void _RADIO_UpdateTitle(BYTE bClear)
{
    PARM_DRAW_BITMAP DrawBitmap;
    PARM_DRAW_STRING TitleStrAttr;

    if (bClear)
    {
        // Draw title background photo.
        DrawBitmap.bBitmapID = 1;        
        DrawBitmap.wDestX = RADIO_TITLE_START_H;
        DrawBitmap.wDestY = RADIO_TITLE_START_V;        
        DrawBitmap.bDestRegion = 0;
    
        GDI_DrawZipBitmap(&DrawBitmap, _aRADIOArray, (PBYTE)RADIO_UNZIP_ADDR, RADIO_UNZIP_WINDOW_ADDR);
    }

    MAINMENU_UseColorKey(&TitleStrAttr);
    TitleStrAttr.bTextColor = RADIO_PALETTE_ENTRY_TEXT_GRAY;   

    TitleStrAttr.wX = RADIO_TITLE_START_H;
    TitleStrAttr.wY = RADIO_TITLE_START_V; 
	
    switch (_bRADIOMode)
    {
    case RADIO_MODE_NORMAL:
        GDI_DrawString_909(0, &TitleStrAttr, aMENUNormal);
        break;
    case RADIO_MODE_FAVORITE:
        GDI_DrawString_909(0, &TitleStrAttr, aPOWERONIconFavorite);
        OSDUTL_PrepareOutputString();
        OSDUTL_CopyStringFromIndex(aRADIOColon);
        OSDUTL_CopyStringFromIndex(aRADIOSpace);
        if (_bRADIOFavoritePlay < 9)
        {
            OSDUTL_OutputNumFromIndex(0);
        }
        OSDUTL_OutputNumFromIndex(_bRADIOFavoritePlay+1);
        TitleStrAttr.wX = TitleStrAttr.wX+(GDI_GetStringWidth(aPOWERONIconFavorite));
        GDI_DrawString_909(0, &TitleStrAttr, __pOSDUTLOutputString);
        break;
    case RADIO_MODE_RECORD:        
        GDI_DrawString_909(0, &TitleStrAttr, aRADIORecord);
        break;
    case RADIO_MODE_SCAN:		
        GDI_DrawString_909(0, &TitleStrAttr, aRADIOScan);
        break;
    case RADIO_MODE_SELECTION:
        GDI_DrawString_909(0, &TitleStrAttr, RADIOModeButton[_bRADIOBackupMode].pwText);
        if (_bRADIOBackupMode == RADIO_MODE_FAVORITE)
        {
            OSDUTL_PrepareOutputString();
            OSDUTL_CopyStringFromIndex(aRADIOColon);
            OSDUTL_CopyStringFromIndex(aRADIOSpace);
            if (_bRADIOFavoritePlay < 9)
            {
                OSDUTL_OutputNumFromIndex(0);
            }
            OSDUTL_OutputNumFromIndex(_bRADIOFavoritePlay+1);
            TitleStrAttr.wX = TitleStrAttr.wX+(GDI_GetStringWidth(aPOWERONIconFavorite));
            GDI_DrawString_909(0, &TitleStrAttr, __pOSDUTLOutputString);
        }
        break;
    default:
        break;
    }
}

void _RADIO_UpdateFreqString(BYTE bClear)
{  
    PARM_DRAW_BITMAP DrawBitmap;
    PARM_DRAW_STRING FreqStrAttr;
    WORD RadioFreq;
	
    if (bClear)
    {
        // Draw frequency string background photo.
        DrawBitmap.bBitmapID = 2;        
        DrawBitmap.wDestX = RADIO_FREQ_STRING_START_H;
        DrawBitmap.wDestY = RADIO_FREQ_STRING_START_V;        
        DrawBitmap.bDestRegion = 0;
    
        GDI_DrawZipBitmap(&DrawBitmap, _aRADIOArray, (PBYTE)RADIO_UNZIP_ADDR, RADIO_UNZIP_WINDOW_ADDR);       
    }

    RadioFreq = RADIODRV_GetFreq();
	
    OSDUTL_PrepareOutputString();    
    OSDUTL_OutputNumFromIndex(RadioFreq/100);
    if ((RadioFreq%100) != 0)
    {
        OSDUTL_CopyStringFromIndex(aRADIODot);
        OSDUTL_OutputNumFromIndex((RadioFreq/10)%10);	
        if ((RadioFreq%10) != 0)
        {
            OSDUTL_OutputNumFromIndex(RadioFreq%10);
        }
    }

    MAINMENU_UseColorKey(&FreqStrAttr);
    FreqStrAttr.bTextColor = RADIO_PALETTE_ENTRY_TEXT_NAVYBLUE;
	
    FreqStrAttr.wX = RADIO_FREQ_STRING_START_H+((RADIO_FREQ_STRING_WIDTH-GDI_GetStringWidth(__pOSDUTLOutputString))>>1)-2;
    FreqStrAttr.wY = RADIO_FREQ_STRING_START_V;    
    // Show current playing frequency.
    GDI_DrawString_909(0, &FreqStrAttr, __pOSDUTLOutputString);  
}

void _RADIO_UpdateFrequencyBar(BYTE bClear, BYTE bArrowType)
{
    PARM_RECT FreqRect;
    DWORD RadioFreq;
    PARM_DRAW_STRING FreqStrAttr;

    if (bClear)
    {
        FreqRect.bColor = RADIO_PALETTE_ENTRY_FREQ_FRAME_BG;
        FreqRect.rect.wLeft = RADIO_BAND_FRAME_START_H+RADIO_DISTANCE_OFFSET10;
        FreqRect.rect.wTop = RADIO_FREQ_ARROW_START_V;
        FreqRect.rect.wRight = RADIO_BAND_FRAME_START_H+RADIO_BAND_FRAME_WIDTH-RADIO_DISTANCE_OFFSET10-1;
        FreqRect.rect.wBottom = FreqRect.rect.wTop+GDI_GetStringHeight(aDSPLYDownArrowSymbol)-1;
        // Clear band arrow region.
        GDI_FillRect(0, &FreqRect);
		
        FreqRect.bColor = RADIO_PALETTE_ENTRY_FREQ_BAR_NORMAL;
        FreqRect.rect.wLeft = RADIO_FREQ_BAR_START_H;
        FreqRect.rect.wTop = RADIO_FREQ_BAR_START_V;
        FreqRect.rect.wRight = FreqRect.rect.wLeft+RADIO_FREQ_BAR_WIDTH-1;
        FreqRect.rect.wBottom = FreqRect.rect.wTop+RADIO_FREQ_BAR_HEIGHT-1;
        // Clear frequency bar.
        GDI_FillRect(0, &FreqRect);
    }
    
    RadioFreq = (DWORD)(RADIODRV_GetFreq());

    RadioFreq = (DWORD)(RADIO_FREQ_BAR_WIDTH*(RadioFreq-_wRADIOStartFreq)/_wRADIOFreqRange);
    FreqRect.bColor = RADIO_PALETTE_ENTRY_FREQ_BAR_HIGHLIGHT;
    FreqRect.rect.wLeft = RADIO_FREQ_BAR_START_H;
    FreqRect.rect.wTop = RADIO_FREQ_BAR_START_V;
    FreqRect.rect.wRight = FreqRect.rect.wLeft+(WORD)RadioFreq-1;
    FreqRect.rect.wBottom = FreqRect.rect.wTop+RADIO_FREQ_BAR_HEIGHT-1;
    // Fill frequency bar.
    GDI_FillRect(0, &FreqRect);

    if (bArrowType == RADIO_COLOR_NORMAL)
    {
        FreqStrAttr.bTextColor = RADIO_PALETTE_ENTRY_FREQ_FRAME_BG;
        _bRADIOFlash = FALSE;
    }
    else
    {
        FreqStrAttr.bTextColor = RADIO_PALETTE_ENTRY_FREQ_BAR_HIGHLIGHT;
        _bRADIOFlash = TRUE;
    }
    
    FreqStrAttr.bBackground = RADIO_PALETTE_ENTRY_FREQ_FRAME_BG;
    FreqStrAttr.bColorKey = 0;
    FreqStrAttr.bShadow1 = PAL_ENTRY_COLOR_TRANSPARENT;
    FreqStrAttr.bShadow2 = PAL_ENTRY_COLOR_TRANSPARENT;

    FreqStrAttr.wX = FreqRect.rect.wRight-(GDI_GetStringWidth(aDSPLYDownArrowSymbol)>>1);
    FreqStrAttr.wY = RADIO_FREQ_ARROW_START_V;    
    // Show arrow incidate current playing frequency.
    GDI_DrawString_909(0, &FreqStrAttr, aDSPLYDownArrowSymbol);   

    _dwRadioFlashTime = OS_GetSysTimer();	
}

void _RADIO_UpdateInfoRegion(BYTE bClear, BYTE bDrawBG, BYTE bListBGType)
{
//    PARM_RECT InfoRect;
    PARM_DRAW_BITMAP DrawBitmap;

    if (bClear)
    {
/*
        InfoRect.bColor = RADIO_PALETTE_ENTRY_FREQ_FRAME_BG;
        InfoRect.rect.wLeft = RADIO_INFO_START_H;

⌨️ 快捷键说明

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