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

📄 lcd_osd_ktc.c

📁 keil c51平台,此代码可用于学习TFT LCD TV 搜台等,(本人自己修改)
💻 C
📖 第 1 页 / 共 5 页
字号:
{
    if (MODE_NOSIGNAL == ucMode_Curr)
    {
        RTDSetByte(HOSTCTRL_02, 0x40);  // Wake RTD up
        RTDCodeW(OSD_Reset);

        if ((SOURCE_VGA == (stGUD1.INPUT_SOURCE & 0x07)) && (VGA_ONLINE != bVGA_CONNECT))
        {           
            RTDCodeW((unsigned char *)OSD_HINT_TABLE[0][stGUD1.FUNCTION & 0x07]);
        }
        else
        {
            RTDCodeW((unsigned char *)OSD_HINT_TABLE[1][stGUD1.FUNCTION & 0x07]);
        }

        RTDCodeW(OSD_Enable);
    }
    else if (MODE_NOSUPPORT == ucMode_Curr)
    {
        RTDSetByte(HOSTCTRL_02, 0x40);  // Wake RTD up
        RTDCodeW(OSD_Reset);

        RTDCodeW((unsigned char *)OSD_HINT_TABLE[2][stGUD1.FUNCTION & 0x07]);

        RTDCodeW(OSD_Enable);
    }
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// OSD Process Routine
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

// In all OSD main page process, you CANNOT call other main page process directly.
// You CAN only change ucOSD_Page_Index to indicate other main page.
// Main program will detect the change of ucOSD_Page_Index and send NOTIFY_SHOW to the new page.
// The only constraint is YOU CANNOT change ucOSD_Page_Index when receive NOTIFY_SHOW.
// p.s. You can call sub-page process directly.

// OSD_Proc0 handles messages when there is no OSD window on screen (ucOSD_Page_Index = 0)
void OSD_Proc0(unsigned char action)
{
    if ((stGUD1.FUNCTION & 0x07) >= 0x06)
    {
        stGUD1.FUNCTION = stGUD1.FUNCTION & 0xf8;
        Save_GUD1();
    }    
    // In this code, we only bring up the first page of OSD window  when enter-key is pressed.
    // Of course, you can bring up any OSD window by other key-message if you like.
    switch (action)
    {
    case NOTIFY_ENTER_KEY:
        if (MODE_NOSIGNAL == ucMode_Curr || MODE_NOSUPPORT == ucMode_Curr)  
        {   
            ucMode_Curr   = MODE_OSDFORCE;
            return;
        }    
        // Change to OSD Main Page 1 and Main Program will show it
        ucOSD_Page_Index    = 1;
        ucOSD_Item_Index0   = 1;
        ucOSD_Item_Index1   = 0;
        ucOSD_Item_Index2   = 0;
        fac_timer = 0;
        break;

    case NOTIFY_RIGHT_KEY :
    case NOTIFY_LEFT_KEY :  
        if (MODE_NOSIGNAL == ucMode_Curr || MODE_NOSUPPORT == ucMode_Curr)  
        {   
            ucMode_Curr   = MODE_OSDFORCE;
            return;
        }    
#if (AUDIO_TYPE != AUDIO_NONE)
        if ( ucOSD_Item_Index1 == 0 )
        {
            RTDCodeW(OSD_Reset);
            ucOSD_Item_Index1 = 1;
            stGUD3.VOLUME   &= 0x1f;
            RTDCodeW((unsigned char *)OSD_Volume_TABLE[stGUD1.FUNCTION & 0x07]);
            OSD_Slider(3, 1, 22, 0x1f - stGUD3.VOLUME, 0x1f, 0x17);
            RTDCodeW(OSD_Enable);
        }
        else
        {
            if (NOTIFY_RIGHT_KEY == action)
            {
                if (0x00 == stGUD3.VOLUME)      break;
                stGUD3.VOLUME   = stGUD3.VOLUME - 1;
            }
            else
            {
                if (0x1f <= stGUD3.VOLUME)      break;
                stGUD3.VOLUME   = stGUD3.VOLUME + 1;
            }
            OSD_Slider(3, 1, 22, 0x1f - stGUD3.VOLUME, 0x1f, 0x17);
            SetVolume();
            Save_GUD3();
        }
#endif
        fac_timer = 0;
        break;

    case NOTIFY_LR_KEY :
        // Go to Hidden FACTORY Function Page
        if ( fac_timer < 255 )	fac_timer = fac_timer + 1;
        if (SOURCE_VGA == (stGUD1.INPUT_SOURCE & 0x07) && fac_timer == 255)
        {
            ucOSD_Page_Index    = 8;
            ucOSD_Item_Index0   = 1;
            ucOSD_Item_Index1   = 0;
            ucOSD_Item_Index2   = 0;
            fac_timer = 0;
        }
        break;

    case NOTIFY_AUTO_KEY:
        if (MODE_NOSIGNAL == ucMode_Curr || MODE_NOSUPPORT == ucMode_Curr)  
        {   
            ucMode_Curr   = MODE_OSDFORCE;
            return;
        }    
        if ( ucOSD_Page_Index == 0 ) 
	{
            if ( ucOSD_Item_Index1 == 0 ) 
            {
    	        RTDCodeW((unsigned char *)OSD_Autocfg_TABLE[stGUD1.FUNCTION & 0x07]);
                RTDCodeW(OSD_Enable);
                if (MODE_0640x0350x70HZ <= ucMode_Curr && MODE_0720x0400x70HZ >= ucMode_Curr)
                {
                    unsigned char ucResult;

                    stMUD.CLOCK = 128;

                    Set_H_Position();
                    Set_Clock();
                    Save_MUD(ucMode_Curr);

                    ucResult    = Auto_Phase();

                    if (ERROR_SUCCEED == ucResult)      ucResult    = Auto_Position();
                    if (ERROR_INPUT == ucResult)
                    {
                        ucMode_Curr = MODE_OSDFORCE;
                        return;
                    }
                }
                else
                {
                    if (ERROR_INPUT == Auto_Config())
                    {
                        ucMode_Curr = MODE_OSDFORCE;
                        return;
                    }
                }
            }
            else
            {
                ucOSD_Page_Index    = 0;
                ucOSD_Item_Index1   = 0;
                ucOSD_Item_Index2   = 0;
            }	
        }
        RTDCodeW(OSD_PWUP_INI);
        RTDCodeW(OSD_Reset);
        ucOSD_Page_Index    = 0;
        ucOSD_Item_Index0   = 0;
        ucOSD_Item_Index1   = 0;
        ucOSD_Item_Index2   = 0;
	fac_timer = 0;
	break;

    default :
        fac_timer = 0;
        break;
    }
}


#define PAGE1_ITEM_NUM      15
#define PAGE1_ITEM_NONE     0
#define PAGE1_ITEM_AUTO     1
#define PAGE1_ITEM_BRIGHT   2
#define PAGE1_ITEM_CONTRAST 3
#define PAGE1_ITEM_POSH     4
#define PAGE1_ITEM_POSV     5
#define PAGE1_ITEM_CLOCK    6
#define PAGE1_ITEM_PHASE    7
#define PAGE1_ITEM_SHARP    8
#define PAGE1_ITEM_COLOR    9
#define PAGE1_ITEM_VOLUME   10
#define PAGE1_ITEM_OSDT     11
#define PAGE1_ITEM_OSDS     12
#define PAGE1_ITEM_RECALL   13
#define PAGE1_ITEM_LANGUAGE 14
#define PAGE1_ITEM_EXIT     15


void OSD_Proc1(unsigned char action)
{
    switch (action)
    {
    case NOTIFY_ENTER_KEY :
        if (ucOSD_Item_Index1)
        {
            ucOSD_Item_Index1   = 0;    
            Show_Page1();
        }
        else
        {
            if (PAGE1_ITEM_EXIT == ucOSD_Item_Index0)
            {
                ucOSD_Page_Index    = 0;
                ucOSD_Item_Index0   = 0;
                ucOSD_Item_Index1   = 0;
                ucOSD_Item_Index2   = 0;
                RTDCodeW(OSD_Reset);
            }
            else if (MODE_NOSIGNAL != ucMode_Curr && MODE_NOSUPPORT != ucMode_Curr)
            {
                switch (ucOSD_Item_Index0)
                {
                case PAGE1_ITEM_AUTO :
                    if (MODE_0640x0350x70HZ <= ucMode_Curr && MODE_0720x0400x70HZ >= ucMode_Curr)
                    {
                        unsigned char ucResult;
                        stMUD.CLOCK = 128;
                        Set_H_Position();
                        Set_Clock();
                        Save_MUD(ucMode_Curr);
                        ucResult    = Auto_Phase();
                        if (ERROR_SUCCEED == ucResult)      ucResult    = Auto_Position();
                        if (ERROR_INPUT == ucResult)
                        {
                            ucMode_Curr = MODE_OSDFORCE;
                            return;
                        }
                    }
                    else
                    {
                        if (ERROR_INPUT == Auto_Config())
                        {
                            ucMode_Curr = MODE_OSDFORCE;
                            return;
                        }
                    }
                    ucOSD_Item_Index1   = 0;
                    Show_Page1();
                    break;

                case PAGE1_ITEM_RECALL :
                    {
                        unsigned char   ucTemp1, ucTemp2;
                        ucTemp1 = stGUD1.FUNCTION & 0x07;       // Language select
                        ucTemp2 = stGUD1.INPUT_SOURCE & 0x07;   // Source select

                        if (SPANISH < ucTemp1)     ucTemp1 = ENGLISH;
                        Reset_GUD();
                        stGUD1.OSD_TIMEOUT = 10;
#if(IRPOLLING)
    			usOSD_Timer	= (unsigned int)stGUD1.OSD_TIMEOUT * 34;
#else
    			usOSD_Timer	= (unsigned int)stGUD1.OSD_TIMEOUT * 51;
#endif
                        stGUD1.FUNCTION     = (stGUD1.FUNCTION & 0xf8) | ucTemp1;
                        stGUD1.INPUT_SOURCE = (stGUD1.INPUT_SOURCE & 0xf8) | ucTemp2;
                        Save_GUD1();
                        Set_Bright_Contrast();
                        SetADC_Gain();
                        SetADC_Offset();
#if (AUDIO_TYPE != AUDIO_NONE)
                        SetVolume();
#endif
                        OSD_Position();
                    }
                    Init_MUD();
                    Load_MUD(ucMode_Curr);
                    ucMode_Curr = MODE_OSDFORCE;
                    ucOSD_Item_Index1   = 0;
                    Show_Page1();
                    break;

                case PAGE1_ITEM_COLOR :
                    ucOSD_Page_Index    = 2;
                    ucOSD_Item_Index0   = ((0 == (stGUD1.INPUT_SOURCE & 0x18)>>3) ? 3 : (1 == (stGUD1.INPUT_SOURCE & 0x18) >>3) ? 2 
                                           : (2 == (stGUD1.INPUT_SOURCE & 0x18)>>3) ? 1 : 4);
                    ucOSD_Item_Index1   = 0;
                    ucOSD_Item_Index2   = 0;
                    break;
                case PAGE1_ITEM_OSDS :
                    ucOSD_Page_Index    = 3;
                    ucOSD_Item_Index0   = 1;                    
                    ucOSD_Item_Index1   = 0;
                    ucOSD_Item_Index2   = 0;
                    break;
                case PAGE1_ITEM_LANGUAGE :
                    RTDCodeW(OSD_ENTER_B_Atb);
                    ucOSD_Page_Index    = 4;
                    ucOSD_Item_Index0   = (stGUD1.FUNCTION & 0x07) + 1;                    
                    ucOSD_Item_Index1   = 0;
                    ucOSD_Item_Index2   = 0;
                    break;
                default :
                    ucOSD_Item_Index1   = 1;
                    Show_Page1();
                    break;
                }
            }
        }
        break;

    case NOTIFY_RIGHT_KEY :     // Right-key to Increase; Left-key to Decrease
    case NOTIFY_LEFT_KEY :
        if (ucOSD_Item_Index1)
        {
            switch (ucOSD_Item_Index0)
            {
            case PAGE1_ITEM_BRIGHT :
#if (BRIGHT_TYPE == GAIN)
                if (NOTIFY_RIGHT_KEY == action)
                {
                    if (100 <= stGUD0.BRIGHT)       break;

                    if (KEY_TURBO_ENABLE > ucKey_Issued)
                        stGUD0.BRIGHT   = 100 > stGUD0.BRIGHT ? stGUD0.BRIGHT + 1 : 100;
                    else
                        stGUD0.BRIGHT   = 99 > stGUD0.BRIGHT ? stGUD0.BRIGHT + 2 : 100;
                }
                else
                {
                    if (0 == stGUD0.BRIGHT)         break;

                    if (KEY_TURBO_ENABLE > ucKey_Issued)
                        stGUD0.BRIGHT   = 0 < stGUD0.BRIGHT ? stGUD0.BRIGHT - 1 : 0;
                    else
                        stGUD0.BRIGHT   = 1 < stGUD0.BRIGHT ? stGUD0.BRIGHT - 2 : 0;
                }
                Set_Bright_Contrast();
                Save_GUD0();
                OSD_Slider(7, 5, 14, stGUD0.BRIGHT, 100, (0 == ucOSD_Item_Index1) ? 0X01 : 0X04);
#endif
#if (BRIGHT_TYPE == LIGHT)
                if (NOTIFY_RIGHT_KEY == action)
                {
                    if (100 <= fac_light)       break;

                    if (KEY_TURBO_ENABLE > ucKey_Issued)
                        fac_light   = 100 > fac_light ? fac_light + 1 : 100;
                    else
                        fac_light   = 99 > fac_light ? fac_light + 2 : 100;
                }
                else
                {
                    if (0 == fac_light)         break;

                    if (KEY_TURBO_ENABLE > ucKey_Issued)
                        fac_light   = 0 < fac_light ? fac_light - 1 : 0;
                    else
                        fac_light   = 1 < fac_light ? fac_light - 2 : 0;
                }
                Set_Bright_Contrast();
                Save_GUD4();
                OSD_Slider(7, 5, 14, fac_light, 100, (0 == ucOSD_Item_Index1) ? 0X01 : 0X04);                
#endif
                break;
            case PAGE1_ITEM_CONTRAST :
                if (NOTIFY_RIGHT_KEY == action)
                {
                    if (100 <= stGUD0.CONTRAST)     break;

                    if (KEY_TURBO_ENABLE > ucKey_Issued)
                        stGUD0.CONTRAST   = 100 > stGUD0.CONTRAST ? stGUD0.CONTRAST + 1 : 100;
                    else
                        stGUD0.CONTRAST   = 99 > stGUD0.CONTRAST ? stGUD0.CONTRAST + 2 : 100;
                }
                else
                {
                    if (0 == stGUD0.CONTRAST)       break;

                    if (KEY_TURBO_ENABLE > ucKey_Issued)
                        stGUD0.CONTRAST   = 0 < stGUD0.CONTRAST ? stGUD0.CONTRAST - 1 : 0;
                    else
                        stGUD0.CONTRAST   = 1 < stGUD0.CONTRAST ? stGUD0.CONTRAST - 2 : 0;
                }
                Set_Bright_Contrast();
                Save_GUD0();
                OSD_Slider(7, 5, 14, stGUD0.CONTRAST, 100, (0 == ucOSD_Item_Index1) ? 0X01 : 0X04);

⌨️ 快捷键说明

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