📄 lcd_osd.c
字号:
#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"
#include "Header\rgb_echo.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 (5 <= ucPageCurr) ? 1 : ucPageCurr + 1;
case SOURCE_DVI :
return (5 <= 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) ? 5 : ucPageCurr - 1;
case SOURCE_DVI :
return (1 >= ucPageCurr) ? 5 : 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);
}
/////////////////////////////////////////////////////////////////////////////////////
//anson
/////////////////////////////////////////////////////////////////////////////////////
void OSD_Fact_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 += FactRow_Info[0][ucTemp];
Data[0] = 5;
Data[1] = Y_INC;
Data[2] = OSD_ADDR_MSB_90;
if( (col+1) > FactRow_Info[0][row + 1]) // if column_start > row_length, then return
return;
else if((col + 1 + length) > FactRow_Info[0][row + 1]) // if column_start + length > row_length, then re-calculate the length
length = FactRow_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_Fact_Clear(unsigned char row_start, unsigned char height, unsigned char col_start, unsigned char width)
{
width = width;
if (height)
{
do
{
OSD_Fact_Line(row_start, col_start, FactRow_Info[0][row_start+1], 0x00, 3);
//OSD_Line(row_start, col_start, width, 0x00, 3);
row_start++;
}
while (--height);
}
}
void ShowValue(unsigned char row, unsigned char col,unsigned char value, unsigned char color)
{
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 += FactRow_Info[0][ucTemp];
Data[10] = value/100;
Data[11] = (value - (Data[10]*100))/10;
Data[12] = value - (Data[10]*100) - (Data[11]*10);
if(0 != Data[10])
{
Data[10] += _0_;
Data[11] += _0_;
}
else
{
if(0 != Data[11]) Data[11] += _0_;
}
Data[12] += _0_;
//Byte1
Data[0] = 5;
Data[1] = Y_INC;
Data[2] = OSD_ADDR_MSB_90;
Data[3] = (unsigned char)( ((usStart_Addr + col) & 0x0fff) >> 8 ) | 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] = Data[10];
Data[4] = Data[11];
Data[5] = Data[12];
Data[6] = 0;
RTDWrite(Data);
//Byte2
Data[0] = 5;
Data[1] = Y_INC;
Data[2] = OSD_ADDR_MSB_90;
Data[3] = (unsigned char)( ((usStart_Addr + col) & 0x0fff) >> 8 ) | 0x90;
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;
Data[4] = color;
Data[5] = color;
Data[6] = 0;
RTDWrite(Data);
}
void Value_Adjust(unsigned char *Var, unsigned char Key, unsigned char VMax, unsigned char VMin)
{
if(NOTIFY_LEFT_KEY == Key)
{
if(bKeyTurbo)
*Var = (*Var < (VMax - 1)) ? (*Var + 2) : VMax;
else
*Var = (*Var < VMax) ? (*Var + 1) : VMax;
}
else
{
if(bKeyTurbo)
*Var = (*Var > (VMin + 1)) ? *Var - 2 : VMin;
else
*Var = (*Var > VMin) ? (*Var - 1) : VMin;
}
}
void SPREAD_Adjust(unsigned char* variable,unsigned char Key)
{
if (NOTIFY_LEFT_KEY == Key)
{
if (15 <= *variable)
return;
if (!bKeyTurbo)
*variable = 15 > *variable ? *variable + 1 : 15;
else
*variable = 14 > *variable ? *variable + 2 : 15;
}
else
{
if (0 == *variable)
return;
if (!bKeyTurbo)
*variable = 0 < *variable ? *variable - 1 : 0;
else
*variable = 1 < *variable ? *variable - 2 : 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
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();
}
if(ucOSD_Page_Index == PAGE_Factory) //anson
{
stGUD1.OSD_POSH = 230;
stGUD1.OSD_POSV = 100;
}
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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -