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

📄 osddraw.c

📁 宏芯T102芯片驱动(51单片机作主控)
💻 C
📖 第 1 页 / 共 3 页
字号:
//				OSDShowOption(y,COL_NORMAL);
//				break;
//			case INFO:
//				OSDShowInfo(0,(cTotal+1),COL_GAUGE);
//				break;
			case NONE:
			default:
				break;
		}
		cTotal++;
		y++;
	}
	OSDShowLine(iBlankLine,0,y++,COL_NORMAL,OSD_LENGTH);
	OSDShowLine(iBlankLine,0,y,COL_NORMAL,OSD_LENGTH);
	
	OSDMoveCursor(0x00,0x00);
}

void OSDShowChinesePage(void)
{
uCHAR y=1;


	pOSDChineseLangPtr=&MultiChineseLangOSD[0];
	pOSDChineseMenuPtr=pOSDChineseLangPtr->osdChineseMenuPtr;  
	cTotal=0;

	while(pOSDChineseMenuPtr[m_cOSDMenu-1][cTotal].iconStr!=NULL)
	{
		OSDShowLine(iBlankLine,0,y,COL_NORMAL,OSD_LENGTH);
		OSDShowLine(pOSDChineseMenuPtr[m_cOSDMenu-1][cTotal].txtStr,TXT_STAT,y,COL_NORMAL,OSD_LENGTH);
		switch (pOSDChineseMenuPtr[(m_cOSDMenu-1)-1][cTotal].cDataAttr)
		{
			case GAUGE:
			case NUMBER:
				break;			
			case NONE:
			default:
				break;
		}
		cTotal++;
		y++;
	}
	OSDShowLine(iBlankLine,0,y++,COL_NORMAL,OSD_LENGTH);
	OSDShowLine(iBlankLine,0,y,COL_NORMAL,OSD_LENGTH);
	
	OSDMoveChineseCursor(0x00,0x00);
}

void OSDShowLine(uCHAR *string,uCHAR x,uCHAR y,uCHAR cColor,uCHAR cLength)
{
 uCHAR c;
	if((x < 30) && ( y < OSD_LINE_NUM))
  	{
		OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)y << 5)+x);//store the data into the register
     	twdWr_Burst_A(OSD_RAM_DL);      // Write OSD index
     	while((*string) != EOL && (x < cLength))
     	{
		    c=*string++;
		    if(c>0x40)
     		  twdWr_Burst_D(c-0x36);
			else if(c>=0x30)
    		  twdWr_Burst_D(c-0x2F);
			else
			  twdWr_Burst_D(c);
        	twdWr_Burst_D(cColor );
        	x++;
  		}
	}
   	twdWr_Burst_P();
}


void OSDCleanLine(uCHAR x,uCHAR y,uCHAR cColor,uCHAR cLength)
{
	if((x < 30) && ( y < OSD_LINE_NUM))
  	{
  		OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)y << 5)+x);
     	twdWr_Burst_A(OSD_RAM_DL);      // Write OSD index
     	while((x < 30) && (x < cLength))
     	{
     		twdWr_Burst_D(BLANK);
        	twdWr_Burst_D(cColor);
        	x++;
     	}
     	twdWr_Burst_P();
	}
}

void OSDClearPage(void)
{
	uCHAR i=0;
	for(i=0;i<OSD_LINE_NUM;i++)
  	{
  		OSDCleanLine(0,i,0,30);
     	OSDSetLineAttribute(i,0x80);
	}
}

void OSDSetLineAttribute(uCHAR cLine,uCHAR cAttribute)
{
     OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)cLine << 5)+31);
     twdWr_Burst_A(OSD_RAM_DL);      // Write OSD index
     twdWr_Burst_D(0);
     twdWr_Burst_D(cAttribute);
     twdWr_Burst_P();
}



void OSDShowVideoData(void)
{
uCHAR  gauge_y =cTotal+2;
	switch(m_cOSDFunc){
	case idBRIGHTMENU:
		OSDDrawGauge(EepVideo.cBright,V_BRIGHT_MAX,0,7,COL_GAUGE);
		OSDDrawNum(EepVideo.cBright,V_BRIGHT_MAX,NUM_STAT,7,COL_TITLE,DRAW_BLANK|0x03); 
		break;
	case idCONTRASTMENU:
		OSDDrawGauge(EepVideo.cContrast,V_CONTRAST_MAX,0,7,COL_GAUGE);
		OSDDrawNum(EepVideo.cContrast,V_CONTRAST_MAX,NUM_STAT,7,COL_TITLE,DRAW_BLANK|0x03); 
		break;
	case idSHARPMENU:
		OSDDrawGauge(EepVideo.cSharp,V_SHARP_MAX,0,7,COL_GAUGE);
		OSDDrawNum(EepVideo.cSharp,0,NUM_STAT,7,COL_TITLE,DRAW_BLANK|0x03);  
		break;
	case idSATMENU:
		OSDDrawGauge(EepVideo.cSat,V_SAT_MAX,0,7,COL_GAUGE);
		OSDDrawNum(EepVideo.cSat,V_SAT_MAX,NUM_STAT,7,COL_TITLE,DRAW_BLANK|0x03);
		break;
//	case idVOLUMEMENU:
//		OSDDrawGauge(EepVideo.cVolume,V_VOL_MAX,0,7,COL_GAUGE);
//		OSDDrawNum  (EepVideo.cVolume,sOSDParamsMax.cVolume-sOSDParamsMin.cVolume,NUM_STAT,7,0x09,DRAW_BLANK|0x03); 
//		break;
//	case idHUEMENU:
//		OSDDrawGauge(EepVideo.cHue,V_HUE_MAX,0,7, COL_GAUGE);
//		OSDDrawNum(EepVideo.cHue,V_HUE_MAX,NUM_STAT,7,COL_TITLE,DRAW_BLANK|0x03); 
//		break;
	case idLANGUAGEMENU:
//		OSDDrawGauge(EepVideo.cLanguage,2,0,7,COL_GAUGE);
		OSDCleanLine(0,7,0x00,30);
		if(ChangeTime==0)
		{	
			if(m_cLang==L_ENGLISH)
			{
				OSDShowLine(iEnglish,12,5,COL_GAUGE,OSD_LENGTH);
				OSDShowLine(iChinese,20,5,COL_GAUGE,OSD_LENGTH);
				OSDShowLine(iEnglish,12,5,YELLOW_DBLUE,OSD_LENGTH);
			}
			else if(m_cLang==L_CHINESE)	
			{
				OSDShowLine(icEnglish,12,5,COL_GAUGE,OSD_LENGTH);
				OSDShowLine(icChinese,20,5,COL_GAUGE,OSD_LENGTH);
				OSDShowLine(icChinese,20,5,YELLOW_DBLUE,OSD_LENGTH);
			}
		}
		if(ChangeTime>0)
		{
			if(ChangeTime%2==1)
			{
				if(m_cLang==L_ENGLISH)
				{
					OSDShowLine(iEnglish,12,5,COL_GAUGE,OSD_LENGTH);
					OSDShowLine(iChinese,20,5,YELLOW_DBLUE,OSD_LENGTH);
				}
				else if(m_cLang==L_CHINESE)
				{
					OSDShowLine(icEnglish,12,5,YELLOW_DBLUE,OSD_LENGTH);  
					OSDShowLine(icChinese,20,5,COL_GAUGE,OSD_LENGTH);
				}
			}
			else if(ChangeTime%2==0)
			{
				if(m_cLang==L_ENGLISH)
				{
					OSDShowLine(iEnglish,12,5,YELLOW_DBLUE,OSD_LENGTH);
					OSDShowLine(iChinese,20,5,COL_GAUGE,OSD_LENGTH);
				}
				else if(m_cLang==L_CHINESE)
				{
					OSDShowLine(icEnglish,12,5,COL_GAUGE,OSD_LENGTH);  
					OSDShowLine(icChinese,20,5,YELLOW_DBLUE,OSD_LENGTH);
				}
			}
			twdDelay(500);	
		}
			
		break;

#ifdef LOAD_TME
	case idTIMEMENU:
		EepVideo.cB2=I2CReadByte(TW101,0xb2);
		EepVideo.cB8=I2CReadByte(TW101,0xb8);
		OSDDrawNum(EepVideo.cB2,0,NUM_STAT-10,GAUGE_Y,COL_TITLE,DRAW_BLANK|0x03); 
		OSDDrawNum(EepVideo.cB8,0,NUM_STAT,GAUGE_Y,COL_TITLE,DRAW_BLANK|0x03); 
		break;
#endif
	default:	break;
  	}	
}

#ifdef AU_35
#define GAUGE_TOTAL_FONT_L		10  //Long
#else
#define GAUGE_TOTAL_FONT_L		25  //Long
#endif
void OSDDrawGauge(uCHAR cVal, uCHAR cMax, uCHAR x, uCHAR y, uCHAR cColor)
{
int index,i,j;
int step_size=100/GAUGE_TOTAL_FONT_L;
	OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)y<< 5)+x);

	twdWr_Burst_A(OSD_RAM_DL);      // Write OSD index

	index= (int)cVal*GAUGE_TOTAL_FONT_L/(int)cMax;
   
    for(i=0;i<index;i++)
	{
	  twdWr_Burst_D(34);
	  twdWr_Burst_D(cColor);
    }

	j=((int)cVal*100/(int)cMax)-index*step_size;
	j=j/2.5;
	twdWr_Burst_D(j+35);
	twdWr_Burst_D(cColor);

    for(i=index+1;i<GAUGE_TOTAL_FONT_L;i++)
	{
	  twdWr_Burst_D(35);
	  twdWr_Burst_D(cColor);
	}
	twdWr_Burst_P();
	

}

//Maximum three initiger, percentage
void OSDDrawNum(uWORD wVal, uCHAR cMax, uCHAR x, uCHAR y, uCHAR cColor, uCHAR cAttr)
{
	//Init Part
	uCHAR cTemp;
	if(cMax!=0)
	{
		m_wBuff[0]=(unsigned long)wVal*100;
		m_wBuff[0]=m_wBuff[0]/cMax;
  	}
	else //Non percentage
	{
		m_wBuff[0]=wVal;
	}

	if(m_wBuff[0]<10)
		m_cBuff[1]=1;
	else if(m_wBuff[0]<100)
		m_cBuff[1]=2;
	else
    	m_cBuff[1]=3;

	OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)y << 5)+x);
	twdWr_Burst_A(OSD_RAM_DL);      // Write OSD index

	if((cAttr&0xF0)==DRAW_BLANK)
	{
		switch(m_cBuff[1]){
		case 1:
			if((cAttr&0x0F)==3||(cAttr&0x0F)==2)
			{
	  			twdWr_Burst_D(BLANK);
				twdWr_Burst_D(cColor);
			}
		case 2:
			if((cAttr&0x0F)==3)
			{
				twdWr_Burst_D(BLANK);
				twdWr_Burst_D(cColor);
			}
	  	}
	}
	else if((cAttr&0xF0)==DRAW_ZERO)
	{
		switch(m_cBuff[1]){
		case 1:
			if((cAttr&0x0F)==3||(cAttr&0x0F)==2)
			{
	  			twdWr_Burst_D('0'-0x2F);
				twdWr_Burst_D(cColor);
			}
		case 2:
			if((cAttr&0x0F)==3)
			{
				twdWr_Burst_D('0'-0x2F);
				twdWr_Burst_D(cColor);
		   	}
	  	}
	}


	while(m_cBuff[1]>0)
	{
		if(m_cBuff[1]==3)
			cTemp=m_wBuff[0]/100;
		else if(m_cBuff[1]==2)
			cTemp=(m_wBuff[0]%100)/10;
		else if(m_cBuff[1]==1)
			cTemp=m_wBuff[0]%10;

		OSDNumConvert(cTemp);
    	twdWr_Burst_D(cColor );
		m_cBuff[1]--;
	}
  	twdWr_Burst_P();
}

#ifdef TV

void OSDDrawSoundSystem(void)
{
	if(m_cSoundSystem==PAL_I)
		//OSDShowLine(iPAL_I,20,3,COL_NORMAL,OSD_LENGTH);
		OSDShowLine(iPAL_I,20,3,COL_TITLE,OSD_LENGTH);   
	else
		//OSDShowLine(iPAL_DK,20,3,COL_NORMAL,OSD_LENGTH);
		OSDShowLine(iPAL_DK,20,3,COL_TITLE,OSD_LENGTH);   


}

void OSDDrawTVFreq(uWORD wFreq)
{
//	float fTemp;
	uWORD wTemp;
	wTemp=((wFreq&0x7fff)-IF2_FERQ1)/FREQ_1MHZ;
	//m_wBuff[0]=wFreq/20-38;
	OSDDrawNum(wTemp, 0, 14, 0, COL_TITLE, DRAW_BLANK|0x03);
	OSDSetRamAddr(MENU_RAM_START_ADDRESS+17);
	twdWr_Burst_A(OSD_RAM_DL);
	twdWr_Burst_D(0x14); //'.'
	twdWr_Burst_D(COL_TITLE );
	twdWr_Burst_P();
	wTemp=((wFreq&0x7fFF)-IF2_FERQ1)%FREQ_1MHZ;
	OSDDrawNum(wTemp, FREQ_1MHZ, 18, 0, COL_TITLE, DRAW_ZERO|0x02);
}

void OSDDrawSkip(void)
{
	OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)2<<5)+19);

	twdWr_Burst_A(OSD_RAM_DL);

	switch((uCHAR)m_bTV_Skip){
	case 0:
  		twdWr_Burst_D('A');
		twdWr_Burst_D(COL_TITLE);
		twdWr_Burst_D('D');
		twdWr_Burst_D(COL_TITLE);
		twdWr_Burst_D('D');
		twdWr_Burst_D(COL_TITLE);
		break;
	case 1:
		twdWr_Burst_D('E');
		twdWr_Burst_D(COL_TITLE);
		twdWr_Burst_D('R');
		twdWr_Burst_D(COL_TITLE);
		twdWr_Burst_D('A');
		twdWr_Burst_D(COL_TITLE);
		break;
	}
}

void OSDDrawBand(uWORD wFreq)
{
	uCHAR k;
	if(wFreq < VLMAX)
		k=BAND_VL;
	else if(wFreq > VHMAX)
		k=BAND_UHF;
	else
		k=BAND_VH;

	OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)2<<5)+19);

	twdWr_Burst_A(OSD_RAM_DL);
	switch(k){
	case BAND_VL:
  		twdWr_Burst_D(BLANK);
		twdWr_Burst_D(COL_TITLE);  
		twdWr_Burst_D('V');
		twdWr_Burst_D(COL_TITLE);
		twdWr_Burst_D('L');
		twdWr_Burst_D(COL_TITLE);
		break;
	case BAND_VH:
		twdWr_Burst_D(BLANK);
		twdWr_Burst_D(COL_TITLE);
		twdWr_Burst_D('V');
		twdWr_Burst_D(COL_TITLE);
		twdWr_Burst_D('H');
		twdWr_Burst_D(COL_TITLE);
		break;
	case BAND_UHF:
		twdWr_Burst_D('U');
		twdWr_Burst_D(COL_TITLE);
		twdWr_Burst_D('H');
		twdWr_Burst_D(COL_TITLE);
		twdWr_Burst_D('F');
		twdWr_Burst_D(COL_TITLE);
		break;
	default:	break;
	}
	twdWr_Burst_P();
}

/*
void OSDTVShowChannel(uCHAR x, uCHAR y, uCHAR cColor, uCHAR cChannel)
{
	if(cChannel>=100)
	{
		OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)y<<5)+x);	//9
		twdWr_Burst_A(OSD_RAM_DL);
		OSDNumConvert(cChannel/100);
		twdWr_Burst_D(cColor );
		OSDNumConvert((cChannel/10)%10);
		twdWr_Burst_D(cColor );
		OSDNumConvert(cChannel%10);
		twdWr_Burst_D(cColor );
		twdWr_Burst_P();
	}
	else if(cChannel>=10)
	{
		OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)y<<5)+x);
		twdWr_Burst_A(OSD_RAM_DL);
		twdWr_Burst_D(BLANK);
		twdWr_Burst_D(cColor);
		OSDNumConvert(cChannel/10);
		twdWr_Burst_D(cColor );
		OSDNumConvert(cChannel%10);
		twdWr_Burst_D(cColor );
		twdWr_Burst_P();
	}
	else
	{
		OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)y<<5)+x);
		twdWr_Burst_A(OSD_RAM_DL);
		twdWr_Burst_D(BLANK);
		twdWr_Burst_D(cColor);
		twdWr_Burst_D(BLANK);
		twdWr_Burst_D(cColor);
		OSDNumConvert(cChannel);
		twdWr_Burst_D(cColor );
		twdWr_Burst_P();
	}
}
*/
#endif


void OSDNumConvert(uCHAR cNum)
{
	switch(cNum){
	case 9:	twdWr_Burst_D('9'-0x2f);	break;
	case 8:	twdWr_Burst_D('8'-0x2f);	break;
	case 7:	twdWr_Burst_D('7'-0x2f);	break;
	case 6:	twdWr_Burst_D('6'-0x2f);	break;

⌨️ 快捷键说明

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