📄 gmiosdfunc.c
字号:
#define __OSD_FUNC__
#include "Core\Header\Include.h"
//---------------------------------------------------------------------------
void SetOsdMap(unsigned char *tOsdMap)
{
pOsdMap = tOsdMap;
SetOSDRamAddress();
SetRowCmds();
}
//---------------------------------------------------------------------------
void SetOSDRamAddress()
{
unsigned int iFontSelectAddress;
unsigned int iFntBaseAddr;
iFontSelectAddress = GET_OSD_MAP_FONT_SELECT_ADDRESS();
iFntBaseAddr = GET_OSD_MAP_FONTBASEADDRESS();
//CUartPrintf("FontSelectAddress:",iFontSelectAddress);
//CUartPrintf("FntBaseAddr:",iFntBaseAddr);
pData[0] = 0xc0;
pData[1] = 0x04;
CScalerWrite(_OSD_ADDR_MSB_90, 2, pData, _AUTOINC);
pData[0] = iFontSelectAddress & 0xff;
pData[1] = ((iFontSelectAddress >> 4) & 0xf0) | (iFntBaseAddr & 0x0f);
pData[2] = ((iFntBaseAddr >> 4) & 0xff);
CScalerWrite(_OSD_DATA_PORT_92, 3, pData, _NON_AUTOINC);
}
//---------------------------------------------------------------------------
void DirectWOSDRam(WORD iAddress, WORD iLen, BYTE TheByte, BYTE Value)
{
pData[0] = TheByte | ((iAddress >> 8) & 0x0f);
pData[1] = (BYTE)(iAddress & 0xff);
CScalerWrite(_OSD_ADDR_MSB_90, 2, pData, _AUTOINC);
if(TheByte == ALL_BYTE)
iLen *= 3;
CScalerSendAddr(_OSD_DATA_PORT_92 , _NON_AUTOINC);
while(iLen)
{
*(&MCU_SCA_INF_DATA_FFF5) = Value;
iLen--;
}
}
//-------------------------------------------------------------
void OutputChar(BYTE C)
{
CScalerSendAddr(_OSD_DATA_PORT_92 , _NON_AUTOINC);
*(&MCU_SCA_INF_DATA_FFF5) = C;
}
//-------------------------------------------------------------
void COsdColorPalette(BYTE *pColorPaletteArray)
{
CScalerSetByte(_OVERLAY_LUT_ADDR_6E, 0x80);
CScalerWrite(_COLOR_LUT_PORT_6F, 48, pColorPaletteArray, _NON_AUTOINC);
CScalerSetByte(_OVERLAY_LUT_ADDR_6E, 0x00);
}
//-------------------------------------------------------------
void SetRowCmds()
{
unsigned char i;
unsigned char ucRowCnt = GET_OSD_MAP_ROWCOUNT();
// Row Command Byte 0
// 0x80
// Character border/shadow 000: None
// Double character width 0: 0x01
// Double character height 0: 0x01
DirectWOSDRam(0x00,ucRowCnt,THE_BYTE0,0x80);
//Row End Command
OutputChar(0x00);
//Row Command Byte 1
// 0x90
// Row height (1~32) : 18
// Column space : 0
DirectWOSDRam(0x00,ucRowCnt,THE_BYTE1,0x88);
// Row Command Byte 2
// DirectWOSDRam(0x00,ucRowCnt,THE_BYTE2,ucRowLenght);
for(i=0;i<ucRowCnt;i++)
{
DirectWOSDRam(i,1,THE_BYTE2,GET_OSD_ROWLENGTH(i));
}
}
//---------------------------------------------------------------------------
void Gotoxy(unsigned char x,unsigned char y,unsigned char TheByte)
{
unsigned int iAddress = GET_OSD_MAP_FONT_SELECT_ADDRESS();
unsigned char i;
for(i=0;i<y;i++)
{
iAddress += GET_OSD_ROWLENGTH(i);
}
iAddress += x;
pData[0] = (unsigned char)(((iAddress >> 8 ) & 0x0f) | TheByte);
pData[1] = (unsigned char)(iAddress & 0xff);
CScalerWrite(_OSD_ADDR_MSB_90, 2, pData, _AUTOINC);
}
//---------------------------------------------------------------------------
/*
void PrintfDec(unsigned char Value)
{
unsigned char a[3];
if(Value / 100 > 0)
{
a[0] = (Value / 100) + '0';
a[1] = ((Value / 10) % 10) + '0';
a[2] = (Value % 10) + '0';
}
else if(Value / 10 > 0)
{
a[0] = 0;
a[1] = (Value / 10) + '0';
a[2] = (Value % 10) + '0';
}
else
{
a[0] = 0;
a[1] = 0;
a[2] = Value + '0';
}
CScalerWrite(_OSD_DATA_PORT_92, 3, a, _NON_AUTOINC);
}
//-------------------------------------------------------------
void PrintfInt(unsigned int Value)
{
unsigned char i,a[5];
bit fBegin = 0;
a[0] = (Value / 10000);
a[1] = ((Value / 1000) % 10);
a[2] = ((Value / 100) % 10);
a[3] = ((Value / 10) % 10);
a[4] = (Value % 10) + '0';
for(i=0;i<4;i++)
{
if(fBegin)
{
a[i] += '0';
}
else
{
if(a[i] != 0)
fBegin = 1;
}
}
CScalerWrite(_OSD_DATA_PORT_92, 5, a, _NON_AUTOINC);
}
//---------------------------------------------------------------------------
void PrintfHex(unsigned char Value)
{
unsigned char h,l,t;
t = (Value & 0x0f);
if(t < 10) l = t + '0';
else l = (t - 10) + 'A';
t = (Value >> 4) & 0x0f;
if(t < 10) h = t + '0';
else h = (t - 10) + 'A';
pData[0] = h;
pData[1] = l;
CScalerWrite(_OSD_DATA_PORT_92, 2, pData, _AUTOINC);
}
//---------------------------------------------------------------------------
*/
void COsdFxCloseWindow(BYTE ucWinID)
{
pData[0] = 0x81;
pData[1] = ucWinID * 4 + 3;
pData[2] = 0x00;
CScalerWrite(_OSD_ADDR_MSB_90, 3, pData, _AUTOINC);
}
//-------------------------------------------------------------
WORD ValueInRangeChange(WORD ucMin, WORD ucMax, WORD ucCur, BYTE ucOption)//BYTE ucOption, BYTE ucLoop)
{
WORD R;
if((ucOption & _INC) == _INC)
{
if(ucCur >= ucMax)
{
if((ucOption & _LOOP) == _LOOP) return ucMin;
else return ucMax;
}
R = ucCur + 1;
}
else
{
if(ucCur <= ucMin)
{
if((ucOption & _LOOP) == _LOOP) return ucMax;
else return ucMin;
}
R = ucCur - 1;
}
return R;
}
//-------------------------------------------------------------
void SetOSDDouble(BYTE ucAttr)
{
pData[0] = 0x40;
pData[1] = 0x03;
pData[2] = ucAttr;
CScalerWrite(_OSD_ADDR_MSB_90, 3, pData, _AUTOINC);
}
//-------------------------------------------------------------
void Textout(BYTE *Text)
{
CScalerSendAddr(_OSD_DATA_PORT_92, _NON_AUTOINC);
while(*Text != 0)
{
*(&MCU_SCA_INF_DATA_FFF5) = *Text++;
}
}
//---------------------------------------------------------------------------
void SetCharWdith(BYTE Index,BYTE Value)
{
BYTE t = Index / 2;
if(Index % 2)
{
// 1 3 5 7 9 ... 存在高 4 位
g_ucCharWidth[t] = (g_ucCharWidth[t] & 0x0f) | (Value << 4);
}
else
{
// 0 2 4 6 8 ... 存在低 4 位
g_ucCharWidth[t] = (g_ucCharWidth[t] & 0xf0) | Value;
}
}
//---------------------------------------------------------------------------
BYTE GetCharWdith(BYTE Index)
{
BYTE w;
BYTE t = Index / 2;
if(Index % 2)
{
// 1 3 5 7 9 ... 存在高 4 位
w = (g_ucCharWidth[t] & 0xf0) >> 4;
}
else
{
// 0 2 4 6 8 ... 存在低 4 位
w = g_ucCharWidth[t] & 0x0f;
}
return w;
}
//---------------------------------------------------------------------------
void CSetBlankWidth(BYTE x,BYTE y,BYTE ucWidth)
{
//设置 Blank
Gotoxy(x,y,ALL_BYTE);
pData[0] = 0x00;
pData[1] = ucWidth;
//pData[2] = ucBlankColor;
//pData[2] = 0x09;
CScalerWrite(_OSD_DATA_PORT_92, 2, pData, _NON_AUTOINC);
}
//---------------------------------------------------------------------------
BYTE CTextOutBase(BYTE *str,BYTE x,BYTE y)
{
BYTE i,ucStrLen;
BYTE ucCharWidth;
WORD ucPixLen = 0;
// Step 1: Display Menu Item
Gotoxy(x,y,BYTE_DISPLAY);
Textout(str);
// Step 2: Set Char Width
ucStrLen = StrLen(str);
Gotoxy(x,y,BYTE_ATTRIB);
CScalerSendAddr(_OSD_DATA_PORT_92, _NON_AUTOINC);
for(i=0;i<ucStrLen;i++)
{
ucCharWidth = GetCharWdith(*str++);
//CScalerSendByte(0x80 | ucCharWidth);
*(&MCU_SCA_INF_DATA_FFF5) = 0x80 | ucCharWidth;
ucPixLen += ucCharWidth;
}
//CScalerSendWriteStop();
// calc blank wdith
//ucPixLen %= 12;
//if(ucPixLen < 4)
// ucPixLen += 12;
return ucPixLen;
}
//---------------------------------------------------------------------------
void CTextOutEx(BYTE *str,BYTE x,BYTE y)
{
BYTE ucStrLen = StrLen(str);
BYTE ucWidth = CTextOutBase(str,x,y);
ucWidth = 12 - (ucWidth % 12);
if(ucWidth < 4)
ucWidth += 12;
CSetBlankWidth(x + ucStrLen,y,ucWidth);
}
//---------------------------------------------------------------------------
void CTextOutRightAlign(BYTE *str,BYTE x,BYTE y)
{
BYTE ucWidth;
BYTE ucStrLen = StrLen(str);
if(ucStrLen > x - 1)
{
x = 1;
}
else
{
x = x - ucStrLen;
}
ucWidth = CTextOutBase(str,x,y);
ucWidth = 12 - (ucWidth % 12);
if(ucWidth < 4)
ucWidth += 12;
CSetBlankWidth(x - 1,y,ucWidth);
}
//---------------------------------------------------------------------------
void CCenterTextout(BYTE *str,BYTE y,BYTE ucSta,BYTE ucCharWidth)
{
WORD usLen = CCalcTextPixcelLen(str);
BYTE x;
usLen = (((WORD)ucCharWidth * 12) - usLen);
x = usLen / 24 + ucSta;
if((usLen % 12) >= 6)
{
x++;
}
//usLen = (((WORD)ucCharWidth * 12) - usLen) / 24 + ucSta; // 24 = 12 * 2
CTextOutEx(str, x, y);
}
//---------------------------------------------------------------------------
WORD CCalcTextPixcelLen(BYTE *str)
{
WORD usPixcelLen = 0;
while(*str)
{
usPixcelLen += GetCharWdith(*str++);
}
return usPixcelLen;
}
//---------------------------------------------------------------------------
void CShowNumber(BYTE x,BYTE y,BYTE Value)
{
unsigned char a[4];
BYTE ucWdith;
if(Value / 100 > 0)
{
a[0] = (Value / 100) + '0';
a[1] = ((Value / 10) % 10) + '0';
a[2] = (Value % 10) + '0';
}
else if(Value / 10 > 0)
{
a[0] = (Value / 10) + '0';
a[1] = (Value % 10) + '0';
a[2] = 0x01;
}
else
{
a[0] = Value + '0';
a[1] = 0x01;
a[2] = 0x01;
}
a[3] = 0x00;
ucWdith = CTextOutBase(a,x,y);
CSetBlankWidth(x + 3,y,ucWdith);
}
#if(_FAC_OSD)
void CFacShowNumber(BYTE x,BYTE y,BYTE Value)
{
unsigned char a[4];
if(Value / 100 > 0)
{
a[0] = (Value / 100) + '0';
a[1] = ((Value / 10) % 10) + '0';
a[2] = (Value % 10) + '0';
}
else if(Value / 10 > 0)
{
a[0] = (Value / 10) + '0';
a[1] = (Value % 10) + '0';
a[2] = 0x01;
}
else
{
a[0] = Value + '0';
a[1] = 0x01;
a[2] = 0x01;
}
a[3] = 0x00;
Gotoxy( x, y, BYTE_DISPLAY);
Textout(a);
// TextOutCalcWidth(a, y, x,4,4*12);
}
#endif
//---------------------------------------------------------------------------
// 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 OSDPosition(WORD usOsdActWidth, WORD usOsdActHeight, BYTE ucHPos, BYTE ucVPos, BYTE ucPar)
{
if(ucHPos > 100)
ucHPos = 50;
if(ucVPos > 100)
ucVPos = 50;
usOsdActWidth = _OSD_HPOSITION_OFFSET +
(DWORD)(Panel[ucPanelSelect]->DHStartPos / 4) +
(DWORD)(ucHPos * (Panel[ucPanelSelect]->DHWidth / 4 - usOsdActWidth/4 - 7)) / 100;
usOsdActHeight = _OSD_VPOSITION_OFFSET +
(DWORD)(Panel[ucPanelSelect]->DVStartPos / 4) +
(DWORD)(ucVPos * (Panel[ucPanelSelect]->DVHeight / 4 - usOsdActHeight/4 - 6)) / 100;
CScalerSetBit(_OSD_SCRAMBLE_93, 0xf8, 0x02);
pData[0] = CScalerGetBit(_OVERLAY_CTRL_6C, _BIT0);
pData[0] = (pData[0] == 0x00) ? 0xc0 : 0xe0;
pData[1] = 0x00;
CScalerWrite(_OSD_ADDR_MSB_90, 2, pData, _AUTOINC);
pData[0] = usOsdActHeight >> 1;
pData[1] = (UINT8) (usOsdActWidth >> 2);
pData[2] = ((UINT8) (usOsdActWidth & 0x0003) << 6) | ((usOsdActHeight & 0x01) << 5) | ucPar;
CScalerWrite(_OSD_DATA_PORT_92, 3, pData, _NON_AUTOINC);
CTimerWaitForEvent(_EVENT_DEN_STOP);
CTimerWaitForEvent(_EVENT_DEN_STOP);
CScalerSetBit(_OSD_SCRAMBLE_93, 0xf8, 0x05);
}
//---------------------------------------------------------------------------
void OSDLine(BYTE row, BYTE col, BYTE length, BYTE value, BYTE TheByte)
{
BYTE ucRowCharLength = GET_OSD_ROWLENGTH(row);
//if(ucRowCharLength < col) return;
if(ucRowCharLength < (col + length))
{
length = ucRowCharLength - col;
}
Gotoxy(col,row,TheByte);
if(TheByte == ALL_BYTE)
{
length *= 3;
}
CScalerSendAddr(_OSD_DATA_PORT_92, _NON_AUTOINC);
while(length)
{
*(&MCU_SCA_INF_DATA_FFF5) = value;
length--;
}
}
//---------------------------------------------------------------------------
void OSDClear(BYTE row_start, BYTE height,
BYTE col_start, BYTE width,
BYTE Value, BYTE indicate)
{
if (height)
{
do
{
OSDLine(row_start, col_start, width, Value, indicate);
row_start++;
}
while (--height);
}
}
//---------------------------------------------------------------------------
/*
void OutputDisplaySize()
{
//unsigned int usHwid;
//Data[0] 长度不定所以在后面才能得到
//pData[1] = N_INC;
//pData[2] = _OSD_DATA_PORT_92;
if(stModeInfo.IHWidth / 1000) pData[0] = '1';
else pData[0] = 0;
pData[1] = (unsigned char)((stModeInfo.IHWidth / 100) % 10) + '0';
pData[2] = (unsigned char)((stModeInfo.IHWidth / 10) % 10) + '0';
pData[3] = (unsigned char)(stModeInfo.IHWidth % 10) + '0';
Gotoxy(2,11,BYTE_DISPLAY);
CScalerWrite(_OSD_DATA_PORT_92, 4, pData, _NON_AUTOINC);
if(stModeInfo.IVHeight / 1000)
pData[0] = '1';
else
pData[0] = 0;
pData[1] = (unsigned char)((stModeInfo.IVHeight / 100) % 10) + '0';
pData[2] = (unsigned char)((stModeInfo.IVHeight / 10) % 10) + '0';
pData[3] = (unsigned char)(stModeInfo.IVHeight % 10) + '0';
Gotoxy(10,11,BYTE_DISPLAY);
CScalerWrite(_OSD_DATA_PORT_92,4,pData,_NON_AUTOINC);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -