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

📄 lcd_main.c

📁 Realtek 公司的RTD2523A芯片原厂source code,没有被修改过的。
💻 C
字号:
#define __MAIN__

#include "Header\INCLUDE.H"


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main Program
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void main(void)
{
    unsigned char idata     ucNotify;

    //////////////////////////////////////////////////////////////////////////
    // Step 1. Initial Whole System
    //////////////////////////////////////////////////////////////////////////

    System_Init();
    
    //////////////////////////////////////////////////////////////////////////
    // Step 2. Initial Scalar
    //////////////////////////////////////////////////////////////////////////

	Power_Status_Init();
    ucCurrStatus    = bPower_Status ? INIT_STATE : PWOFF_STATE;
    usStateTimer    = LOGO_PERIOD;
   
    //////////////////////////////////////////////////////////////////////////
    // Step 3. Enter Main Program Loop
    //////////////////////////////////////////////////////////////////////////

    while (1)
    {	
        // For debugging through ISPACK and KingMice
        RTD_Test();
        
        // Check if input signal is stable during display and turn-off backlight
        // ASAP once input signal is changed.
        if (Frame_Sync_Detector())
        {
            ucCurrStatus    = SEARCH_STATE;
            usStateTimer    = BKGND_PERIOD;

            bNotify_Timer0_Int  = 0;
        }

        //////////////////////////////////////////////////////////////////////////
        // bNotify_Timer0_Int is set to 1 by timer interrupt every 20ms.
        //////////////////////////////////////////////////////////////////////////

        if (bNotify_Timer0_Int)
        { 
            
#if (RS232_DEBUG)
            // For debugging through RS232
            DebugModeLoop();
#endif

            ///////////////////////////////////////////////////////////////
            // Step A. Get Key Information
            ///////////////////////////////////////////////////////////////
            ucNotify    = Key_Trans();

            ///////////////////////////////////////////////////////////////
            // Step B. Check System Power Status and Respond to Power Key
            ///////////////////////////////////////////////////////////////
            if (Power_Control(ucNotify))
            {
                ucCurrStatus    = bPower_Status ? INIT_STATE : PWOFF_STATE;
                usStateTimer    = LOGO_PERIOD;
            }
            else
            {
                ///////////////////////////////////////////////////////////
                // Step C. Show Customer's Logo
                ///////////////////////////////////////////////////////////
                Display_Logo_Animation();
                
                ///////////////////////////////////////////////////////////
                // Step D. Check Input Source Selection 
                ///////////////////////////////////////////////////////////
                if (Source_Control(ucNotify))
                {
                    // Prepare Showing Input Source Note (like VGA/DVI)
                    OSD_Dispatcher(NOTIFY_SOURCEID);

                    ucCurrStatus    = SEARCH_STATE;
                    usStateTimer    = BKGND_PERIOD;
                }
                else
                {
                    ///////////////////////////////////////////////////////
                    // Step E. Detect and Check Input Signal
                    ///////////////////////////////////////////////////////
                    if (Input_Mode_Detector())
                    {
                        ucCurrStatus    = SEARCH_STATE;
                        usStateTimer    = BKGND_PERIOD;
                    }
                    else
                    {
                        ///////////////////////////////////////////////////
                        // Step F. Display Input Image and OSD 
                        ///////////////////////////////////////////////////
                        Display_State_Control(ucNotify);
                    }
                }
            }

            // Clear Flag and End Mission
            bNotify_Timer0_Int  = 0;
        }   
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Static Function
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void Display_Logo_Animation()
{
    if (INIT_STATE == ucCurrStatus)
    {
        // You can show your logo animation here, and set ucCurrStatus to SEARCH_STATE when finished.
        
        OSD_Dispatcher(NOTIFY_RESET_OSD);   // Clear OSD
        OSD_Dispatcher(NOTIFY_SHOWLOGO);    // Show Logo
        OSD_Dispatcher(NOTIFY_RESET_OSD);   // Clear Logo

        OSD_Dispatcher(NOTIFY_SOURCEID);    // Prepare Source Note

        ucCurrStatus    = SEARCH_STATE;     // Go to next state
        usStateTimer    = BKGND_PERIOD;
    }
}

void Display_State_Control(unsigned char ucNotify)
{
#if (BURNIN_MODE)
    if (BKGND_STATE == ucCurrStatus)
    {
        BurnIn();
        return;
    }
#endif

    if (usStateTimer)   usStateTimer -= 1;

    switch (ucCurrStatus)
    {
    case SEARCH_STATE :

        // Issac : If you don't want to enter SLEEP_STATE when cable is connected (even no signal),
        //         you can modify the line below to enter ACTIVE_STATE instead of BKGND_STATE.

        ucCurrStatus    = (MODE_NOSIGNAL == ucMode_Curr) ? BKGND_STATE : ACTIVE_STATE;
        usStateTimer    = BKGND_PERIOD;
        bReload         = 1;
        break;

    case ACTIVE_STATE :
    case BKGND_STATE :

        if (bReload || Is_Main_OSD_Exist() || ACTIVE_STATE == ucCurrStatus)
        {
            usStateTimer    = BKGND_PERIOD;
        }

        if (usStateTimer)
        {
            if (_OFF == bPanel_Status)
            {
                OSD_Dispatcher(NOTIFY_LOADFONT);    // Load OSD font
                Set_Panel(1);                       // Turn on panel

                usStateTimer    = BKGND_PERIOD;
            }
            
            if (bReload)
            {
                bReload     = 0;

                Start_Display();

                OSD_Dispatcher(NOTIFY_RESET_OSD);

                bLIGHT_PWR  = LIGHT_ON;

                ucNotify    = NOTIFY_SHOW;
            }   
            
            OSD_Dispatcher(ucNotify);
            
            if (MODE_OSDFORCE == ucMode_Curr)   // OSD force to reset
            {
                Reset_Mode();
                ucCurrStatus        = SEARCH_STATE;
            }
        }
        else
        {
            if (_ON == bPanel_Status)
            {
                OSD_Dispatcher(NOTIFY_RESET_OSD);
                Set_Panel(0);

                PowerDown_ADC();

                RTDSetByte(HOSTCTRL_02, 0x02);
            }
            ucCurrStatus    = SLEEP_STATE;
        }
        break;

    case SLEEP_STATE :

        if (Is_Key_For_Wakeup(ucNotify))
        {
            // In sleep state, panel must be OFF.

            OSD_Dispatcher(NOTIFY_LOADFONT);    // Load OSD font
            Set_Panel(1);                       // Turn on panel

            ucCurrStatus    = BKGND_STATE;
            usStateTimer    = BKGND_PERIOD;

            OSD_Dispatcher(ucNotify);
        }
        break;

    default :
        // You should never come here. If you comes here, you should check and modify your code.
        break;
    }
}


#if (BURNIN_MODE)
void BurnIn()
{
    static unsigned char Color = 1;
    static unsigned char ColorCounter = 100;
  
    if (_OFF == bPanel_Status)
    {
        OSD_Dispatcher(NOTIFY_LOADFONT);    // Load OSD font
        Set_Panel(1);                       // Turn on panel
    }
    bLIGHT_PWR  = LIGHT_ON;

    if (ColorCounter)      
        ColorCounter   -= 1;
    else
    {  
        Color += 1;
        
        if (Color == 17)    Color = 1;

        if ( _ON == bPanel_Status)
        {
            Wait_For_Event(EVENT_DEN_STOP);     // Wait for Frame End

            Set_Background_Color(BurnInColor[0][Color], BurnInColor[1][Color], BurnInColor[2][Color]);

            RTDSetBit(VDIS_CTRL_20,0x5f,0x20 | DHS_MASK);
        }
        
        ColorCounter = 255;              
    }	    
}
#endif

⌨️ 快捷键说明

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