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

📄 lcd_func.~c

📁 液晶显示器程序代码
💻 ~C
📖 第 1 页 / 共 2 页
字号:
#define __FUNC__

#include "reg52.h"
#include "intrins.h"

#include "Header\MAIN_DEF.H"
#include "Header\CONFIG.H"
#include "Header\ACCESS.H"
#include "Header\OSD.H"
#include "Header\LCD_COEF.H"
#include "Header\LCD_MAIN.H"
#include "Header\LCD_AUTO.H"
#include "Header\LCD_FUNC.H"
#include "Header\FRAME_SYNC.H"
#include "Header\LCD_OSD.H"


#if (TV_CHIP != TV_NONE)
#include "TUNER.H"
#endif

void SetVolume()
{
    stGUD3.VOLUME   &= 0x1f;

#if (AUDIO_TYPE == AUDIO_LM4832)
    Data[0] = 10;
    Data[1] = ADDR_LM4832;
    Data[2] = 0x00;
    Data[3] = 0x02;
    Data[4] = 0x00;                     // Input Volume - 0 dB
    Data[5] = 0x26;                     // Bass         - 0 dB
    Data[6] = 0x46;                     // Treble       - 0 dB
    Data[7] = 0x60 | stGUD3.VOLUME;     // Right Volume
    Data[8] = 0x80 | stGUD3.VOLUME;     // Left Volume

    // Mic 1 selected with 20dB when input source is VGA or DVI
    // Both Mic 1 and 2 selected with 20dB when input source is AV or S-Video
    Data[9] = (SOURCE_AV <= (stGUD1.INPUT_SOURCE & 0x07)) ? 0xa6 : 0xa4;
    
    I2CWrite(Data);
#endif

#if (AUDIO_TYPE == AUDIO_PWM2)
    Data[0] = 6;
    Data[1] = Y_INC;
    Data[2] = OSD_ROW_90;
    Data[3] = 0x80;
    Data[4] = 0x01;
#if (INV_VOLUME)
    Data[5] = (0xff -(stGUD3.VOLUME << 3));
#else
	Data[5] = (stGUD3.VOLUME << 3);
#endif
	Data[6] = 0;
    RTDWrite(Data);
#endif


#if (AUDIO_TYPE == AUDIO_PWM0)

    Data[0] = 6;
    Data[1] = Y_INC;
    Data[2] = OSD_ROW_90;
    Data[3] = 0x00;
    Data[4] = 0x01;
#if (INV_VOLUME)
    Data[5] = (0xff -(stGUD3.VOLUME << 3));
#else
	Data[5] = (stGUD3.VOLUME << 3);
#endif
	Data[6] = 0;
    RTDWrite(Data);
#endif
}

void WriteGamma(unsigned char code *arrayR, unsigned char code *arrayG, unsigned char code *arrayB)
{
    unsigned char   n   = 0;

    RTDSetBit(COLOR_CTRL_5D, 0xfb, 0x10);   // Disable GAMMA & Enable Access Channel
    

    // GAMMA_RED
    bRTD_SCSB   = 0;
    RTDSendAddr(RED_GAMMA_64, WRITE, N_INC);
    do
    {
        RTDSendByte(arrayR[n]);
    }
    while (++n);    // if n is 0xff, then n will be 0x00 after increased.

#if(MCU_TYPE == MCU_WINBOND)
    bRTD_SCLK   = 0; 
    bRTD_SCLK   = 1;           
    bRTD_SCSB   = 1;
    
    // GAMMA_GREEN
    bRTD_SCSB   = 0;
#else
    MCU_WriteRtdSclk(LOW); 
    MCU_WriteRtdSclk(HIGH);           
    MCU_WriteRtdScsb(HIGH);
    
    // GAMMA_GREEN
    MCU_WriteRtdScsb(LOW);
#endif

    RTDSendAddr(GRN_GAMMA_65, WRITE, N_INC);
    do
    {
        RTDSendByte(arrayG[n]);
    }
    while (++n);
#if(MCU_TYPE == MCU_WINBOND)
    bRTD_SCLK   = 0; 
    bRTD_SCLK   = 1;           
    bRTD_SCSB   = 1;
    
    //GAMMA_BLUE
    bRTD_SCSB   = 0;
#else
    MCU_WriteRtdSclk(LOW); 
    MCU_WriteRtdSclk(HIGH);           
    MCU_WriteRtdScsb(HIGH);
    
    //GAMMA_BLUE
    MCU_WriteRtdScsb(LOW);
#endif
    RTDSendAddr(BLU_GAMMA_66, WRITE, N_INC);
    do
    {
        RTDSendByte(arrayB[n]);
    }
    while (++n);

#if(MCU_TYPE == MCU_WINBOND)
    bRTD_SCLK   = 0; 
    bRTD_SCLK   = 1;           
    bRTD_SCSB   = 1;
#else
    MCU_WriteRtdSclk(_LOW); 
    MCU_WriteRtdSclk(_HIGH);           
    MCU_WriteRtdScsb(_HIGH);
#endif

    
    RTDSetBit(COLOR_CTRL_5D, 0xef, 0x04);   // Enable GAMMA & Diable Access Channel
}

void WriteDither(unsigned char code *array , bit new_dither)
{
    unsigned char   n;
    if(new_dither)
      RTDSetBit(FX_LST_LEN_H_5A,0xff,0x80);
    else
      RTDSetBit(FX_LST_LEN_H_5A,0x7f,0x00);

    RTDSetBit(COLOR_CTRL_5D, 0xb7, 0x68);   // Enable DITHER & Enable Access Channels

#if(MCU_TYPE == MCU_WINBOND)
    bRTD_SCSB   = 0;
    RTDSendAddr(DITHER_PORT_67, WRITE, N_INC);

    for (n = 0; n < 8; n++)     RTDSendByte(array[n]);

    bRTD_SCLK   = 0; 
    bRTD_SCLK   = 1;           
    bRTD_SCSB   = 1;
#else
    MCU_WriteRtdScsb(_LOW);
    RTDSendAddr(DITHER_PORT_67, WRITE, N_INC);

    for (n = 0; n < 8; n++)     RTDSendByte(array[n]);

    MCU_WriteRtdSclk(_LOW); 
    MCU_WriteRtdSclk(_HIGH);           
    MCU_WriteRtdScsb(_HIGH);
#endif
    
    //RTDSetBit(COLOR_CTRL_5D, 0xdf, 0x48);   // Enable DITHER & Disable Access Channels
	RTDSetBit(COLOR_CTRL_5D, 0x1f, 0x88);   // Enable DITHER & Disable Access Channels
}

void WriteSU_COEF(unsigned char code *arrayH, unsigned char code *arrayV)
{
    unsigned char   n;
    


    RTDSetBit(FILTER_CTRL1_1C, 0xfc, 0x01);     // Enable H-Coeff access
#if(MCU_TYPE == MCU_WINBOND)
    bRTD_SCSB   = 0;
    RTDSendAddr(FILTER_PORT_1D, WRITE, N_INC);
    for (n = 0; n < 128; n++)    RTDSendByte(arrayH[n]);

    bRTD_SCLK   = 0; 
    bRTD_SCLK   = 1;           
    bRTD_SCSB   = 1;

    RTDSetBit(FILTER_CTRL1_1C, 0xfc, 0x03);     // Enable V-Coeff access
    
    bRTD_SCSB   = 0;
    RTDSendAddr(FILTER_PORT_1D, WRITE, N_INC);
    for (n = 0; n < 128; n++)    RTDSendByte(arrayV[n]);

    bRTD_SCLK   = 0; 
    bRTD_SCLK   = 1;           
    bRTD_SCSB   = 1;

#else
    MCU_WriteRtdScsb(_LOW);
    RTDSendAddr(FILTER_PORT_1D, WRITE, N_INC);
    for (n = 0; n < 128; n++)    RTDSendByte(arrayH[n]);

    MCU_WriteRtdSclk(_LOW); 
    MCU_WriteRtdSclk(_HIGH);           
    MCU_WriteRtdScsb(_HIGH);

    RTDSetBit(FILTER_CTRL1_1C, 0xfc, 0x03);     // Enable V-Coeff access
    
    MCU_WriteRtdScsb(_LOW);
    RTDSendAddr(FILTER_PORT_1D, WRITE, N_INC);
    for (n = 0; n < 128; n++)    RTDSendByte(arrayV[n]);

    MCU_WriteRtdSclk(_LOW); 
    MCU_WriteRtdSclk(_HIGH);           
    MCU_WriteRtdScsb(_HIGH);

#endif

    RTDSetBit(FILTER_CTRL1_1C, 0xfc, 0xc4);     // Disable filter coefficient access
}

void Set_H_Position(void)
{
#if(AS_NON_FRAMESYNC)
    RTDSetBit(ODD_CTRL_8E,0xef,0x00);
#endif

    // if the backporch is far small then the standard one,
	// it is possibile that even IHS_Delay decrease to zero still can't correct the H position
	// so adjust the usIPH_ACT_STA first and turn back to original value later

    if(stMUD.H_POSITION < ucH_Min_Margin)
    {
       usIPH_ACT_STA = usIPH_ACT_STA - (ucH_Min_Margin - stMUD.H_POSITION);
       stMUD.H_POSITION = ucH_Min_Margin;
    }

#if(ALIGN_LEFT == CLOCK_ALIGN)
    ((unsigned int*)Data)[4] = usIPH_ACT_STA + (stMUD.CLOCK >> 2) - 32;
#else
    ((unsigned int*)Data)[4] = usIPH_ACT_STA + (stMUD.CLOCK >> 1) - 64;
#endif


    Wait_For_Event(EVENT_IEN_STOP);
        
    Data[0] = 5;
    Data[1] = Y_INC;
    Data[2] = IPH_ACT_STA_06;
    Data[3] = (unsigned char)((unsigned int*)Data)[4];
    Data[4] = (unsigned char)(((unsigned int*)Data)[4] >> 8);
    Data[5] = 0;    
    RTDWrite(Data);

    // Update IHS delay according to phase
//    Set_Phase(stMUD.PHASE & 0x7c);
    //Data[0]     = PROGRAM_HDELAY + (stMUD.H_POSITION - ucH_Min_Margin);
     Data[12] = (stMUD.H_POSITION - ucH_Min_Margin) + PROGRAM_HDELAY;
	
	RTDSetByte(IHS_DELAY_8D, Data[12]);
   

#if(AS_NON_FRAMESYNC)
    if(bFrameSync && bStable)
        RTDSetBit(ODD_CTRL_8E,0xef,0x10);
#endif
}

#if(PANEL_TYPE == PANEL_HYUNDAI)		//hgxxxx 0522 for Hyundai
#define MAX_MOVE_LINE	2
bit	bSTEP_VPOS	= 0;
static unsigned char idata ucPre_V_POS = 0x80;
void Set_V_Position4HD(void);

void Set_V_Position(void)
{
	unsigned char tempstore;
	tempstore = stMUD.V_POSITION;
	bSTEP_VPOS = 1;
    do
	{
		if(stMUD.V_POSITION > ucPre_V_POS)
		{
			if(stMUD.V_POSITION - ucPre_V_POS > MAX_MOVE_LINE)
				stMUD.V_POSITION = ucPre_V_POS + MAX_MOVE_LINE;
		}
		else
		{
			if(ucPre_V_POS - stMUD.V_POSITION > MAX_MOVE_LINE)
				stMUD.V_POSITION = ucPre_V_POS - MAX_MOVE_LINE;
		}
		Set_V_Position4HD();
		stMUD.V_POSITION = tempstore;
	}
	while(stMUD.V_POSITION != ucPre_V_POS);
	bSTEP_VPOS = 0;
}

void Set_V_Position4HD(void)
#else
void Set_V_Position(void)
#endif

{
    unsigned int    usIV_Temp, usDV_Temp;


#if(AS_NON_FRAMESYNC)
    RTDSetBit(ODD_CTRL_8E,0xef,0x00);
#endif

#if(AS_DV_TOTAL)
    RTDSetBit(DV_BKGD_STA_31,0x7f,0x00);
#endif

    if ((ucV_Max_Margin - 1)  < stMUD.V_POSITION)
    {
       
        RTDSetByte(IVS_DELAY_8C, (PROGRAM_VDELAY + stMUD.V_POSITION - (ucV_Max_Margin - 1)));


        usIV_Temp   = usIPV_ACT_STA + (ucV_Max_Margin - 1) - 128;
        usDV_Temp   = (unsigned int)ucDV_Delay + (ucV_Max_Margin - 1) - 128;
    }
    else
    {

        RTDSetByte(IVS_DELAY_8C, PROGRAM_VDELAY);


        usIV_Temp   = usIPV_ACT_STA + stMUD.V_POSITION - 128;
        usDV_Temp   = (unsigned int)ucDV_Delay + stMUD.V_POSITION - 128;
    }

    Wait_For_Event(EVENT_IEN_START);

    Data[0] = 4;
    Data[1] = N_INC;
    Data[2] = IV_DV_LINES_38;
    Data[3] = (unsigned char)usDV_Temp;
    Data[4] = 5;    
    Data[5] = Y_INC;
    Data[6] = IPV_ACT_STA_0A;
    Data[7] = (unsigned char)usIV_Temp;

⌨️ 快捷键说明

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