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

📄 lcd_osd_rel.c

📁 keil c51平台,此代码可用于学习TFT LCD 之TCON,SCALER,OSD,(本人自己修改)
💻 C
📖 第 1 页 / 共 5 页
字号:
#define PAGE2_ITEM_POSH     1
#define PAGE2_ITEM_POSV     2
#define PAGE2_ITEM_SHARP    3
#define PAGE2_ITEM_PHASE    4
#define PAGE2_ITEM_CLOCK    5
#define PAGE2_ITEM_EXIT     6

void OSD_Proc2(unsigned char action)
{
    switch (action)
    {
    case NOTIFY_ENTER_KEY :
        if (0 == ucOSD_Item_Index0)
        {
            if (MODE_NOSIGNAL != ucMode_Curr && MODE_NOSUPPORT != ucMode_Curr)
            {
                // Select and highlight the first item
                ucOSD_Item_Index0   = PAGE2_ITEM_POSH;
                ucOSD_Item_Index1   = 0;
                OSD_Window(1, (2 + ucOSD_Item_Index0), (2 + ucOSD_Item_Index0), 7, 23, 7, COLOR_CYAN);
            }
        }
        else
        {
            if (ucOSD_Item_Index1)
            {
                ucOSD_Item_Index1   = 0;    // Leave the item
                Show_Mode();
            }
            else
            {
                if (PAGE2_ITEM_EXIT == ucOSD_Item_Index0)
                {
                    // De-select the page item and disable the hightlight window
                    ucOSD_Item_Index0   = 0;
                    ucOSD_Item_Index1   = 0;

                    // Disable highlight window
                    OSD_Window(1, (2 + PAGE2_ITEM_EXIT), (2 + PAGE2_ITEM_EXIT), 7, 23, 3, COLOR_CYAN);
                }
                else if (MODE_NOSIGNAL != ucMode_Curr && MODE_NOSUPPORT != ucMode_Curr)
                {
                    if (SOURCE_VGA == (stGUD1.INPUT_SOURCE & 0x07) || PAGE2_ITEM_SHARP == ucOSD_Item_Index0)
                    {
                        switch (ucOSD_Item_Index0)
                        {
                        case PAGE2_ITEM_POSH :
                            ucOSD_Item_Index1   = 1;    // Enter the item
                            OSD_Slider(11, 2, 20, ucH_Max_Margin - stMUD.H_POSITION, ucH_Max_Margin - ucH_Min_Margin, 0x61);
                            break;
                        case PAGE2_ITEM_POSV :
                            ucOSD_Item_Index1   = 1;    // Enter the item
                            OSD_Slider(11, 2, 20, (unsigned int)(stMUD.V_POSITION - ucV_Min_Margin) * 50 / (128 - ucV_Min_Margin), 100, 0x61);
                            break;
                        case PAGE2_ITEM_SHARP :
                            ucOSD_Item_Index1   = stGUD1.FILTER + 1;
                            RTDCodeW((1 == ucOSD_Item_Index1) ? OSD_Sharp_1 : (2 == ucOSD_Item_Index1) ? OSD_Sharp_2
                                : (3 == ucOSD_Item_Index1) ? OSD_Sharp_3 : (4 == ucOSD_Item_Index1) ? OSD_Sharp_4 : OSD_Sharp_5);
                            break;
                        case PAGE2_ITEM_PHASE :
                            ucOSD_Item_Index1   = 1;    // Enter the item
                            OSD_Slider(11, 2, 20, (stMUD.PHASE & 0x7c) >> 2, 31, 0x61);
                            break;
                        case PAGE2_ITEM_CLOCK :
                            ucOSD_Item_Index1   = 1;    // Enter the item
                            OSD_Slider(11, 2, 20, stMUD.CLOCK - 28, 200, 0x61);
                            break;
                        }
                    }
                }
            }
        }
        break;

    case NOTIFY_RIGHT_KEY :     // Right-key to Increase; Left-key to Decrease
    case NOTIFY_LEFT_KEY :
    case NOTIFY_IR_RIGHT_KEY :
    case NOTIFY_IR_LEFT_KEY :
        if (ucOSD_Item_Index1)
        {
            switch (ucOSD_Item_Index0)
            {
            case PAGE2_ITEM_POSH :
                if (NOTIFY_RIGHT_KEY == action || NOTIFY_IR_RIGHT_KEY == action)
                {
                    if (ucH_Min_Margin >= stMUD.H_POSITION)     break;

                    if (KEY_TURBO_ENABLE > ucKey_Issued)
                        stMUD.H_POSITION    = stMUD.H_POSITION > ucH_Min_Margin ? stMUD.H_POSITION - 1 : ucH_Min_Margin;
                    else
                        stMUD.H_POSITION    = stMUD.H_POSITION > (ucH_Min_Margin + 2) ? stMUD.H_POSITION - 3 : ucH_Min_Margin;
                }
                else
                {
                    if (ucH_Max_Margin <= stMUD.H_POSITION)     break;

                    if (KEY_TURBO_ENABLE > ucKey_Issued)
                        stMUD.H_POSITION    = stMUD.H_POSITION < ucH_Max_Margin ? stMUD.H_POSITION + 1 : ucH_Max_Margin;
                    else
                        stMUD.H_POSITION    = stMUD.H_POSITION < (ucH_Max_Margin - 2) ? stMUD.H_POSITION + 3 : ucH_Max_Margin;
                }                    
                OSD_Slider(11, 2, 20, ucH_Max_Margin - stMUD.H_POSITION, ucH_Max_Margin - ucH_Min_Margin, 0x61);
                Set_H_Position();
                Save_MUD(ucMode_Curr);
                break;
            case PAGE2_ITEM_POSV :
                if (NOTIFY_RIGHT_KEY == action || NOTIFY_IR_RIGHT_KEY == action)
                {
                    if ((unsigned int)256 - ucV_Min_Margin <= stMUD.V_POSITION)     break;

                    stMUD.V_POSITION    += 1;
                }
                else
                {
                    if (ucV_Min_Margin >= stMUD.V_POSITION)     break;

                    stMUD.V_POSITION    -= 1;
                }                
                OSD_Slider(11, 2, 20, (unsigned int)(stMUD.V_POSITION - ucV_Min_Margin) * 50 / (128 - ucV_Min_Margin), 100, 0x61);
                Set_V_Position();
                Save_MUD(ucMode_Curr);
                break;
            case PAGE2_ITEM_SHARP :
                if (NOTIFY_RIGHT_KEY == action || NOTIFY_IR_RIGHT_KEY == action)
                {
                    if (5 <= ucOSD_Item_Index1)     break;

                    ucOSD_Item_Index1   = ucOSD_Item_Index1 + 1;
                }
                else
                {
                    if (1 >= ucOSD_Item_Index1)     break;

                    ucOSD_Item_Index1   = ucOSD_Item_Index1 - 1;
                }

                RTDCodeW((1 == ucOSD_Item_Index1) ? OSD_Sharp_1 : (2 == ucOSD_Item_Index1) ? OSD_Sharp_2
                    : (3 == ucOSD_Item_Index1) ? OSD_Sharp_3 : (4 == ucOSD_Item_Index1) ? OSD_Sharp_4 : OSD_Sharp_5);
                
                stGUD1.FILTER    = ucOSD_Item_Index1 - 1;
                Sharpness();
                Save_GUD1();
                break;
            case PAGE2_ITEM_PHASE :
                stMUD.PHASE     &= 0x7c;
                if (NOTIFY_RIGHT_KEY == action || NOTIFY_IR_RIGHT_KEY == action)
                {
                    if (0x7c <= stMUD.PHASE)    break;

                    stMUD.PHASE += 4;
                }
                else
                {
                    if (0x00 == stMUD.PHASE)    break;

                    stMUD.PHASE -= 4;
                }
                OSD_Slider(11, 2, 20, (stMUD.PHASE & 0x7c) >> 2, 31, 0x61);
                Set_Phase(stMUD.PHASE);
                Save_MUD(ucMode_Curr);
                break;
            case PAGE2_ITEM_CLOCK :
                if (NOTIFY_RIGHT_KEY == action || NOTIFY_IR_RIGHT_KEY == action)
                {
                    if (228 <= stMUD.CLOCK)     break;

                    if (KEY_TURBO_ENABLE > ucKey_Issued)
                        stMUD.CLOCK = (227 >= stMUD.CLOCK) ? stMUD.CLOCK + 1 : 228;
                    else
                        stMUD.CLOCK = (226 >= stMUD.CLOCK) ? stMUD.CLOCK + 2 : 228;
                    
                    Set_Clock();
                    Set_H_Position();
                }
                else
                {
                    if (28 >= stMUD.CLOCK)     break;

                    if (KEY_TURBO_ENABLE > ucKey_Issued)
                        stMUD.CLOCK = (29 <= stMUD.CLOCK) ? stMUD.CLOCK - 1 : 28;
                    else
                        stMUD.CLOCK = (30 <= stMUD.CLOCK) ? stMUD.CLOCK - 2 : 28;
                    
                    Set_H_Position();
                    Set_Clock();
                }                    
                OSD_Slider(11, 2, 20, stMUD.CLOCK - 28, 200, 0x61);
                Save_MUD(ucMode_Curr);
                break;
            }
        }
        else
        {
            if (ucOSD_Item_Index0)
            {
                // Select and highlight the next/previous item
                if (NOTIFY_RIGHT_KEY == action || NOTIFY_IR_RIGHT_KEY == action)
                    ucOSD_Item_Index0   = (PAGE2_ITEM_NUM == ucOSD_Item_Index0) ? 1 : (ucOSD_Item_Index0 + 1);
                else
                    ucOSD_Item_Index0   = (1 == ucOSD_Item_Index0) ? PAGE2_ITEM_NUM : (ucOSD_Item_Index0 - 1);

                OSD_Window(1, (2 + ucOSD_Item_Index0), (2 + ucOSD_Item_Index0), 7, 23, 7, COLOR_CYAN);
            }
            else
            {
                // Change to next/previous main page
                if (NOTIFY_RIGHT_KEY == action || NOTIFY_IR_RIGHT_KEY == action)
                    ucOSD_Page_Index    = GetNextPageIdx(ucOSD_Page_Index);
                else
                    ucOSD_Page_Index    = GetPrevPageIdx(ucOSD_Page_Index);
            }
        }
        break;

    case NOTIFY_SHOW :
        Init_Page(1);
        RTDCodeW(CHINESE == (stGUD1.FUNCTION & 0x07) ? Page2_C_Atb : Page2_E_Atb);
        RTDCodeW((unsigned char *)OSD_PAGE_TABLE[1][stGUD1.FUNCTION & 0x07]);

        // Highlight the select item
        OSD_Window(1, (2 + ucOSD_Item_Index0), (2 + ucOSD_Item_Index0), 7, 23, (ucOSD_Item_Index0 ? 7 : 3), COLOR_CYAN);

        if (MODE_NOSIGNAL == ucMode_Curr || MODE_NOSUPPORT == ucMode_Curr)
        {
            ucOSD_Item_Index0   = 0;
            ucOSD_Item_Index1   = 0;
        }

        if (SOURCE_VGA != (stGUD1.INPUT_SOURCE & 0x07) && PAGE2_ITEM_SHARP != ucOSD_Item_Index0)
        {
            ucOSD_Item_Index1   = 0;
        }

        if (0 == ucOSD_Item_Index1)
            Show_Mode();                // No Slider or ON/OFF text on Page
        else
        {
            switch (ucOSD_Item_Index0)
            {
            case PAGE2_ITEM_POSH :
                OSD_Slider(11, 2, 20, ucH_Max_Margin - stMUD.H_POSITION, ucH_Max_Margin - ucH_Min_Margin, 0x61);
                break;
            case PAGE2_ITEM_POSV :
                OSD_Slider(11, 2, 20, (unsigned int)(stMUD.V_POSITION - ucV_Min_Margin) * 50 / (128 - ucV_Min_Margin), 100, 0x61);
                break;
            case PAGE2_ITEM_SHARP :
                ucOSD_Item_Index1   = stGUD1.FILTER + 1;
                RTDCodeW((1 == ucOSD_Item_Index1) ? OSD_Sharp_1 : (2 == ucOSD_Item_Index1) ? OSD_Sharp_2
                    : (3 == ucOSD_Item_Index1) ? OSD_Sharp_3 : (4 == ucOSD_Item_Index1) ? OSD_Sharp_4 : OSD_Sharp_5);
                break;
            case PAGE2_ITEM_PHASE :
                OSD_Slider(11, 2, 20, (stMUD.PHASE & 0x7c) >> 2, 31, 0x61);
                break;
            case PAGE2_ITEM_CLOCK :
                OSD_Slider(11, 2, 20, stMUD.CLOCK - 28, 200, 0x61);
                break;
            }
        }
        break;
        
#if (KEY_TYPE == KEY_5)
    case NOTIFY_AUTO_KEY :
#endif

#if (KEY_TYPE == KEY_6)
    case NOTIFY_AUTO_KEY:
        RTDCodeW(OSD_Reset);
    	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;
            }
        }
	break;

    case NOTIFY_EXIT_KEY :
#endif    	
        if (0 == ucOSD_Item_Index1)
        {
            if (0 == ucOSD_Item_Index0)
            {
                ucOSD_Page_Index    = 0;
                RTDCodeW(OSD_Reset);            
            }
            else
            {
            	ucOSD_Item_Index0   = 0;
                OSD_Window(1, (2 + ucOSD_Item_Index0), (2 + ucOSD_Item_Index0), 7, 23, 3, COLOR_CYAN);
                Show_Mode();
            }    
        }
        else
        {
            ucOSD_Item_Index1   = 0;                
            Show_Mode();	
        }
        break;

    default :
        // We don't handle other messages
        break;
    }
}

#define PAGE3_ITEM_NUM      6
#define PAGE3_ITEM_NONE     0
#define PAGE3_ITEM_AUTOCFG  1
#define PAGE3_ITEM_AUTOPOS  2
#define PAGE3_ITEM_AUTOPHA  3
#define PAGE3_ITEM_AUTOCLK  4
#define PAGE3_ITEM_AUTOBAL  5
#define PAGE3_ITEM_EXIT     6

void OSD_Proc3(unsigned char action)
{
    switch (action)
    {
    case NOTIFY_ENTER_KEY :
        if (0 == ucOSD_Item_Index0)
        {
            if (MODE_NOSIGNAL != ucMode_Curr && MODE_NOSUPPORT != ucMode_Curr)
            {
                // Select and highlight the first item
                ucOSD_Item_Index0   = PAGE3_ITEM_AUTOCFG;
                ucOSD_Item_Index1   = 0;
                OSD_Window(1, (2 + ucOSD_Item_Index0), (2 + ucOSD_Item_Index0), 7, 23, 7, COLOR_CYAN);
            }
        }
        else
        {
            if (PAGE3_ITEM_EXIT == ucOSD_Item_Index0)
            {
                // De-select the page item and disable the hightlight window
                ucOSD_Item_Index0   = 0;
                ucOSD_Item_Index1   = 0;

                // Disable highlight window
                OSD_Window(1, (2 + PAGE3_ITEM_EXIT), (2 + PAGE3_ITEM_EXIT), 7, 23, 3, COLOR_CYAN);
            }
            else if (ucOSD_Item_Index1)
            {
                if (1 == ucOSD_Item_Index1)
                {
                    switch (ucOSD_Item_Index0)
                    {
                    case PAGE3_ITEM_AUTOCFG :
                        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;

⌨️ 快捷键说明

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