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

📄 lcd_osd.~c

📁 液晶显示器程序代码
💻 ~C
📖 第 1 页 / 共 5 页
字号:
#define __OSD__

#include "reg52.h" 

#include "Header\MAIN_DEF.H"
#include "Header\CONFIG.H"
#include "Header\ACCESS.H"
#include "Header\LCD_FUNC.H"
#include "Header\LCD_AUTO.H"
#include "Header\LCD_MSG.H"
#include "Header\LCD_MAIN.H"
#include "Header\LCD_OSD.H"
#include "Header\FONT.H"
#include "Header\OSD.H"
#include "Header\SRC_CTRL.H"
#include "Header\OSD_TREE.H"

#if (TV_CHIP != TV_NONE)
#include "TUNER.H"
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// OSD Process Dispatch Table
// In this code, when input source is not VGA, AUTO CONFIG page will not be shown.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

unsigned char GetNextPageIdx(unsigned char ucPageCurr)
{
    switch (stGUD1.INPUT_SOURCE & 0x07)
    {
    case SOURCE_VGA :
        return (6 <= ucPageCurr) ? 1 : ucPageCurr + 1;
    case SOURCE_DVI :
        return (6 <= ucPageCurr) ? 1 : ucPageCurr + 1;
    case SOURCE_AV  :
        return (5 <= ucPageCurr) ? 1 : ucPageCurr + 1;
    case SOURCE_SV  :
        return (5 <= ucPageCurr) ? 1 : ucPageCurr + 1;
    case SOURCE_YUV :
        return (5 <= ucPageCurr) ? 1 : ucPageCurr + 1;
    default :
        return 1;
    }
    
}

unsigned char GetPrevPageIdx(unsigned char ucPageCurr)
{
   switch (stGUD1.INPUT_SOURCE & 0x07)
    {
    case SOURCE_VGA :
        return (1 >= ucPageCurr) ? 6 : ucPageCurr - 1;
    case SOURCE_DVI :
        return (1 >= ucPageCurr) ? 6 : ucPageCurr - 1;
    case SOURCE_AV  :
        return (1 >= ucPageCurr) ? 5 : ucPageCurr - 1;
    case SOURCE_SV  :
        return (1 >= ucPageCurr) ? 5 : ucPageCurr - 1;
    case SOURCE_YUV :
        return (1 >= ucPageCurr) ? 5 : ucPageCurr - 1;
    default :
        return 1;
    }

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// OSD Process Public Function
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

//  OSD Window : Control OSD Windows
//  win_no     : bit 2 ~ 0   Window Number 0 ~ 7
//  row_start  : bit 10 ~ 0  Window Row Start Address
//  row_end    : bit 10 ~ 0  Window Row End Address
//  col_start  : bit 10 ~ 0  Window Column Start Address
//  col_end    : bit 10 ~ 0  Window Column End Address
//  width      : bit 2 ~ 0   shadow/border width or 3D button thickness in pixel unit 1~8 pixel
//  height     : bit 2 ~ 0   shadow/border height in line unit , it must the same with width for 3D button thickness
//  color      : bit 3 ~ 0   window color index in 16-color LUT
//  color_sb   : bit 7 ~ 4   shadow color or left-top/bottom border color for 3D window
//             : bit 3 ~ 0   border color or right-bottom/top border color
//  gradient   : bit 7       R Gradient Polarity 0 : Decrease  1 : Increase
//             : bit 6       G Gradient Polarity 0 : Decrease  1 : Increase
//             : bit 5       B Gradient Polarity 0 : Decrease  1 : Increase
//             : bit 4 ~ 3   Gradient level      00~11 : 1 step ~ 4 setp per level
//             : bit 2       Enable Red Color Gradient
//             : bit 1       Enable Green Color Gradient
//             : bit 0       Enable Blue Color Gradient
//  gra_level  : bit 2~0     111 ~ 001 : 7 level ~ 1 level per gradient, 000 : 8 level per gradient
//  attr       : bit 6       1 - Enable Gradient function      0 - Disable Gradient function
//             : bit 5       1 - Vertical Gradient             0 - Horizontal Gradient
//             : bit 4       1 - Enable Shadow/Border/3D button   0 - Disable
//             : bit 3 ~ 1   000 : Shadow Type 1
//                           001 : Shadow Type 2
//                           010 : Shadow Type 3
//                           011 : Shadow Type 4
//                           100 : 3D Button Type 1
//                           101 : 3D Button Type 2
//                           110 : Reserved
//                           111 : Border
//             : bit 0       1 - Enable Window            0 - Disable Window
void OSD_Window(unsigned char win_no, unsigned int row_start, unsigned int row_end, unsigned int col_start, unsigned int col_end,
					unsigned char width, unsigned char height, unsigned char color, unsigned char color_sb, unsigned char gradient,
					unsigned char gray_level,unsigned char attr)
{
	if(win_no > 7)  
		return;

	Data[0]     = 5;
	Data[1]     = Y_INC;
	Data[2]     = OSD_ADDR_MSB_90;
	Data[3]     = 0xc1;
	Data[4]     = (win_no << 2);
	Data[5]     = 0;
	RTDWrite(Data);
	Data[0]     = 6;
	Data[1]     = N_INC;
	Data[2]     = OSD_DATA_92;
	Data[3]     = ((width & 0x07) << 3) | (height & 0x07);
	Data[4]     = color_sb;
	Data[5]     = gradient;
	Data[6]     = 0;
	RTDWrite(Data);

	Data[0]     = 5;
	Data[1]     = Y_INC;
	Data[2]     = OSD_ADDR_MSB_90;
	Data[3]     = 0xe1;
	Data[4]     = (win_no << 2) + 1;
	Data[5]     = 0;
	RTDWrite(Data);
	Data[0]     = 9;
	Data[1]     = N_INC;
	Data[2]     = OSD_DATA_92;
	Data[3]     = (unsigned char)((unsigned int)(row_start & 0x003f) << 2);
	Data[4]     = (unsigned char)((unsigned int)(col_start & 0x0007) << 5) | 
			      (unsigned char)((unsigned int)(row_start & 0x07c0) >> 6);
	Data[5]     = (unsigned char)((unsigned int)(col_start & 0x07f8) >> 3);

	Data[6]     = (unsigned char)((unsigned int)(row_end & 0x003f) << 2);
	Data[7]    = (unsigned char)((unsigned int)(col_end & 0x0007) << 5) | 
				  (unsigned char)((unsigned int)(row_end & 0x07c0) >> 6);
	Data[8]    = (unsigned char)((unsigned int)(col_end & 0x07f8) >> 3);
	Data[9]     = 0;
	RTDWrite(Data);

	Delay_Xms(25);
	
	/*
	do
	{
		RTDRead(0x94, 0x01, Y_INC);
	}
	while( ((Data[0] >> 5) & 0x01) );
	*/
	
	Data[0]     = 5;
	Data[1]     = Y_INC;
	Data[2]     = OSD_ADDR_MSB_90;
	Data[3]     = 0xc1;
	Data[4]     = (win_no << 2) + 3;
	Data[5]     = 0;
	RTDWrite(Data);
	Data[0]     = 6;
	Data[1]     = N_INC;
	Data[2]     = OSD_DATA_92;
	Data[3]    = 0x00;
	Data[4]    = (unsigned char)((gray_level & 0x07) << 4) |( color & 0x0f);
	Data[5]    = attr;
	Data[6]    = 0;
	RTDWrite(Data);

}

void Get_OSD_Margin(void)
{
	unsigned char ucH_Min, ucH_Max, ucV_Max;

#if (DISP_ALIGN)
	RTDRead(DH_ACT_STA_27, 0x02, Y_INC);
	Data[2] = Data[1] & 0x07;
	Data[3] = Data[0];

	ucH_Min = (((unsigned int *)Data)[1] / 4) + 1;
	ucH_Max = OSD_HMAX;
#else
	RTDRead(DH_ACT_END_29, 0x02, Y_INC);
	Data[2] = Data[1] & 0x07;
	Data[3] = Data[0];

	//ucH_Max = ((((unsigned int *)Data)[1] - 312 - 8 - 16) / 4) + 1;
	ucH_Max = ((((unsigned int *)Data)[1] - 512) / 4) + 1; 
	ucH_Min = OSD_HMIN;
#endif

	RTDRead(DV_ACT_END_34, 0x02, Y_INC);
	Data[2] = Data[1] & 0x07;
	Data[3] = Data[0];

	ucV_Max = (((unsigned int *)Data)[1] - DV_ACT_STA_POS - 250 - 14) / 4;

	Data[0] = ucH_Min;
	Data[1] = ucH_Max;
	Data[2] = OSD_VMIN;
	Data[3] = ucV_Max;
	
}

// OSD_Position : Restore OSD position according to global settings
// para : OSD font parameter
// OSD_GLOBAL_BLINK    : 0x10
// OSD_DISP_ZONE_LEFT  : 0x04
// OSD_DISP_ZONE_RIGHT : 0x08
// OSD_ROTATE          : 0x02
// OSD_ENABLE          : 0x01

void OSD_Position(unsigned char para)
{
	Get_OSD_Margin();

	if (Data[0] > stGUD1.OSD_POSH || Data[1] < stGUD1.OSD_POSH ||
		Data[2] > stGUD1.OSD_POSV || Data[3] < stGUD1.OSD_POSV)
	{
		stGUD1.OSD_POSV = OSD_VMID;
		stGUD1.OSD_POSH = OSD_HMID;
		Save_GUD1();
	}

	Wait_For_Event(EVENT_DEN_STOP);

	Data[0]     = 5;
	Data[1]     = Y_INC;
	Data[2]     = OSD_ADDR_MSB_90;
	Data[3]     = 0xc0;
	Data[4]     = 0x00;
	Data[5]     = 6;
	Data[6]     = N_INC;
	Data[7]     = OSD_DATA_92;
	Data[8]     = stGUD1.OSD_POSV >> 1;
	Data[9]     = (unsigned char)(stGUD1.OSD_POSH >> 2);
	Data[10]    = ((unsigned char)(stGUD1.OSD_POSH & 0x0003) << 6) | ((stGUD1.OSD_POSV & 0x01) << 5) | para;
				//+ (unsigned char)(OSD_Enable[10] & 0x1e) + osd_en;
	Data[11]    = 0;
	RTDWrite(Data);

}

void OSD_Line(unsigned char row, unsigned char col, unsigned char length,
              unsigned char value, unsigned char indicate)
{
	unsigned int idata usStart_Addr;
	unsigned char idata ucTemp;

	usStart_Addr = FONT_SELECT_ADDRESS;

	//The address of the first character Cn1 in Row n = FONT_SELECT_ADDRESS + Row0_length + Row1_length +...+Row(n-1)_length
	for(ucTemp = 1; ucTemp < row+1; ucTemp ++)
		usStart_Addr += Row_Info[0][ucTemp];

	Data[0] = 5;
	Data[1] = Y_INC;
	Data[2] = OSD_ADDR_MSB_90;

	if( (col+1) > Row_Info[0][row + 1])	// if column_start > row_length, then return
		return;
	else if((col + 1 + length) > Row_Info[0][row + 1])	// if column_start + length > row_length, then re-calculate the length
		length = Row_Info[0][row + 1] - col;
    	
	// indicate : 0, 1, 2, 3 set byte 0, 1, 2 and all byte
	Data[3] = (unsigned char)( ((usStart_Addr + col)  & 0x0fff) >> 8 ) | (((indicate << 2) + 1) << 4);
	Data[4] = (unsigned char)((usStart_Addr + col) & 0x00ff);
	Data[5] = 0;  
	RTDWrite(Data);

	Data[0]     = (indicate == 3) ? length * 3 + 3 : length + 3;
	Data[1]     = BURST; 
	Data[2]     = OSD_DATA_92;
	Data[3]     = value;
	Data[4]     = 0;
	RTDWrite(Data);
	
}     

void OSD_Slider(unsigned char row, unsigned char col, unsigned char length, unsigned char value, unsigned char range,
                unsigned char color, unsigned char color_slider)
{
	unsigned int idata usStart_Addr;
	unsigned char idata ucTemp;
	unsigned int bound;

	usStart_Addr = FONT_SELECT_ADDRESS;

	for(ucTemp = 1; ucTemp < row+1; ucTemp ++)
		usStart_Addr += Row_Info[0][ucTemp];

	length = length -5;
	bound   = ((length-2)*6 + 2*3) * value;

	// Set color
	Data[0] = 6;
	Data[1] = Y_INC;
	Data[2] = OSD_ADDR_MSB_90;
	Data[3] = (unsigned char)((((usStart_Addr + col) >>8 ) & 0x0f ) | 0x90);
	Data[4] = (unsigned char)( (usStart_Addr + col) & 0x00ff);
	Data[5] = (color << 4) & 0xf0;		
	Data[6] = 0;
	RTDWrite(Data);

	Data[0] = 5;
	Data[1] = N_INC;
	Data[2] = OSD_DATA_92;
	Data[3] = (color << 4) & 0xf0;		
	Data[4] = (color << 4) & 0xf0;		
	Data[5] = 0;
	RTDWrite(Data);

	OSD_Line(row,col+5,12,((color_slider<<4) & 0xf0),2);
	Data[0] = 6;
	Data[1] = Y_INC;
	Data[2] = OSD_ADDR_MSB_90;

	Data[6] = 0;

 	for (row = 0; row < length; row++)
    	{
		Data[3] = (unsigned char)((((usStart_Addr + col + row + 5) >> 8 ) & 0x0f ) | 0x50);
    		Data[4] = (unsigned char)( (usStart_Addr + col + row + 5) & 0x00ff);

		if( row == 0 || row == (length-1) )
		{
			if( bound )
			{
				if( bound >= (range*3) )
				{
					Data[5] = (row==0) ? 0x13 : 0x1e;
					bound = bound - range*3;
				}
				else
				{
			       	color   = (bound << 4) / (range*3);
					bound = 0;
	
					if (4 > color)
						Data[5] = (row==0) ? 0x10 : 0x1b;	
					else if (8 > color)
						Data[5] = (row==0) ? 0x11 : 0x1c;
					else if (12 > color)
						Data[5] = (row==0) ? 0x12 : 0x1d;
					else
						Data[5] = (row==0) ? 0x13 : 0x1e;
				}
			}
			else
			{
				Data[5] = (row==0) ? 0x10 : 0x1b;	
			}
		}
		else
		{
			if( bound )
			{
				if( bound >= (range*6) )
				{
					Data[5] = 0x1a;
					bound = bound - range*6;
				}
				else
				{
					color   = (bound << 4) / (range*6);
					bound = 0;
	
					if (1 > color)
						Data[5] = 0x14;
					else if (4 > color)
						Data[5] = 0x15;
					else if (6 > color)
						Data[5] = 0x16;
					else if (9 > color)
						Data[5] = 0x17;
					else if (11 > color)
						Data[5] = 0x18;
					else if (14 > color)
						Data[5] = 0x19;
					else
						Data[5] = 0x1a;
				}
			}
			else
			{
				Data[5] = 0x14;
			}
		
		}

		RTDWrite(Data);
		
	}

	range	= value / 10;
	row		= value - (range * 10);	// x1
	color	= range / 10;			// x100
	range	= range - (color * 10);	// x10

	row		= row + 0x01;
	range	= (range || color) ? range + 0x01 : 0x00;
	color	= color ? color + 0x01 : 0x00;

	Data[0] = 5;
	Data[1] = Y_INC;
	Data[2] = OSD_ADDR_MSB_90;
	Data[3] = (unsigned char)((((usStart_Addr + col) >>8 ) & 0x0f ) | 0x50);
	Data[4] = (unsigned char)( (usStart_Addr + col ) & 0x00ff);
	Data[5] = 0;
	RTDWrite(Data);

	Data[0] = 6;
	Data[1] = N_INC;
	Data[2] = OSD_DATA_92;
	Data[3] = color;		// Number x100
	Data[4] = range;		// Number x10
	Data[5] = row;		// Number x1
	Data[6] = 0;
	RTDWrite(Data);

}


void Init_Page(unsigned char index)
{
	index = index;
	OSD_Position(OSD_ENABLE);
	OSD_Clear(5, 11, 15, 1);	//Need to be modified case by case.
	if( ucOSD_Page_Index == 1)
		RTDOSDW(OSD_Window_Setting);
}

void Show_Osd_Page(unsigned char Page_Num,unsigned char* Page_Attr,unsigned char OSD_Table_Num)
{
	Init_Page(Page_Num);
	RTDOSDW(Page_All_Atb);
	RTDOSDW(OSD_PAGE_All_TABLE[0][stGUD1.FUNCTION & 0x07]);
	RTDOSDW(Page_Attr);
	RTDOSDW(OSD_PAGE_TABLE[OSD_Table_Num][stGUD1.FUNCTION & 0x07]);
	Show_Mode();
}

void OSD_Clear(unsigned char row_start, unsigned char height, unsigned char col_start, unsigned char width)
{
	width = width;
	if (height)
	{
		do
		{
			OSD_Line(row_start, col_start, Row_Info[0][row_start+1], 0x00, 3);
			//OSD_Line(row_start, col_start, width, 0x00, 3);
			row_start++;
		}
		while (--height);
	}
}

void Bright_Contrast_Adjust(unsigned char* variable,unsigned char Key)
{
	if (NOTIFY_RIGHT_KEY == Key)
	{
		if (100 <= *variable)
			return;
 
		if (KEY_TURBO_ENABLE > ucKey_Issued)
			*variable   = 100 > *variable ? *variable + 1 : 100;
		else
			*variable   = 99 > *variable ? *variable + 2 : 100;
	}
	else
	{
		if (0 == *variable)
			return;

		if (KEY_TURBO_ENABLE > ucKey_Issued)
			*variable   = 0 < *variable ? *variable - 1 : 0;
		else
			*variable   = 1 < *variable ? *variable - 2 : 0;
	}
}

void Osd_Change_Item(unsigned char Pess_Key,unsigned char Item_Num)
{
	if (ucOSD_Item_Index0)
	{
		// Select and highlight the next/previous item
		//OSD_Window( 6, 150, 282, (54 + (ucOSD_Item_Index0-1)*(29+4)), (84 + (ucOSD_Item_Index0-1)*(29+4))
		//	, 0, 0, 14, 251, 0, 1, 0);
		if (NOTIFY_RIGHT_KEY == Pess_Key)
			ucOSD_Item_Index0   = (Item_Num == ucOSD_Item_Index0) ? 1 : (ucOSD_Item_Index0 + 1);
		else

⌨️ 快捷键说明

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