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

📄 t100_old.c

📁 TFT 驱动 T100DEMO程序.做protable DVD的朋友可以参考一下.
💻 C
📖 第 1 页 / 共 2 页
字号:
{
	uCHAR cAddr,cReg,cNum0,cNum1,cINC;
  while(*pString != EOT)
  {
		cAddr	=	*pString++;
		cNum0	=	*pString++;
		while(cNum0)
		{
			cReg	=	*pString++;
			cNum1	=	*pString++;
			cNum0  -=	(cNum1+2);
			if(cNum1!=1)
			{
				cINC	=	*pString++;
				cNum1  -=	1;
			}
			while(cNum1--)
			{
				I2CWriteByte(cAddr,cReg,*pString++);
				cReg+=cINC;
			}
		}
  }
}
uCHAR Repeat_Times;
void KeyFunction(uCHAR cTemp)
{
                        switch(cTemp)
                        {
                                case kyFULL_43://0x40
           		                bFULL_43=!bFULL_43;
				        SetMode();
						if(!bFULL_43)I2CWriteByte(0x50,0xe0,0x00);
						else I2CWriteByte(0x50,0xe0,0x9d);
                                        Repeat_Times=0xff;
                                        Delay_ms(50);
                                        break;
                                case kyUD_LR://0x20
									if(bUP_DOWN&bLEFT_RIGHT)
									{
										bUP_DOWN=0;
										bLEFT_RIGHT=0;
									}
									else if(bUP_DOWN&!bLEFT_RIGHT)
									{
										bUP_DOWN=1;
										bLEFT_RIGHT=1;
									}
									else if(!bUP_DOWN&bLEFT_RIGHT)
									{
										bUP_DOWN=1;
										bLEFT_RIGHT=0;
									}
									else if(!bUP_DOWN&!bLEFT_RIGHT)
									{
										bUP_DOWN=0;
										bLEFT_RIGHT=1;
									}

                                         SetUD_LR();
                                        Repeat_Times=0xff;
										I2CWriteByte(0x50,0xe0,0x8d);
                                        Delay_ms(50);
                                        break;
                                case kySOURCE://0x10
				        cSource++;
				        if(cSource>6)cSource=3;
				        SetSource();
				        SetMode();
                                        Repeat_Times=0xff;
                                        Delay_ms(50);
                                        break;
#ifdef OSD_EN
                                case kyMENU://0x08
                                        cOSDFunc+=1;
                                        if(cOSDFunc>3)cOSDFunc=0;
                                        OSDCtrl(0);
                                        Repeat_Times=0xff;
                                        break;
                                case kyDEC://0x04
                                        OSDCtrl(-1);
                                        if(Repeat_Times==0xff)Repeat_Times=5;
                                        else Repeat_Times=0;
                                        break;
                                case kyINC://0x02
                                        OSDCtrl(1);
                                        if(Repeat_Times==0xff)Repeat_Times=5;
                                        else Repeat_Times=0;
                                        break;
                                default:  Repeat_Times=0xff;
#endif
                        }

}
void kyKeypad(void)
{
	cKey_Curr =0xff -( KEYPORT | kyKEY_MSK );
        if((cKey_Curr!=cKey_Pre)|(Repeat_Times==0))
        {
			cKey_Pre =  cKey_Curr;
			KeyFunction(cKey_Curr);
/*                        switch(cKey_Curr)
                        {
                                case kyFULL_43://0x40
           		                bFULL_43=!bFULL_43;
				        SetMode();
						if(!bFULL_43)I2CWriteByte(0x50,0xe0,0x00);
						else I2CWriteByte(0x50,0xe0,0x9d);
                                        Repeat_Times=0xff;
                                        Delay_ms(50);
                                        break;
                                case kyUD_LR://0x20
                                         SetUD_LR();
                                        Repeat_Times=0xff;
										I2CWriteByte(0x50,0xe0,0x8d);
                                        Delay_ms(50);
                                        break;
                                case kySOURCE://0x10
				        cSource++;
				        if(cSource>6)cSource=3;
				        SetSource();
				        SetMode();
                                        Repeat_Times=0xff;
                                        Delay_ms(50);
                                        break;
#ifdef OSD_EN
                                case kyMENU://0x08
                                        cOSDFunc+=1;
                                        if(cOSDFunc>3)cOSDFunc=0;
                                        OSDCtrl(0);
                                        Repeat_Times=0xff;
                                        break;
                                case kyDEC://0x04
                                        OSDCtrl(-1);
                                        if(Repeat_Times==0xff)Repeat_Times=5;
                                        else Repeat_Times=0;
                                        break;
                                case kyINC://0x02
                                        OSDCtrl(1);
                                        if(Repeat_Times==0xff)Repeat_Times=5;
                                        else Repeat_Times=0;
                                        break;
                                default:  Repeat_Times=0xff;
#endif
                        }//*/
/*			if(!kyFULL_43)	//P0^6
			{
           		bFULL_43=!bFULL_43;
				SetMode();
			}
			if(!kyUD_LR)	//P0^5
				SetUD_LR();
			if(!kySOURCE)	//P0^4
			{
				cSource++;
				if(cSource>6)cSource=2;
				SetSource();
				SetMode();
			}
/*				P0	 = 0xff;
				cKey_Curr = 0xff -( P0 | 0x8F );*/
			//Delay_ms(2);
        }
        else if(cKey_Curr&0x06){Repeat_Times-=1;Delay_ms(2);}

}
#ifdef OSD_EN
void OSDShowLine(uCHAR *string,uCHAR x,uCHAR y,uCHAR cColor);
void OSDDrawGauge(uCHAR cVal, uCHAR cMax, uCHAR x, uCHAR y, uCHAR cColor);
void LoadFont(void);
void LoadMenu(void);
void ShowOSDData(void);
void LoadData(void);
void SaveData(void);
void InitOSD(void)
{
    LoadFont();
    LoadMenu();
    LoadData();
    ShowOSDData();
    OSDDisable();
}
void LoadFont(void)
{
	unsigned int i;
        StartCondition();
        Send_Byte(0x50);
        Send_Byte(0xA4);
        for(i=0; i<55*18; i++){
        	Send_Byte(font_00[2*i]);
   	        Send_Byte(font_00[2*i+1]);
	       }
   //0xc00==1024*3;
	for(; i<0xc00; i++){
   	        Send_Byte(0x00);
                Send_Byte(0x00);
	}//*/
 	StopCondition();
}
void LoadMenu(void)
{
    uCHAR i;
    for(i=0;i<36;i++)
    {
        OSDShowLine(iBlankLine,0,i,COL_NORMAL);
    }
        OSDShowLine(iBright_E,1,0,COL_NORMAL);
        OSDShowLine(iBright_F,1,6,COL_NORMAL);
        OSDShowLine(iBright_G,1,12,COL_NORMAL);
        OSDShowLine(iBright_S,1,18,COL_NORMAL);
        OSDShowLine(iBright_J,1,24,COL_NORMAL);
        OSDShowLine(iBright_R,1,30,COL_NORMAL);

        OSDShowLine(iColor_E,1,2,COL_NORMAL);
        OSDShowLine(iColor_F,1,8,COL_NORMAL);
        OSDShowLine(iColor_G,1,14,COL_NORMAL);
        OSDShowLine(iColor_S,1,20,COL_NORMAL);
        OSDShowLine(iColor_J,1,26,COL_NORMAL);
        OSDShowLine(iColor_R,1,32,COL_NORMAL);

        OSDShowLine(iScreen_E,1,4,COL_NORMAL);
        OSDShowLine(iScreen_F,1,10,COL_NORMAL);
        OSDShowLine(iScreen_G,1,16,COL_NORMAL);
        OSDShowLine(iScreen_S,1,22,COL_NORMAL);
        OSDShowLine(iScreen_J,1,28,COL_NORMAL);
        OSDShowLine(iScreen_R,1,34,COL_NORMAL);

        OSDShowLine(iScreen_E,1,5,COL_NORMAL);
        OSDShowLine(iScreen_F,1,11,COL_NORMAL);
        OSDShowLine(iScreen_G,1,17,COL_NORMAL);
        OSDShowLine(iScreen_S,1,23,COL_NORMAL);
        OSDShowLine(iScreen_J,1,29,COL_NORMAL);
        OSDShowLine(iScreen_R,1,35,COL_NORMAL);

        OSDShowLine(iNormal_E,LINE_LENGTH-6,4,COL_NORMAL);
        OSDShowLine(iNormal_F,LINE_LENGTH-6,10,COL_NORMAL);
        OSDShowLine(iNormal_G,LINE_LENGTH-6,16,COL_NORMAL);
        OSDShowLine(iNormal_S,LINE_LENGTH-6,22,COL_NORMAL);
        OSDShowLine(iNormal_J,LINE_LENGTH-6,28,COL_NORMAL);
        OSDShowLine(iNormal_R,LINE_LENGTH-6,34,COL_NORMAL);

        OSDShowLine(iEnhanced_E,LINE_LENGTH-8,5,COL_NORMAL);
        OSDShowLine(iEnhanced_F,LINE_LENGTH-8,11,COL_NORMAL);
        OSDShowLine(iEnhanced_G,LINE_LENGTH-8,17,COL_NORMAL);
        OSDShowLine(iEnhanced_S,LINE_LENGTH-8,23,COL_NORMAL);
        OSDShowLine(iEnhanced_J,LINE_LENGTH-8,29,COL_NORMAL);
        OSDShowLine(iEnhanced_R,LINE_LENGTH-8,35,COL_NORMAL);//*/
}
void ShowOSDData(void)
{
    uCHAR i;
    switch(cOSDFunc)
    {
        case 1:
                for(i=0;i<6;i++)
                  OSDDrawGauge(cBright,0xfc,0,i*6+1,COL_GAUGE);
                break;
        case 2:
                for(i=0;i<6;i++)
                  OSDDrawGauge(cColor,0xfc,0,i*6+3,COL_GAUGE);
                break;
        case 3: break;
        }
}

void OSDSetRamAddr(int address)
{
	I2CWriteByte(TW100,0xA3,(uCHAR)(address>>8));
  	I2CWriteByte(TW100,0xA2,(uCHAR)(address & 0xff));
}
void OSDShowLine(uCHAR *string,uCHAR x,uCHAR y,uCHAR cColor)
{
	if((x < 30) && ( y < 0x28))
  	{
	OSDSetRamAddr(MENU_START_ADDR+((int)y << 5)+x);
        StartCondition();
        Send_Byte(0x50);
        Send_Byte(0xA4);
     	while((*string) != EOL && (x < LINE_LENGTH))
     	{
     		Send_Byte(*string++);
        	Send_Byte(cColor );
        	x++;
  		}
   	StopCondition();
	}
}

void OSDDrawGauge(uCHAR cVal, uCHAR cMax, uCHAR x, uCHAR y, uCHAR cColor)
{
     uCHAR cTemp1,cTemp2,i=LINE_LENGTH;
     int wTemp,wTemp1,wTemp2;
     wTemp1=cVal;
     wTemp2=cMax;
     wTemp=(int)((wTemp1*LINE_LENGTH*3)/wTemp2);
     cTemp1=wTemp/3;
     cTemp2=wTemp%3;
     OSDSetRamAddr(MENU_START_ADDR+((int)y << 5)+x);
        StartCondition();
        Send_Byte(0x50);
        Send_Byte(0xA4);
     while(i)
     {
        if(cTemp1==0)
        {
          if(i==LINE_LENGTH)Send_Byte(0x04+cTemp2);
          else if(i==1)Send_Byte(0x0c+cTemp2);
          else Send_Byte(0x08+cTemp2);
         Send_Byte(cColor);
          i--;
          break;
         }
         else
         {
          if(i==LINE_LENGTH)Send_Byte(0x07);
          else if(i==1)Send_Byte(0x0f);
          else Send_Byte(0x0B);
         }
         Send_Byte(cColor);
         cTemp1--;
         i--;
      }
      while(i)
      {
         if(i>1)Send_Byte(0x08);
         else   Send_Byte(0x0c);
         Send_Byte(cColor);
         i--;
      }
      StopCondition();
      //Num
     wTemp=(int)((wTemp1*NUM_MAX)/wTemp2);
     i=wTemp/100;
     cTemp1=(wTemp%100)/10;
     cTemp2=wTemp%10;
/*     i=cVal/100;
     cTemp1=(cVal%100)/10;
     cTemp2=cVal%10;//*/
     OSDSetRamAddr(MENU_START_ADDR+((int)(y-1) << 5)+(LINE_LENGTH-3));
        StartCondition();
        Send_Byte(0x50);
        Send_Byte(0xA4);
        if(i)Send_Byte(i+0x10);
        else Send_Byte(BLANK);
         Send_Byte(cColor);
         if(!i&&!cTemp1)Send_Byte(BLANK);
         else Send_Byte(cTemp1+0x10);
         Send_Byte(cColor);
        Send_Byte(cTemp2+0x10);
         Send_Byte(cColor);
      StopCondition();

}
void  OSDDisable(void)
{
   I2CWriteTbl(OSDDisableTbl);
}
void OSDEnable(void)
{
   uCHAR cTemp[8];
   cTemp[0]=TW100;
   cTemp[1]=5;
   cTemp[2]=0xa0;
   cTemp[3]=3;
   cTemp[4]=Y_INC;
   cTemp[5]=0x05;
   cTemp[6]=0x38+cLanguage*6+(cOSDFunc-1)*2;
   if((cOSDFunc==3)&&bFULL_43)cTemp[6]+=1;
   cTemp[7]=EOT;
   I2CWriteTbl(cTemp);
   cTemp[5]=0x1E;
   cTemp[6]+=1;
   if(cOSDFunc==3)cTemp[6]-=1;
   I2CWriteTbl(cTemp);
   I2CWriteTbl(OSDEnableTbl);
}
void OSDCtrl(char cDir)
{
        switch(cOSDFunc)
        {
                case 0: OSDDisable();return;
                case 1:
                      if((cBright==0xfc)&&(cDir==1))return;
                      if((cBright==0x00)&&(cDir==-1))return;
                      cBright+=cDir*4;
                      I2CWriteByte(TW100,0x69,cBright);
                      break;
                case 2:
                      if((cColor==0xfc)&&(cDir==1))return;
                      if((cColor==0x00)&&(cDir==-1))return;
                      cColor+=cDir*4;
                      I2CWriteByte(TW100,0x6c,cColor);
                      break;
                case 3:
                      if(Repeat_Times==0)return;
                      if(cDir)
                      {
                          bFULL_43=!bFULL_43;
                          SetMode();
                       }
                      break;
        }
        SaveData();
        ShowOSDData();
        OSDEnable();
}


void LoadData(void)
{
#ifdef NVRAM

#else
        cBright=BRIGHT;
        cColor=COLOR;
#endif
}
void SaveData(void)
{
#ifdef NVRAM

#endif
}
#endif
bit m_bBKPowerOn		=1;
bit m_bKyPowerOn 		=1;
bit m_bChipPowerOn		=1;
void PowerManage(void)
{
 	if(m_bKyPowerOn) //Power on
	{
		I2CWriteByte(TW100, 0xE0, I2CReadByte(TW100, 0xE0)|0x80);
		//When power on chip, force to reset chip
		m_bChipPowerOn=1;
		Delay_ms(50);
		OpenPanel();
 			if(!m_bBKPowerOn)
					BL_EN=0;
// 				BKPower();
	}
	else 	//Forced Power Off
	{
		if(m_bChipPowerOn)
		{
			Delay_ms(50);
 			if(m_bBKPowerOn)
				BL_EN=1;
// 				BKPower();
			ClosePanel();
			Delay_ms(100);
			I2CWriteByte(TW100, 0xE0, I2CReadByte(TW100, 0xE0)&0x7F);
			m_bChipPowerOn=0;
		}
	}
}

⌨️ 快捷键说明

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