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

📄 t100.c

📁 在51单片机上用C写的T100,T101TFT屏的控制程序,有OSD
💻 C
📖 第 1 页 / 共 4 页
字号:

	/************************************/
	/*   Detect 16 bit address code     */
	/************************************/
	if(ir_enable==TRUE)
	{
		TMOD=0x11;           /*counter start with INT0 and TR0*/
		ir_code=0;		/*初始化变量*/
		for(i=0;i<16;i++)
		{
			while(INT1==0);
			TL0=0;
			TH0=0;
			TR0=1;
			do
			{
				count=(TL0+TH0*256);   /*count :us unit */
				if(Filter13(0)==1) break;
			}while(count<=(CODE_1_TIME+DELTA));	/*INT0为高电平时计时*/
			TR0=0;

			//ir_code<<=1;

			if((count>(CODE_1_TIME-DELTA))&&(count<=(CODE_1_TIME+DELTA)))  /*detect 1 code  2.24mS-0.56mS=1.68mS*/
				ir_code|=mask; //ir_code++;
			else if((count>(CODE_0_TIME-DELTA))&&(count<=(CODE_0_TIME+DELTA)));  /*detect 0 code 1.12mS-0.56mS=0.56mS*/
			else
			{
			 	ir_enable=FALSE;
				TR0=1;
				break;           /*not suitable for address code */
			}
                        mask<<=1;
		}                /*end for*/
	}
	/************************************/
	/*   Detect 16 bit data code        */
	/************************************/
	if(ir_enable==TRUE&&~ir_code==IR_SYSTEM_CODE)/**/
	{
		TMOD=0x11;           /*counter start with INT0 and TR0*/
                mask=1;
                ir_code=0;
		for(i=0;i<16;i++)
		{
			while(INT1==0);
			TL0=0;
			TH0=0;
			TR0=1;
			do
			{
				count=(TL0+TH0*256);
				if(Filter13(0)==1) break;
			}while(count<=(CODE_1_TIME+DELTA));	/*INT0为高电平时计时*/
			TR0=0;
			//count=(TL0+TH0*256);   /*count :us unit */
			//ir_code<<=1;
			if((count>(CODE_1_TIME-DELTA))&&(count<=(CODE_1_TIME+DELTA)))  /*detect 1 code 1.68mS*/
				ir_code|=mask; //ir_code++;
			else if((count>(CODE_0_TIME-DELTA)&&count<=(CODE_0_TIME+DELTA)));  /*detect 0 code 0.56mS*/
			else
			{
				ir_enable=FALSE;
				TR0=1;
				break;           /*not suitable for address code */
			}
                        mask<<=1;
		}                /*end for*/
		if(ir_enable==TRUE)
		{

			temp0=ir_code&0xff00;
			temp0=~temp0;
			temp0>>=8;
			temp1=ir_code&0x00ff;
			if(temp0!=temp1)
				ir_enable=FALSE;
			else
			{
				ir_data=(BYTE)(temp1);     /*true code effective*/
//                                ir_data=(BYTE)(temp0);
				ir_enable=TRUE;            /*set ir flag*/
				EX1=0;
				return;
			}
		}
	}
	else
	{	ir_enable=FALSE;
	EX1=1;}
}
void RemoteEvent(void)
{
	bit bTemp=0;
	switch(ir_data)
	{
	    case LEFT  : left=1;
	                 break;

  	    case RIGHT : right=1;
	                 break;

	    case DOWN  : down=1;
	                 break;

            case UP    : up=1;
	                 break;

            case ENTER : enter=1;
	                 break;

            case OSD   : osd=1;

	    default    : break;
        }

        if((window==SUB1_D) && ((cursor1==VIDEO) && (cursor2!=V_SHARP))
                    || ((cursor1==AUDIO) && (cursor2==A_VOL)) )
        {
            EX1=1;

        }
       	else
       	{
	    EX1=0;
	}

}
/*bit IRGammaAdjust(void)
{

	 switch(m_cOSDFunc)
	{
	      case 0:
	                m_cOSDFunc=idGammaAdjust;
	                m_cOSDEvent=GammaAdjust;
	                break;
	      case idGammaAdjust:
                        m_cOSDFunc=0;
                        bGAMMA_ADJ=0;
                        m_cOSDEvent=FUNCEXIT;
                        break;
             default:
                        m_cOSDFunc=0;
                        bGAMMA_ADJ=0;
                        m_cOSDEvent=FUNCEXIT;
                        break;
                        break;

        }
	      return 1;


}*/
/*void IRSourceSelCtrl(void)
{

        if(cSource>=5)cSource = 1; //Kuo
        cSource++;
        ClosePanel();
	//I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_SOURCE_INDEX,m_cSource);
	SetSource();
	SetMode();
	Delay_ms(25);
	OpenPanel();
	//OSDShowSource();
//	return 1;
}*/
/*void IRSCALEREvent(void)
{
       bFULL_43=!bFULL_43;
       SetMode();
       Delay_ms(25);
       OpenPanel();
//   OSDShowRatio();
   //return 1;
}*/
/*void IRDismodeEvent(void)
{
        uCHAR cTemp;
	if(bUP_DOWN&bLEFT_RIGHT)
	{
	  bUP_DOWN= 1;      //0:Down to Up 	1:Up to Down
          bLEFT_RIGHT= 0;      //0:Right to Left     1:Left to Right
	  cTemp=UD_LR;
	}
	else if(bUP_DOWN&!bLEFT_RIGHT)
	{
	   bUP_DOWN= 0;      //0:Down to Up 	1:Up to Down
           bLEFT_RIGHT= 1;
	   cTemp=UD_RL;
	}
	else if(!bUP_DOWN&bLEFT_RIGHT)
	{
	   bUP_DOWN= 0;      //0:Down to Up 	1:Up to Down
           bLEFT_RIGHT= 0;
	   cTemp=DU_LR;
	}
	else if(!bUP_DOWN&!bLEFT_RIGHT)
	{  bUP_DOWN= 1;      //0:Down to Up 	1:Up to Down
           bLEFT_RIGHT= 1;
	   cTemp=DU_RL;
	}
	I2CWriteByte(TW100,0xe1,cTemp);
}*/
/*bit IRMENUEvent(void)
{
	switch(m_cOSDFunc&0xf0)
	{
	      case 0:
	                m_cOSDFunc=idMainMenu;
	                m_cOSDEvent=OPENMENU;
	                break;
	      case idMainMenu :
	      case idGammaAdjust:
                        m_cOSDFunc=0;
                        m_cOSDEvent=FUNCEXIT;
                        break;
        }
	      return 1;
}*/
/*bit IRINCREASEEvent(void)
{
        m_cOSDEvent=FUNCADJ_IN;
	return 1;
}*/
/*
bit IRDECREASEEvent(void)
{
	m_cOSDEvent=FUNCADJ_DN;
	return 1;
}*/
/*bit IRUpKeyCtrl(void)
{
          if(((m_cOSDFunc&0xF0)==idMainMenu)||(m_cOSDFunc==idGammaAdjust))
            { m_cOSDEvent=FUNCSELCT_IN; return 1;}
          else  return 0;
}

bit IRDownKeyCtrl(void)
{
        if(((m_cOSDFunc&0xF0)==idMainMenu)||(m_cOSDFunc==idGammaAdjust))
          { m_cOSDEvent=FUNCSELCT_DN; return 1; }
	else  return 0;
}
*/
/*void SaveEeprom(void)  //Save Gammma Data to EEPBLOCK1
{
	uCHAR i;
	uCHAR c;

	for(i=0;i<GAMMA_TABLE_DATA_SIZE;i++) {
		c=GAMMAData[i+8];
		I2CWriteByte(EEPBLOCK1,i,c);
		twdDelay(NVRDELAY);
	}
	I2CWriteByte(EEPBLOCK0,0x10,0xa3);
}
*/
/*void AdjustGammmaDate(void)
{
	uCHAR i;
	uCHAR c;
	if(bGAMMA_ADJ==1){
	        I2CWriteByte(EEPBLOCK1,AddPoint,GammaBuffer);
	     }
	I2CWriteByte(TW100,IMG_FUN_CTRL,I2CReadByte(TW100,IMG_FUN_CTRL)&GAMMA_RGB);
  	I2CWriteByte(TW100,GAMMA_ADDR,0x00);

  	for(i=0;i<GAMMA_TABLE_DATA_SIZE;i++) {
		c=I2CReadByte(EEPBLOCK1,i);
		twdDelay(NVRDELAY);
		I2CWriteByte(TW100,GAMMA_DATA,c);
		twdDelay(NVRDELAY);
	}
}*/





///////////////////////////////////////////////
//       OSD

void KSP7001_Init(void)
{
    OSD_enable = 0;
//display timer
    OSD_time=0;
//cursor
 //   modify = 0;
    window = MAIN_D;
    cursor1 = SOURCE;
    cursor2 = 0;
    reset_valid=0;
    //Value default
    KSP7001_Default();

}

void KSP7001_Default(void)
{
    uCHAR video_set;

//source
    CurMode = MODE_TUNER;
//audio
    Aud_BassLevel=7; //0(-7)->14(+7)
    Aud_TrebleLevel=7; //0(-7)->14(+7)
    Aud_BalanceLevel=7; //0(L7)->14(R7)
    Aud_FaderLevel=7; //0(F7)->14(R7)

                  //subwoofer=0; //subwoofer off
                  //beep=1;  //beep on
    AudioStatus = AUDIO_STS_BEEP_EN;

    Aud_IniVol=49; //0->50
//video
    bright=25;
    video_set = (bright-1) * 5 + 7;
    I2CWriteByte(TW100,VBRIGHT,video_set);
    contrast=25;
    video_set = (contrast-1) * 5 + 7;
    I2CWriteByte(TW100,VCONTRAST,video_set);
    color=25;
    video_set = (color-1) * 5 + 7;
    I2CWriteByte(TW100,VCOLOR,video_set);
    sharp=3;
    video_set = sharp*2 + 1;
    I2CWriteByte(PAGE2_ADDR,VSHARP,video_set);
//screen
    VideoStatus&=~PIC_INVERSE; //direction=0; //0 normal, 1 inv
    if(VideoStatus&PIC_INVERSE)
    {
        bUP_DOWN = 0;
        bLEFT_RIGHT = 0;
    }
    else
    {
        bUP_DOWN = 1;
        bLEFT_RIGHT = 1;
    }
    SetUD_LR();

    VideoStatus|=SCREEN_FULL; //full=1; //16:9
    if(VideoStatus&SCREEN_FULL) bFULL_43 = 1; //1: FULL
    else bFULL_43 = 0; //0: 4:3
    SetMode();

//system
    //tilt=0; //tilt auto
    TiltFlag0|=TILT_AUTO; //tilt auto
    
    MinoutState = INOUT_NONE; //in_out=0; //0 none, 1 level-1,
              //2 level-2, 3 level-3
    TiltLimit = ANGLE_AUTO; //tilt_range=0; //0 auto, 1 1-3,
                  //2 1-4, 3 1-5

    ChannelType=TV_NTSC; //0 NTSC, 1 PAL, 2 CHINESE
    PalType=PAL_DK;  //3 sound-3, 2 sound-2, 1 sound-1
    VideoStatus&=~ILL_BRIGHT; //backlight off
}

void OSD_UpDown(void)
{
    unsigned char max;


    if(window==MAIN_D)  //OSD main menu
    {
    	                                //  main menu map :
        if(up)                          //      5 4 3
        {                               //      2 1 0
            if(cursor1<3)
            {
                OSD_UpdateMain(1); //clean cursor
                cursor1+=3;
                OSD_UpdateMain(0); //display cursor
            }
        }
        else if(down)
        {
            if(cursor1>2)
            {
                OSD_UpdateMain(1); //clean cursor
                cursor1-=3;
                OSD_UpdateMain(0); //display cursor
            }
        }

    }
    else if(window==SUB1_D) //OSD sub_menu
    {
    	//clean old cursor
        switch(cursor1)
        {
            case SYSTEM : max = SYS_MAX; //system menu
                          OSD_UpdateSystem(1);
                          break;
            case SCREEN : max = SCR_MAX; //screen menu
                          OSD_UpdateScreen(1);
                          break;
            case VIDEO  : max = VIDEO_MAX; //video menu
                          OSD_UpdateVideo(1);
                          break;
            case AUDIO  : max = AUDIO_MAX; //audio menu
                          OSD_UpdateAudio(1);
                          break;
            case SOURCE : max = SCE_MAX; //source menu
                          OSD_UpdateSource(1);
                          break;

            default     : OSDExit();
                          OSD_enable = 0;
                          break;
        }

        //move cursor
        if(up)
        {
            if(cursor2==max) cursor2=0;
            else cursor2++;
        }
        else
        {
            if(cursor2==0) cursor2=max;
            else cursor2--;
        }

        //display new cursor
        switch(cursor1)
        {
            case SYSTEM : if(!(CurMode&MODE_TV))
                          {
                              if((cursor2==TV_PICTURE)||(cursor2==TV_SOUND))
                              {
                                  if(up) cursor2 = RANGE;
                                  else cursor2 = BLIGHT;
                              }
                          }
                          else if((cursor2==TV_SOUND)&&(ChannelType==TV_NTSC))
                          {
                              if(up) cursor2 = TV_PICTURE;
                              else cursor2 = BLIGHT;
                          }

                          OSD_UpdateSystem(0);
                          break;
            case SCREEN : if((cursor2==SCR_FULL)&&(VideoStatus&SCREEN_FULL))
                          {
                              if(up) cursor2 = SCR_PICTURE;
                              else cursor2 = SCR_NORMAL;
                          }
                          else if((cursor2==SCR_NORMAL)&&!(VideoStatus&SCREEN_FULL))
                          {
                              if(up) cursor2 = SCR_FULL;
                              else cursor2 = EXIT;
                          }
                          OSD_UpdateScreen(0);
                          break;
            case VIDEO  : OSD_UpdateVideo(0);
                          break;
            case AUDIO  : OSD_UpdateAudio(0);
                          break;
            case SOURCE : OSD_UpdateSource(0);
                          break;

            default     : OSDExit();
                          OSD_enable = 0;
                          break;
        }

    }
    up = 0;
    down = 0;
    OSD_time=0;

}

void OSD_LeftRight(void)
{
    if(window==MAIN_D) //OSD main menu
    {                      //  main menu map :
                           //      5 4 3

⌨️ 快捷键说明

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