📄 lcd_osd.c
字号:
#define __OSD__
#include "Header\INCLUDE.H"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// OSD Export Function (Called outside Lcd_osd.c)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
void OSD_Dispatcher(unsigned char message)
{
switch (message)
{
case NOTIFY_NONE :
if (0 != ucOSD_Page_Index && 0 == usOSD_Timer && 0 != stGUD1.OSD_TIMEOUT)
{
if (SOURCE_TV != (stGUD1.INPUT_SOURCE & 0x07))
{
ucOSD_Page_Index = 0;
ucOSD_Item_Index0 = 0;
ucOSD_Item_Index1 = 0;
ucOSD_Item_Index2 = 0;
Clear_OSD();
}
}
break;
case NOTIFY_SHOW :
if (ucOSD_Page_Index)
{
Clear_OSD();
OSD_Main_Proc(NOTIFY_SHOW);
RTDCodeW(OSD_Enable);
RTDSetBit(OVL_CTRL_6D, 0xfc, 0x03);
}
break;
case NOTIFY_RESET_OSD :
ucOSD_Page_Index = 0;
ucOSD_Item_Index0 = 0;
ucOSD_Item_Index1 = 0;
ucOSD_Item_Index2 = 0;
Clear_OSD();
break;
case NOTIFY_CLEAR_OSD :
Clear_OSD();
break;
case NOTIFY_LOADFONT :
OSD_Load_Font();
break;
/*
case NOTIFY_MENU_KEY :
Select_Next_Input();
break;
*/
/*
case NOTIFY_SHOWLOGO :
// Not Ready Yet
break;
*/
default : // ENTER-KEY & LEFT-KEY & RIGHT-KEY ....
usOSD_Timer = (unsigned int)stGUD1.OSD_TIMEOUT * 51;
{
// Save the current OSD page index
unsigned char ucPage_Curr = ucOSD_Page_Index;
// Send messages to OSD process
OSD_Main_Proc(message);
// If OSD page is changed ...
if (ucPage_Curr != ucOSD_Page_Index)
{
if (ucOSD_Page_Index)
{
if (0 == ucPage_Curr) Clear_OSD();
OSD_Main_Proc(NOTIFY_SHOW);
if (0 == ucPage_Curr) OSD_Opening();
}
else
{
// OSD should be cleared when ucOSD_Page_Index becomes 0.
// Clear other OSD status registers for safety
ucOSD_Item_Index0 = 0;
ucOSD_Item_Index1 = 0;
ucOSD_Item_Index2 = 0;
OSD_Ending();
}
}
else
{
// OSD page is not changed
if (ucOSD_Page_Index)
{
// Change H/V Position and ADC clock may cause overflow/underflow temporarily.
if (NOTIFY_RIGHT_KEY == message || NOTIFY_LEFT_KEY == message)
{
RTDSetByte(STATUS0_01, 0x00); // Clear status
RTDSetByte(STATUS1_1F, 0x00); // Clear status
}
#if (SHOW_CHECK)
// Just for showing debug information
OSD_Show_Check();
#endif
}
}
}
break;
}
Show_Text(message);
}
bit Is_Main_OSD_Exist(void)
{
return ucOSD_Page_Index ? 1 : 0;
}
bit Is_Key_For_Wakeup(unsigned char message)
{
return (NOTIFY_MENU_KEY == message || NOTIFY_ENTER_KEY == message
|| NOTIFY_RIGHT_KEY == message || NOTIFY_LEFT_KEY == message) ? 1 : 0;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// OSD Static Function (Only called inside Lcd_osd.c)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
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 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);
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 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_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 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);
*/
Data[0] = 5;
Data[1] = Y_INC;
Data[2] = OSD_ADDR_MSB_90;
Data[3] = 0xef;
Data[4] = 0xff;
Data[5] = 9;
Data[6] = N_INC;
Data[7] = OSD_DATA_92;
Data[8] = 0x80;
Data[9] = 0x80 ;
Data[10] = 0x80 ;
Data[11] = stGUD1.OSD_POSV >> 1;
Data[12] = (unsigned char)(stGUD1.OSD_POSH >> 2);
Data[13] = ((unsigned char)(stGUD1.OSD_POSH & 0x0003) << 6) | ((stGUD1.OSD_POSV & 0x01) << 5) | para;
Data[14] = 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)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -