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

📄 main.c

📁 此程序为twell8806驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
			case 'K':

				switch (arg[1]) {
				case 0:	Key = POWERKEY;			break;
				case 5:	Key = MENUKEY;			break;
				case 8:	Key = UPKEY;			break;
				case 2: Key = DOWNKEY;			break;
				case 4:	Key = LEFTKEY;			break;
				case 6:	Key = RIGHTKEY;			break;
				case 7:	Key = INPUTSOURCEKEY;	break;
				}
				RepeatKey = 0;
				KeyReady = 1;

				break;


			case 'z':
			case 'Z':

				if( argn==2 ) {
					if( arg[1]==0 )	P3_2 = 0;
					else P3_2 = 1;
				}

				if( P3_2==0 ) Printf("\r\nDisable Main Micom");
				else          Printf("\r\nEnable main Micom");

				break;


		/////////////////////////////////////////////////////////////////////////////////////

			case 'z':
			case 'Z':


				WriteDecoder( INFORM, ReadDecoder(INFORM) | 0x01 );
				WriteDecoder( ACNTL, ReadDecoder(ACNTL) & 0xfe );

				//WriteDecoder( G_GAIN,  0x80 );
				WriteDecoder( SCrGAIN, 0x40 );
				WriteDecoder( SCrGAIN, 0x40 );
				WriteDecoder( RGBCONTROL, 0x03 );
				WriteDecoder( RGBMISC, 0x05 );
				
				delay(10);
				
				for(i=0; ; i++) {
					if( Zilog[i].cnt==0 ) break;

					WriteZilog( Zilog[i].cnt, Zilog[i].str );
					
				}
				delay(20);

	
				break;


*/

		/////////////////////////////////////////////////////////////////////////////////////
			default : 
				break;
			}
			Prompt();
			commdptr = 0;
			commdbuf[0]='\0';
		}
	}

	//----- 1 byte command ----------------------------
	else {
		switch(ikey) {
		
		case 0x08:		// back space
			if(commdptr>0) {
				commdbuf[commdptr--]='\0';
				RS_tx(ikey);
				RS_tx(' ');
				RS_tx(ikey);
			}
			break;

		case 0x1B:		// Esc 
			Prompt();
			commdptr = 0;commdbuf[0]='\0';
			break;

		case ',':
		case '<':
			RS_tx('\r');
			if( indirect ){
				MonWriteI2C(I2CAddressDeb, 0xc5, arg[1]);
				RS_tx('\r');
				MonWriteI2C(I2CAddressDeb, 0xc6, --arg[2]);
				RS_tx('\r');
				MonWriteI2C(I2CAddressDeb, 0xc5, arg[1]);
				MonReadI2C(I2CAddressDeb, 0xc6);
			}
			else {
				MonWriteI2C(I2CAddressDeb, arg[1], --arg[2]);
				MonReadI2C(I2CAddressDeb, arg[1]);
			}
			Prompt();
			commdptr = 0;commdbuf[0]='\0';
			break;

		case '.':
		case '>':
			RS_tx('\r');
			if( indirect ){
				MonWriteI2C(I2CAddressDeb, 0xc5, arg[1]);
				RS_tx('\r');
				MonWriteI2C(I2CAddressDeb, 0xc6, ++arg[2]);
				RS_tx('\r');
				MonWriteI2C(I2CAddressDeb, 0xc5, arg[1]);
				MonReadI2C(I2CAddressDeb, 0xc6);
			}
			else {
				MonWriteI2C(I2CAddressDeb, arg[1], ++arg[2]);
				MonReadI2C(I2CAddressDeb, arg[1]);
			}
			Prompt();
			commdptr = 0;commdbuf[0]='\0';
			break;

{			

	static DATA BYTE level=0;

		case '-':
		case '_':
			RS_tx('\r');
			WriteI2C(0x80, 1, --level);
			Printf("\r\n 80[1]=%02x(%3d)  80[2]=%02x(%3d)", (WORD)ReadI2C(0x80, 1), (WORD)ReadI2C(0x80, 1),
                                               				(WORD)ReadI2C(0x80, 2), (WORD)ReadI2C(0x80, 2) );

			Printf(" min=%02x(%3d)  max=%02x(%3d)",         (WORD)ReadI2C(0x80, 3), (WORD)ReadI2C(0x80, 3),
                                               				(WORD)ReadI2C(0x80, 4), (WORD)ReadI2C(0x80, 4) );


			commdptr = 0;commdbuf[0]='\0';
			break;

		case '+':
		case '=':
			RS_tx('\r');
			WriteI2C(0x80, 1, ++level);
			Printf("\r\n 80[1]=%02x(%3d)  80[2]=%02x(%3d)", (WORD)ReadI2C(0x80, 1), (WORD)ReadI2C(0x80, 1),
                                               				(WORD)ReadI2C(0x80, 2), (WORD)ReadI2C(0x80, 2) );

			Printf(" min=%02x(%3d)  max=%02x(%3d)",         (WORD)ReadI2C(0x80, 3), (WORD)ReadI2C(0x80, 3),
                                               				(WORD)ReadI2C(0x80, 4), (WORD)ReadI2C(0x80, 4) );

			commdptr = 0;commdbuf[0]='\0';
			break;

}

		default:
			RS_tx(ikey);	
			commdbuf[commdptr++] = ikey;
			break;
		}
	}

}

#endif	// SERIAL

void CheckDipSwitch(void)
{
	static bit BW_STATUS=0, EDGE_STATUS=0;
			//----- Check DIP Switch ---------------

			if( EDGE_STATUS != DIP_EDGE_ENHANCE ) 
			{
				if( DIP_EDGE_ENHANCE==0 )
				 {
					EDGE_STATUS = 0;
					//WriteTW88(0x79, ReadTW88(0x79) & 0xf7);
					//Printf("\r\nEnable Color Enhancement");
					WriteTW88(0xdd, ReadTW88(0xdd) | 0x80);
					Printf("\r\nEnable Color Enhancement");


				}
				else 
				{
					EDGE_STATUS = 1;
//					WriteTW88(0x79, ReadTW88(0x79) | 0x08);
//					Printf("\r\nDisable Edge Enhancement");
					WriteTW88(0xdd, ReadTW88(0xdd) & 0x7f);
					Printf("\r\nDisable Color Enhancement");
				}
			}
			
			if( BW_STATUS != DIP_BW_STRETCH ) 
			{
				if( DIP_BW_STRETCH==0 ) 
				{
					BW_STATUS = 0;
					#ifdef WQVGA
					WriteTW88(0x86, 0x0c);
					WriteTW88(0x87, 0xff);
					#else
					WriteTW88(0x86, 0x20);
					WriteTW88(0x87, 0xe0);
					#endif
					Printf("\r\nEnable Black/White Stretch");
				}
				else
				 {
					BW_STATUS = 1;
					WriteTW88(0x86, 0x00);
					WriteTW88(0x87, 0xff);
					Printf("\r\nDisable Black/White Stretch");
				}
			}

}

#ifdef SUPPORT_GAMMA

#include "Gamma.c"

void DownLoadGamma(void)
{
		// Red
		WriteI2C(TW88I2CAddress, 0xf0, 0xe8|1 ); 
		WriteI2C(TW88I2CAddress, 0xf1, 0x00); //  Start Address
		WriteI2C(TW88I2CAddress, 0xf2, GammaRed[0]); //  
		WriteI2Cn(TW88I2CAddress, 0xf2, &GammaRed[1], 255);
		// Blue
		WriteI2C(TW88I2CAddress, 0xf0, 0xe8|2 ); 
		WriteI2C(TW88I2CAddress, 0xf1, 0x00); //  Start Address
		WriteI2C(TW88I2CAddress, 0xf2, GammaGreen[0]); //  
		WriteI2Cn(TW88I2CAddress, 0xf2, &GammaGreen[1], 255);
		// Red
		WriteI2C(TW88I2CAddress, 0xf0, 0xe8|3 ); 
		WriteI2C(TW88I2CAddress, 0xf1, 0x00); //  Start Address
		WriteI2C(TW88I2CAddress, 0xf2, GammaBlue[0]); //  
		WriteI2Cn(TW88I2CAddress, 0xf2, &GammaBlue[1], 255);

}
#endif

void I2CDeviceInitialize( CODE_P BYTE *RegSet)
{
	int	cnt=0;
	BYTE addr, index, val;

	while ( *RegSet != 0xFF ) {
		if( cnt==0 ) {
			addr = *RegSet;
			#ifdef DEBUG_TW88
			dPrintf("\r\nI2C address : %02x", (WORD)addr);
			#endif
			cnt = *(RegSet+1);
			RegSet+=2;
		}
		index = *RegSet;
		val = *(RegSet+1);
		WriteI2C(addr, index, val);

		#ifdef DEBUG_TW88
		dPrintf("\r\n    addr=%02x  index=%02x   val=%02x", (WORD)addr, (WORD)index, (WORD)val );
		#endif

		RegSet+=2;

		cnt--;
	}
}
#ifdef SUPPORT_TV
void ChangeVInputStdDetectMode(BYTE val)
{
	VInputStdDetectMode = val;
	SaveVInputStdDetectModeEE(val);
	if( VInputStdDetectMode ==AUTO )	
		SetAutoDetectStd();
	else {
		SetVInputStd(val);
		ClearAutoDetectStd(val-1);
		InitVideoData( val );			
	}
}
#endif
WORD GetIVF(void)
{
	return IVF;
}

DWORD GetIHF(void)
{
	return IHF;
}

extern CODE struct RegisterInfo UserRange;
extern CODE struct RegisterInfo VideoContrastRange;
extern CODE struct RegisterInfo VideoBrightnessRange;
extern CODE struct RegisterInfo VideoSaturationRange;
extern CODE struct RegisterInfo VideoHueRange;
extern CODE struct RegisterInfo VideoSharpnessRange;
extern CODE struct RegisterInfo DigitalVideoSaturationRange;

/*
BYTE	ConvertVideoVSAT(BYTE reg)
{ 
	reg = (WORD)reg * 0x5a / 0x7f;
	return reg;
}
*/
#ifdef ADD_ANALOGPANEL
BYTE IsAnalogOn(void)
{
	if(DIP_PANEL_SWITCH==0) return 1;
	else return 0;
}
#endif

void InitVideoData(BYTE src)
{

	#ifdef DEBUG_DECODER
	dPrintf("\r\n++(InitVideoData)src:%02x", (WORD)src);
	#endif

	#ifdef ADD_ANALOGPANEL
	if(IsAnalogOn())
		I2CDeviceInitialize(NTSC_Regs_Analog);
	else
	#endif
	I2CDeviceInitialize(NTSC_Regs);
					
	switch( src ) {

	#ifdef SUPPORT_PAL
	case PAL:			
		#ifdef ADD_ANALOGPANEL
			if(IsAnalogOn())
				I2CDeviceInitialize(PAL_Regs_Analog);
			else
		#endif
		I2CDeviceInitialize(PAL_Regs);	
		break;
	#endif
	#ifdef SUPPORT_SECAM
	case SECAM:		
		#ifdef ADD_ANALOGPANEL
			if(IsAnalogOn())
				I2CDeviceInitialize(PAL_Regs_Analog);
			else
		#endif
		I2CDeviceInitialize(PAL_Regs);	
		break;
	#endif
	#ifdef SUPPORT_PALN
	case PALN:		
		#ifdef ADD_ANALOGPANEL
			if(IsAnalogOn())
				I2CDeviceInitialize(PAL_Regs_Analog);
			else
		#endif
		I2CDeviceInitialize(PAL_Regs);	
		break;
	#endif

	#ifdef SUPPORT_NTSC4
	case NTSC4:
	#endif
	#ifdef SUPPORT_PALM
	case PALM:
	#endif
	#ifdef SUPPORT_PAL60
	case PAL60:
	#endif
	case NTSC:

	case UNKNOWN:
	case NOINPUT:	src = NTSC;						break;
	}

	if( InputSelection == TV ) {
		if( VInputStdDetectMode==AUTO ) SetAutoDetectStd();
		else							ClearAutoDetectStd(src-1);
	}
	else // Always Auto Detect.
		SetAutoDetectStd();
		
	//----- Set Panel Characteristics
///	SetPanelSingleDouble(PIXEL_SINGLE);

	WriteDecoder(V_CONTROL2, 0x15);			// Set CC line number of Even Field
//	WriteDecoder(CC_ODDLINE, 0x15);			// Set CC line number of Odd Field
	WriteTW88(0x5c, 0x06);			// change error tolerance and enable V/HSYNC change/loss detection

	DefaultPanelAttributeForVideo();

	SetVideoMode( GetVideoModeEE());

	#ifdef SUPPORT_CCD_VCHIP
	( EnabledVChip() ?	InitEDS()   :   ClearEDS()	);		//ljy012005...just check whether VChip is enabled, don't need real value.
	#endif

	#ifdef WIDE_SCREEN
	Set4WideScreen(GetWideModeEE());
	#endif

}

/*********************************/
//#if defined SUPPORT_TV || defined ID_CHECK_BY_FW
BYTE IsNoInput(void)
{
	if( ReadDecoder(CSTATUS) & 0x80 ) return 1;
	return 0;
}
//#endif

#ifdef ID_CHECK_BY_FW
BYTE Is50Hz(void)
{
	if( ReadDecoder(CSTATUS) & 0x01 ) return 1;
	return 0;
}

BYTE Slock(void)
{
	if( ReadDecoder(CSTATUS) & 0x20 ) return 1;
	return 0;
}
#endif	// ID_CHECK_BY_FW

#ifdef SUPPORT_COMPONENT
void CheckDecoderComponent(void)
{
	CODE_P BYTE *reg=0;
	BYTE mode;

	extern CODE BYTE COMPONENT_STR[][15] ;

	if( InputSelection != COMPONENT ) return;

	mode = ((ReadDecoder(CVFMT) & 0x70) >> 4);
	if( mode == ComponentMode ) return;
	Printf("\n\rCheckDecoderComponent==> Changed component Mode: %2x-> %2x (%s)", (WORD)ComponentMode, (WORD)mode,COMPONENT_STR[mode]);

	ComponentMode = mode;
	switch (mode)
	{
	case YPBPR_576i:	reg = COMP_YPbPr_576I_Reg;	break;
	#ifndef WQVGA
	case YPBPR_480p:	reg = COMP_YPbPr_480P_Reg;	break;
	case YPBPR_576p:	reg = COMP_YPbPr_576P_Reg;	break;
	case YPBPR_720p:	reg = COMP_YPbPr_720P_Reg;	break;
	case YPBPR_1080i:	reg = COMP_YPbPr_1080I_Reg;	break;
	#endif
	default:			reg = COMP_YPbPr_480I_Reg;	break;

	}

	InitVideoData(NTSC);

	I2CDeviceInitialize(reg);

	delay(50);

	if( IsNoInput() )	DisplayInputHold = 1;		// Hold  Input Information in no signal.
	else 
	DisplayInputHold = 0;

	ClearOSDInfo();

	DisplayInput();
}
#endif
void CheckDecoderInput(void)
{



#ifdef ID_CHECK_BY_FW

	BYTE std, changed=0;

	static DATA BYTE no_cnt=0, secam_cnt=0, check_cnt=0;

	//if( InputSelection == TV ) return;
	if( InputSelection == COMPONENT ) return;
	if( ( InputSelection == TV ) && (VInputStdDetectMode != AUTO) ) return;

	if( IsNoInput() ) 
	{
		if( VInputStd==NOINPUT ) return;
		no_cnt++;
		if( no_cnt>=10 ) 
		{
			no_cnt = 0;
			
			SetVInputStd( NOINPUT );
			InitVideoData(NTSC);	

			#ifdef DEBUG_DECODER
			dPrintf("\r\nDecoder No Input");
			#endif

		}
		return;
	}
	else 
	{
		no_cnt = 0;
	}


	switch( VInputStd )
	 {

	//--------------------------------------------------------------------------------------
	case NOINPUT:

		WriteDecoder(STD, 0x0f);		// 0x1c
		//WriteTW88(0xb6, 0x87);
		//delay(50);

		switch( ReadDecoder(STD) & 0x70 ) {
		case 0x00:	std = NTSC;	break;
		case 0x10:	std = PAL;	break;
		case 0x20:	std = SECAM;	break;
		}
		changed = 1;
		check_cnt = 0;
		secam_cnt = 0;
		break;
		
	//--------------------------------------------------------------------------------------
	case NTSC:
		if( Is50Hz() ) 
		{
			if( !Slock() ) secam_cnt++;
			if( ++check_cnt>=10 )
			 {
				if( secam_cnt>=7 )
				 {
					std = SECAM;
					changed = 1;
				}
				else 
				{
					std = PAL;
					changed = 1;
				}
				check_cnt = 0;
				secam_cnt = 0;
			}
		}
		break;

	//--------------------------------------------------------------------------------------
	case PAL:

		if( !Is50Hz() ) 
		{
			std = NTSC;
			changed = 1;
			check_cnt = 0;
			secam_cnt = 0;
		}

		if( ReadTW88(0x30) & 0x10 ) secam_cnt++;
		if( ++check_cnt>=10*10 ) 
		{
			if( secam_cnt>=7 )
			 {
				std = SECAM;
				changed = 1;
			}
			check_cnt = 0;
			secam_cnt = 0;

⌨️ 快捷键说明

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