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

📄 1574osd.c

📁 small pannel driver using MXIC s 88LV462,this sample code including the function IIC with 8051,IR,OS
💻 C
📖 第 1 页 / 共 2 页
字号:
	OSD_Attribute(0, 13, OSD_NORMAL_C);					//Set Title line attribute

		//Turn ON the OSD window after the OSD Reg. setting
	buf[0] = OSDWINON;
	Write_OSDReg(buf, SEL_OSDCTRLREG, 1, OSDCTRLREG);
}


/**--------------------------------------------------------------------------
* Name			OSD_Attribute(BYTE item, BYTE length, BYTE attr_color)
*
* Description	Write OSD Attribute Reg.
*
* Flow Chart
*
* Return
*
* DATE          Author          Description
* ===========================================================================
* 2004-07-12    K.M. Ho         This is first time implement
**/
void	OSD_Attribute(BYTE addr, BYTE length, BYTE attr_color)
{
	BYTE	buf[13], i;

	for (i=0; i<length; i++)		//make Attribute buffer
		buf[i] = attr_color;

		//Write OSD attribute buffer
	Write_OSDReg(buf, SEL_OSDDISPATTR, length, addr);
}

/**--------------------------------------------------------------------------
* Name			Read_OSDReg(BYTE *buf, BYTE rd_type
*								 BYTE ch_count, BYTE begin_addr)
*
* Description   Read data from 15xx OSD
*
* Flow Chart
*
* Return        *str 			reading data buffer
*
* DATE          Author          Description
* ===========================================================================
* 2004-07-12    K.M. Ho         This is first time implement
* 2004-10-12	KMHo			Del the OSD enable 
**/
void	Read_OSDReg(BYTE *buf, BYTE rd_type, BYTE ch_count, BYTE addr)
{
	BYTE	i;
	
//	I2C_WriteByte(L44_WRID, OSD_EN,		0xAC);	//Del by KMHo 2004-10-12
	I2C_WriteByte(L44_WRID, ORWCTRL, 	rd_type|0xA0);
	I2C_WriteByte(L44_WRID, OSDADDR_L,	addr);
	I2C_WriteByte(L44_WRID, OSDADDR_H,	0x00);
	
	for(i=0; i<ch_count; i++)
		*(buf+i) = I2C_ReadByte(L44_WRID, OSDDATA_L);
		
	I2C_WriteByte(L44_WRID, ORWCTRL, 	0x04);	//Disable OSD Reg. Read/Write
}

/**--------------------------------------------------------------------------
* Name          Write_OSDReg(BYTE *buf, BYTE wr_type
*								 , BYTE ch_count, BYTE begin_addr)
*
* Description   Write data buffer to 15xx OSD Reg
*
* Flow Chart
*
* Return        None
*
* DATE          Author          Description
* ===========================================================================
* 2004-07-12    K.M. Ho         This is first time implement
* 2004-10-12	KMHo			Del the OSD enable 
**/
void	Write_OSDReg(BYTE buf[], BYTE wr_type, BYTE count, BYTE addr)
{
	BYTE	i,j;
	BYTE	wr_byte;
	int		offset;

//	I2C_WriteByte(L44_WRID, OSD_EN,		0xAC);		//Del by KMHo 2004-10-12
	I2C_WriteByte(L44_WRID, ORWCTRL, 	wr_type|0x80);
	I2C_WriteByte(L44_WRID, OSDADDR_L,	addr);
	I2C_WriteByte(L44_WRID, OSDADDR_H,	0x00);

	switch(wr_type)
	{
		case 0x01:						//0x01 OSD Font table RAM
			for (i=0; i<count; i++)		//character count
			{
				offset = (int)(i*36);
				for (j=0; j<18; j++)	//Write a character to 15xx Font Table RAM
				{
					I2C_WriteByte(L44_WRID, OSDDATA_L, buf[offset]);
					I2C_WriteByte(L44_WRID, OSDDATA_H, buf[offset+1]);
					offset += 2;
				}
			}
			break;
		case 0x02:						//0x02 OSD Display code buffer
			if (count == 1)
				I2C_WriteByte(L44_WRID, OSDDATA_L, buf[0]);
			else
				for (i=0; i<count; i++)	//Write number of byte to select
				{						//Convert ASCII code to 15xx ROM Font code
					wr_byte = ASCII_OSDFont(buf[i]);
					I2C_WriteByte(L44_WRID, OSDDATA_L, wr_byte);
				}
			break;
		case 0x00:						//0x00 OSD Control Reg.
		case 0x03:						//0x03 OSD Display attribute buffer
			for (i=0; i<count; i++)		//Write data to OSD Control Reg or Attribute
				I2C_WriteByte(L44_WRID, OSDDATA_L, buf[i]);
			break;
	}
	I2C_WriteByte(L44_WRID, ORWCTRL, 	0x04);	//Disable OSD Reg. Read/Write
}

/**--------------------------------------------------------------------------
* Name          BYTE	ASCII_OSDFont(BYTE ascii_code)
*
* Description	convert the ASCII code to the 15xx ROM font code
*				There are 64 char. font in 15xx ROM font
*					0 1 2 3 4 5 6 7 8 9 A B C D E F
*					G H I J K L M N O P Q R S T U V
*					W X Y Z a b c d e f g h i j k l
*					m n o p q r s t u v w x y z   /
* Flow Chart
*
* Return		osd font code
*
* DATE          Author          Description
* ===========================================================================
* 2004-07-10	K.M. Ho         This is first time implement
*/
BYTE	ASCII_OSDFont(BYTE ascii_code)
{
	BYTE	osd_font_code;

	osd_font_code = 0x3E;	//default convert to space Font index

	if (ascii_code>=0x20 && ascii_code<=0x2F)	osd_font_code = (ascii_code-0x20)|0x40;
	
	if (ascii_code>=0x30 && ascii_code<=0x39)	osd_font_code = ascii_code-0x30;
	if (ascii_code>=0x41 && ascii_code<=0x5A)	osd_font_code = ascii_code-0x41+10;
	if (ascii_code>=0x61 && ascii_code<=0x7A)	osd_font_code = ascii_code-0x61+36;

	return (osd_font_code);
}

/**--------------------------------------------------------------------------
* Name          void	Value_ASCII(BYTE value, BYTE *val_str, BYTE signed_bit)
*
* Description	convert the pass-in value to ASCII code
*
* Flow Chart
*
* Return		value string buffer
*
* DATE          Author          Description
* ===========================================================================
* 2004-07-21	K.M. Ho         This is first time implement
*/
void	Value_ASCII(BYTE value, BYTE *val_str, BYTE item)
{
	BYTE	i, tmp_div, tmp_val;
	
	*val_str = 0x20;
	if (item==0x04 || item==0x05)
	{
		if (value & 0x20)	value = value - 0x20;		//value is plus
		else 	{			value = 0x20 - value;		//value is minus
							*val_str = 0x2D;
				}
	}

	tmp_div = 10;

	for (i=0; i<2; i++)
	{
		tmp_val = value / tmp_div;
		value 	= value % tmp_div;		//get the new value

		*(val_str+i+1) = tmp_val|0x30;	//save the ASCII code to string buffer

		tmp_div = tmp_div / 10;			//get the divide 10 or 1
	}
}

/**--------------------------------------------------------------------------
* Name          void	Adj_LRUD(BYTE value)
*
* Description
*
* Flow Chart 
*
* Return		
*
* DATE          Author          Description
* ===========================================================================
* 2004-11-23	K.M. Ho         This is first time implement
*/
void	Adj_LRUD(BYTE set_val)
{
	BYTE	rd_val;
		
	rd_val  = I2C_ReadByte(L44_WRID, 0x30);
	set_val = (set_val<<6) | (rd_val&0x3F);
	
	I2C_WriteByte(L44_WRID, 0x30, set_val);
}

/**--------------------------------------------------------------------------
* Name          void	Adj_Brightness(BYTE value)
*
* Description
*
* Flow Chart 
*
* Return		
*
* DATE          Author          Description
* ===========================================================================
* 2004-07-22	K.M. Ho         This is first time implement
*/
void	Adj_Brightness(BYTE value)
{
	char	i;
	
	for (i=0; i<3; i++)
		I2C_WriteByte(L44_WRID, i+0x15, value);
}

/**--------------------------------------------------------------------------
* Name          void	Adj_Contrast(BYTE value)
*
* Description
*
* Flow Chart
*
* Return		
*
* DATE          Author          Description
* ===========================================================================
* 2004-07-22	K.M. Ho         This is first time implement
*/
void	Adj_Contrast(BYTE value)
{
	char	i;
	
	for (i=0; i<3; i++)
		I2C_WriteByte(L44_WRID, i+0x12, value);
}

/**--------------------------------------------------------------------------
* Name          void	Adj_Saturation(BYTE value)
*
* Description
*
* Flow Chart
*
* Return	
*
* DATE          Author          Description
* ===========================================================================
* 2004-07-22	K.M. Ho         This is first time implement
*/
void	Adj_Saturation(BYTE value)
{
	I2C_WriteByte(L44_WRID, 0x18, value);
}

/**--------------------------------------------------------------------------
* Name          void	Adj_Hue(BYTE value)
*
* Description
*
* Flow Chart
*
* Return		
*
* DATE          Author          Description
* ===========================================================================
* 2004-07-22	K.M. Ho         This is first time implement
*/
void	Adj_Hue(char value)
{
	value -= 0x80;
	I2C_WriteByte(L44_WRID, 0x19, value);
}

/**--------------------------------------------------------------------------
* Name          void	Adj_Sharpen(BYTE value)
*
* Description
*
* Flow Chart
*
* Return		
*
* DATE          Author          Description
* ===========================================================================
* 2004-19-19	K.M. Ho         This is first time implement
*/
void	Adj_Sharpen(char value)
{
	BYTE	va, vb;
	
	if (value & 0x40)
	{	
		value = (value - 0x40) << 1;		//value is plus
		va = 0xFF - value + 1;		
		vb = value + 64;
	}
	else
	{ 	
		value = 0x40 - value;				//value is minus
		va = value;
		vb = 64 - value;
	}

	I2C_WriteByte(L44_WRID, 0x24, va);
	I2C_WriteByte(L44_WRID, 0x25, vb);
	I2C_WriteByte(L44_WRID, 0x26, va);
}

/**--------------------------------------------------------------------------
* Name          void	Adj_Edge(BYTE value)
*
* Description
*
* Flow Chart
*
* Return		
*
* DATE          Author          Description
* ===========================================================================
* 2004-11-19	K.M. Ho         This is first time implement
*/
void	Adj_Edge(char value)
{
	BYTE	reg01_val,reg80_val;
		
	reg01_val = CVD1_ReadWrite(0x00, 0x01, 0x00);
	reg80_val = CVD1_ReadWrite(0x00, 0x80, 0x00);
	if (value)
	{
		reg01_val |= 0x08;		
		reg80_val |= 0x01;
	}
	else
	{
		reg01_val &= 0xF7;
		reg80_val &= 0xFE;
	}
	
	CVD1_ReadWrite(0x01, 0x01, reg01_val);
	CVD1_ReadWrite(0x01, 0x80, reg80_val);
}

/**--------------------------------------------------------------------------
* Name          void	Adj_DisplayMode(BYTE value)
*
* Description
*
* Flow Chart
*
* Return		
*
* DATE          Author          Description
* ===========================================================================
* 2004-12-10	K.M. Ho         This is first time implement
*/
void	Adj_DisplayMode(BYTE value)
{
	BYTE	offset, i;
	
	if (value)
	{
		for (i=0; i<15; i++)				//download Full mode Reg. value
		{
			offset = i<<1;
			I2C_WriteByte(L44_WRID, Mode_Full[offset], Mode_Full[offset+1]);
		}
		
//		I2C_WriteByte(L44_WRID, 0x3B, 0x0D);
		if (NTSC_PAL && value>1)
		{
			I2C_WriteByte(L44_WRID, 0x3B, 0x11);
			if (value == 2)
				for (i=0; i<6; i++)			//download Zoom1 mode Reg. value
				{
					offset = i<<1;
					I2C_WriteByte(L44_WRID, Mode_Zoom1[offset], Mode_Zoom1[offset+1]);
				}
			if (value == 3)
				for (i=0; i<6; i++)			//download Zoom2 mode Reg. value
				{	
					offset = i<<1;
					I2C_WriteByte(L44_WRID, Mode_Zoom2[offset], Mode_Zoom2[offset+1]);
				}
		}
		if (NTSC_PAL)	I2C_WriteByte(L44_WRID, 0x68, 0x56);
		else			I2C_WriteByte(L44_WRID, 0x68, 0x10);
	}
	else
	{
		for (i=0; i<15; i++)				//download 4by3 mode Reg. value
		{
			offset = i<<1;
			I2C_WriteByte(L44_WRID, Mode_4by3[offset], Mode_4by3[offset+1]);
		}
		if (NTSC_PAL)	I2C_WriteByte(L44_WRID, 0x68, 0x7E);
		else			I2C_WriteByte(L44_WRID, 0x68, 0x1A);	
		
	}
}

⌨️ 快捷键说明

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