📄 api_osd.c
字号:
#include "..\INC\SYS_DECLARE.H"
#include "..\INC\SYS_GLOBAL.H"
#include "INC\API_IIC.H"
#include "INC\API_REG.H"
#include "INC\API_OSD.H"
#include "INC\API_PANEL.H"
void API_OSD_Enable(BOOL flag)
{
if(flag) API_SC_WriteByte(REG_SC_OSD_CTRL, 0x1D); // Set enable bit.
else API_SC_WriteByte(REG_SC_OSD_CTRL, 0x1C); // Set disable bit.
}
//--------------------------------------------------------------------------
void API_OSD_Initial(void)
{
gbTrmBuf[0] = 0x00; // REG_SC_OSD_SYS_CTRL
gbTrmBuf[1] = 0x00; // REG_SC_SPACECODE
gbTrmBuf[2] = 0x00; // REG_SC_OSD_DIS_OPT1
gbTrmBuf[3] = 0x06; // REG_SC_OSD_HPOS
gbTrmBuf[4] = 0x00; // REG_SC_OSD_VPOS
gbTrmBuf[5] = 0x00; // REG_SC_OSD_CTRL2
gbTrmBuf[6] = 0x1c; // REG_SC_OSD_CTRL
gbTrmBuf[7] = 0x00; // REG_SC_OSD_DIS_OPT2
gbTrmBuf[8] = 0x00; // REG_SC_OSDWIN_ADDR
API_IIC_WriteBurst(DEV_SC_ADDR, REG_SC_OSD_SYS_CTRL, 9);
API_SC_WriteByte(REG_SC_CLUT_ALPHA, gScalerPara.bOsdAlphaBlind);
API_OSD_SetRowAttr(0, 0x00, 0x15);
API_OSD_ClearRow(0, 15, 0);
API_OSD_DisableWindow(0);
API_OSD_DisableWindow(1);
API_OSD_DisableWindow(2);
API_OSD_DisableWindow(3);
API_OSD_Enable(0);
}
//--------------------------------------------------------------------------
// Function : API_OSD_Window
// Description : draw a OSD window
// Input : bIdx -> Window index (0-3)
// bPos -> [0]: row start, [1]: row end
// [2]: col start, [3]: col end
// bCol -> R, G, B, index to CLUT
//--------------------------------------------------------------------------
void API_OSD_Window(BYTE bIdx, BYTE code *bPos, BYTE bColor)
{
BYTE bWinAddr = bIdx * 5;
BYTE bval;
API_SC_WriteByte(REG_SC_OSDWIN_ADDR, bWinAddr); // starting row
API_SC_WriteByte(REG_SC_OSDWIN_DATA, *bPos);
API_SC_WriteByte(REG_SC_OSDWIN_ADDR, bWinAddr+1); // ending row
API_SC_WriteByte(REG_SC_OSDWIN_DATA, *(bPos+1));
bval = ((*(bPos+2)) << 4) + 0x04;
API_SC_WriteByte(REG_SC_OSDWIN_ADDR, bWinAddr+2); // starting column
API_SC_WriteByte(REG_SC_OSDWIN_DATA, bval);
bval = ((*(bPos+3)) << 4) + (bColor >> 2);
API_SC_WriteByte(REG_SC_OSDWIN_ADDR, bWinAddr+3); // ending column
API_SC_WriteByte(REG_SC_OSDWIN_DATA, bval);
API_SC_WriteByte(REG_SC_OSDWIN_ADDR, bWinAddr+4); // window shadow
API_SC_WriteByte(REG_SC_OSDWIN_DATA, 0x00);
}
//--------------------------------------------------------------------------
// Function : API_OSD_DisableWindow
// Description : disable a OSD window
// Input : bIndex -> Window index (0-3)
//--------------------------------------------------------------------------
void API_OSD_DisableWindow(BYTE bIndex)
{
bIndex *= 5;
API_SC_WriteByte(REG_SC_OSDWIN_ADDR, bIndex+2);
API_SC_WriteByte(REG_SC_OSDWIN_DATA, 0x08);
}
//--------------------------------------------------------------------------
// Function : API_OSD_SetRowAttr
// Description : set OSD row attribute
// Input : row -> select row
// attr_hi -> high attribute
// attr_lo -> low attribute
//--------------------------------------------------------------------------
void API_OSD_SetRowAttr(BYTE bRow, BYTE bAttrHigh, BYTE bAttrLow)
{
if(bRow < 8) API_SC_WriteByte(REG_SC_OSD_AD0, bRow << 5);
else if(bRow < 16) API_SC_WriteByte(REG_SC_OSD_AD1, (bRow-8) << 5);
else API_SC_WriteByte(REG_SC_OSD_AD2, (bRow-16) << 5);
// Write attribute
API_SC_WriteByte(REG_SC_FONT_AT, bAttrLow);
API_SC_WriteByte(REG_SC_FONT_DT, bAttrHigh);
}
//--------------------------------------------------------------------------
// Function : API_OSD_SetAddress
// Description : Set OSD active RAM index address
// Input : bRow -> Y position
// bCol -> X position
//--------------------------------------------------------------------------
void API_OSD_SetAddress(BYTE bRow, BYTE bCol)
{
if(bRow < 8)
{
bRow = (bRow<<5) + bCol + 1;
API_SC_WriteByte(REG_SC_OSD_AD0, bRow);
}
else if( bRow < 16 )
{
bRow = ((bRow-8)<<5) + bCol+1;
API_SC_WriteByte(REG_SC_OSD_AD1, bRow);
}
else
{
bRow = ((bRow-16)<<5) + bCol+1;
API_SC_WriteByte(REG_SC_OSD_AD2, bRow);
}
}
//--------------------------------------------------------------------------
// Function : API_OSD_ClearRow
// Description : clear row data
// Input : bVstart -> startRow
// bVend -> endRow
//--------------------------------------------------------------------------
void API_OSD_ClearRow(BYTE bVstart, BYTE bVend, BYTE bAttr)
{
BYTE i;
for(i = 0; i < 15; i++) gbTrmBuf[i] = __;
for(i = bVstart; i <= bVend; i++)
{
API_OSD_SetAddress(i, 0); // Set starting address
API_SC_WriteByte(REG_SC_FONT_AT, bAttr);
API_IIC_WriteBurst(DEV_SC_ADDR, REG_SC_FONT_DT, 15);
API_IIC_WriteBurst(DEV_SC_ADDR, REG_SC_FONT_DT, 15);
API_IIC_WriteBurst(DEV_SC_ADDR, REG_SC_FONT_DT, 1);
}
}
//--------------------------------------------------------------------------
// Function : API_OSD_ClearArea
// Description : clear area data
// Input : (bHstart,bVstart) -> (x1,y1)
// (bHend , bVend ) -> (x2,y2)
//--------------------------------------------------------------------------
void API_OSD_ClearArea(BYTE bVstart, BYTE bVend, BYTE bHstart, BYTE bHend, BYTE bAttr)
{
BYTE i, j;
// set upper boundary to avoid wrap effect.
bHend = (bHend > 31) ? 31 : bHend;
bVend = (bVend > 19) ? 19 : bVend;
API_SC_WriteByte(REG_SC_FONT_AT, bAttr);
for(i = bVstart; i <= bVend; i++)
{
API_OSD_SetAddress(i, bHstart); // set starting address
for(j = 0; j <= (bHend - bHstart); j++)
API_SC_WriteByte(REG_SC_FONT_DT, __);
}
}
//--------------------------------------------------------------------------
// Function : API_OSD_SetPosition
// Description : Set OSD display position
// Input : (hpos,vpos) -> (x,y)
//--------------------------------------------------------------------------
void API_OSD_SetPosition(BYTE bHpos, BYTE bVpos)
{
API_SC_WriteByte(REG_SC_OSD_HPOS, bHpos);
API_SC_WriteByte(REG_SC_OSD_VPOS, bVpos);
}
//--------------------------------------------------------------------------
// Function : API_OSD_WriteChar
// Description : Output a char to current address
// Input : bFontIdx -> Font data
// bAttr -> Font attribute
//--------------------------------------------------------------------------
void API_OSD_WriteChar(BYTE bFontIdx, BYTE bAttr)
{
API_SC_WriteByte(REG_SC_FONT_AT, bAttr);
API_SC_WriteByte(REG_SC_FONT_DT, bFontIdx);
}
//--------------------------------------------------------------------------
// Function : API_OSD_PrintString
// Description : Print a string in OSD. The pRomData pointer is first character
// Input : pRomData -> array of string head
// (col,row) -> (x,y) Print position
//--------------------------------------------------------------------------
void API_OSD_PrintString(BYTE bRow, BYTE bCol, BYTE bColor, BYTE code *pRomData)
{
BYTE i, bData, bX;
if(*pRomData == _EOF) return;
bX = bCol;
WriteLoop:
bRow &= 0x0F; // mask off other attribute
API_OSD_SetAddress(bRow, bCol); // set starting address
API_SC_WriteByte(REG_SC_FONT_AT, bColor);
i = 0;
while(1)
{
bData = *pRomData++;
if(bData == _EOF) break;
if(bData == _CR_LF)
{
bRow++;
bCol = bX;
goto WriteLoop;
}
API_SC_WriteByte(REG_SC_FONT_DT, bData);
bCol++;
if(bCol >= 30) break; // avoid overflow
}
}
//--------------------------------------------------------------------------
// Function : API_OSD_LoadFont
// Purpose : Load font code into Vipor internal OSD
//--------------------------------------------------------------------------
void API_OSD_LoadFont(BYTE bFontIndex, BYTE code *pRomData)
{
BYTE it, byte_0, byte_1, byte_2;
API_SC_WriteByte(REG_SC_FONT_ADDR, bFontIndex);
for(it = 0; it < 8; it++)
{
byte_0 = *pRomData++;
byte_1 = *pRomData++;
byte_2 = *pRomData++;
gbTrmBuf[0] = (byte_0 << 4) + (byte_1 >> 4);
gbTrmBuf[1] = (byte_0 >> 4);
API_IIC_WriteBurst(DEV_SC_ADDR, REG_SC_FONT_LSB, 2);
gbTrmBuf[0] = byte_2;
gbTrmBuf[1] = (byte_1 & 0x0F);
API_IIC_WriteBurst(DEV_SC_ADDR, REG_SC_FONT_LSB, 2);
}
}
void API_OSD_LoadCLUT(BYTE code *pData)
{
BYTE i;
// Reload CLUT address
API_SC_WriteByte(REG_SC_OSDLUT_ADDR, 0x00);
API_SC_WriteByte(REG_SC_OSDLUT_ADDR, 0x80);
API_SC_WriteByte(REG_SC_OSDLUT_ADDR, 0x00);
// *** Write Color-Lookup-Table ***
for(i = 0; i < 16; i++)
{
API_SC_WriteByte(REG_SC_OSD_LUT, *(pData+i*2+1)); // Low byte
API_SC_WriteByte(REG_SC_OSD_LUT, *(pData+i*2)); // High byte
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -