📄 osddraw.c
字号:
#include <reg51.h>
#include "common.h"
#include "System.h"
#include "Resolution.h"
#include "SRC_ctrl.h"
#include "OSDDraw.h"
#include "Keypad.h"
#include "TwoWire.h"
#include "TW803Reg.h"
#include "OSDCtrl.h"
#include "OSDDRAW.h"
#include "Tuner.h"
#include "timer0.h"
#include "T803_Util.h"
#define __GLOBAL_H__
#include "Global.h"
#ifndef T118
#include "T803OSD.h"
#endif
#define __INIT_H__
#include "init.h"
#include "OSDTbl.h"
#include "OSDMenu.h"
#include "intrins.h"
void OSDLoadColor(void)
{
uCHAR i;
I2CWriteByte(TW803_P0,OSD_CFG_INDEX,OSD_LUT_RAM_DATA);
for(i=0;i<32;i++)
I2CWriteByte(TW803_P0,OSD_CFG_DATA,cOSDMenuLutData[i]);
}
void OSDSetRamAddr(uWORD address)
{
I2CWriteByte(TW803_P0,OSD_RAM_AH,(uCHAR)(address>>8));
I2CWriteByte(TW803_P0,OSD_RAM_AL,(uCHAR)(address & 0xff));
}
void OSDEnable(void)
{
m_bOSDEnable = 1;
OSDCfgWr(OSD_CTRL,0x84);
I2CWriteByte(TW803_P0,0xE2,0x11);
#ifdef TIMER0
Timer0Start();
#endif
}
void OSDDisable(void)
{
#ifdef TIMER0
Timer0Stop();
#endif
OSDCfgWr(OSD_CTRL,0x18);
m_cOSDMenu=idNULLMENU;
m_cItem=0;
m_bOSDEnable=0;
m_cCurreKey=m_cPreKey=0xFF;
}
void OSDExit(void)
{
OSDCfgWr(0x10,0x00);
OSDDisable();
}
void OSDOpenMenu(void)
{
OSDClearPage();
OSDPosition(CENTER);
OSDShowPage();
}
void OSDFuncExit(void)
{
}
void OSDShowPage(void)
{
uCHAR y,str_index;
uCHAR item_num=ALL_MENU[m_cOSDMenu]->Item_Num;
OSDReadData(idPUBMENU);
str_index=ALL_MENU[m_cOSDMenu]->Item_Num*EepPublic.cOSDLang;
for(y=0;y<item_num;y++)
{
OSDShowLine(iBlankLine_E,0,y,COL_NORMAL,OSD_LENGTH);
OSDShowLine(ALL_MENU[m_cOSDMenu]->str[y+str_index],TXT_STAT,y,COL_NORMAL,OSD_LENGTH);
if(ALL_MENU[m_cOSDMenu]->Par[y].cDataAttr&OSD_VALUE)
OSDDrawNum(ALL_MENU[m_cOSDMenu]->EEProm[y],ALL_MENU[m_cOSDMenu]->Par[y].ucValMAX,NUM_STAT,y,COL_NORMAL,DRAW_BLANK);
// if((ALL_MENU[m_cOSDMenu]->Par->cDataAttr&OSD_ITEM)&&(((uCHAR *)ALL_MENU[m_cOSDMenu]->Par[y].Item)!=NULL))
if((ALL_MENU[m_cOSDMenu]->Par[y].cDataAttr&OSD_ITEM)&&(((uCHAR *)ALL_MENU[m_cOSDMenu]->Par[y].Item)!=NULL))
OSDShowItem((uCHAR *)ALL_MENU[m_cOSDMenu]->Par[y].Item[(ALL_MENU[m_cOSDMenu]->EEProm[y])], ITEM_STAT, y);
}
for(y=0;y<GUAGE_GAP;y++)
OSDShowLine(iBlankLine_E,0,y+item_num,COL_NORMAL,OSD_LENGTH);
OSDMoveCursor();
OSDEnable();
}
void OSDCleanLine(uCHAR x,uCHAR y,uCHAR cColor,uCHAR cLength)
{
if((x < 30) && ( y < OSD_LINE_NUM))
{
OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)y << 5)+x);
twdWr_Burst_A(OSD_RAM_DL); // Write OSD index
while((x < 30) && (x < cLength))
{
twdWr_Burst_D(BLANK);
twdWr_Burst_D(cColor);
x++;
}
twdWr_Burst_P();
}
}
void OSDClearPage(void)
{
uCHAR i=0;
for(i=0;i<OSD_LINE_NUM;i++)
{
OSDCleanLine(0,i,0,30);
OSDSetLineAttribute(i,0x80);
}
if ( VBI_ON )
OSDCfgWr(ALPHA_BLD_CTRL,0x80);
else
OSDCfgWr(ALPHA_BLD_CTRL,0x83);
}
void OSDSetLineAttribute(uCHAR cLine,uCHAR cAttribute)
{
OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)cLine << 5)+31);
twdWr_Burst_A(OSD_RAM_DL); // Write OSD index
twdWr_Burst_D(0);
twdWr_Burst_D(cAttribute);
twdWr_Burst_P();
}
#ifdef lucy_edition
#ifdef TV //lucy for tv add
extern bit m_bTV_Num_Bits;
void OSDShowTV_Num(uCHAR cTemp)
{
uCHAR cTemp1;
OSDExit();
OSDPosition(RIGHT_TOP);
cTemp1=I2CReadByte(EEPVIDEOBLOCK, idVIDEO_FLAG_INDEX)&0x06;
OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)1<<5)+19);
twdWr_Burst_A(OSD_RAM_DL);
switch((cTemp|cTemp1))
{
case 0: OSDNumConvert(m_cTV_Num);
twdWr_Burst_D(COL_NORMAL);//Kuo
break;
case 2: if(m_bTV_Num_Bits)
{
OSDNumConvert(m_cTV_Num/10);
twdWr_Burst_D(COL_NORMAL);
OSDNumConvert(m_cTV_Num%10);
twdWr_Burst_D(COL_NORMAL);
}
else
{
OSDNumConvert(m_cTV_Num);
twdWr_Burst_D(COL_NORMAL);
twdWr_Burst_D(0x1B);
twdWr_Burst_D(COL_NORMAL);
}
break;
case 4: OSDNumConvert(1);
twdWr_Burst_D(COL_NORMAL);
if(m_bTV_Num_Bits)
{
OSDNumConvert((m_cTV_Num%100)/10);
twdWr_Burst_D(COL_NORMAL);//Kuo
OSDNumConvert(m_cTV_Num%10);
twdWr_Burst_D(COL_NORMAL);//Kuo
}
else
{
OSDNumConvert(m_cTV_Num%10);
twdWr_Burst_D(COL_NORMAL);//Kuo
twdWr_Burst_D(0x1B);
twdWr_Burst_D(COL_NORMAL);//Kuo
}
break;
case 6:if(cTemp1==4)
{
OSDNumConvert(1);
twdWr_Burst_D(COL_NORMAL);//Kuo
twdWr_Burst_D(0x1B);
twdWr_Burst_D(COL_NORMAL);
twdWr_Burst_D(0x1B);
twdWr_Burst_D(COL_NORMAL);
}
else if(cTemp1==2)
{
twdWr_Burst_D(0x1B);
twdWr_Burst_D(COL_NORMAL);
twdWr_Burst_D(0x1B);
twdWr_Burst_D(COL_NORMAL);
}
else
{
twdWr_Burst_D(0x1B);
twdWr_Burst_D(COL_NORMAL);
}
}
}
void OSDShowRESET(bit bTemp)
{
if(bTemp)
{
OSDShowLine(iBlankLine,0,6,COL_TITLE,OSD_LENGTH);
OSDShowLine(iRecall_E,3,6,COL_TITLE,OSD_LENGTH);
OSDShowLine(iOK,19,6,COL_TITLE,OSD_LENGTH);//Kuo
}
else
{
OSDShowLine(iBlankLine,0,6,COL_TITLE,OSD_LENGTH);
OSDShowLine(iRecalling_E,3,6,COL_TITLE,OSD_LENGTH);//Kuo
}
}
#endif
#endif
#ifdef _160_234
#define GAUGE_TOTAL_FONT_L 20 //10 //Long
#else
#define GAUGE_TOTAL_FONT_L 25 //Long
#endif
void OSDShowItem(uCHAR *str, uCHAR x,uCHAR y)
{
if(str !=NULL)
OSDShowLine(str,x,y,COL_GAUGE,OSD_LENGTH);
return;
}
/*
void OSDDrawGauge1(uCHAR cData, uCHAR cMax, uCHAR cMin, uCHAR cDef, uCHAR x, uCHAR y, uCHAR cColor)
{
int index,i,j;
int step_size=100/GAUGE_TOTAL_FONT_L;
OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)y<< 5)+x);
twdWr_Burst_A(OSD_RAM_DL); // Write OSD index
if(cMin>cDef)
{
cVal=
}
else
{
cVal=cData;
}
index= (int)cVal*GAUGE_TOTAL_FONT_L/((int)cMax-(int)cMin);
for(i=0;i<index;i++){
twdWr_Burst_D(11);
twdWr_Burst_D(cColor);
}
j=((int)cVal*100/(int)cMax)-index*step_size;
j=j/2;//2.5;
twdWr_Burst_D(8);
twdWr_Burst_D(cColor);
for(i=index+1;i<GAUGE_TOTAL_FONT_L;i++)
{
twdWr_Burst_D(8);
twdWr_Burst_D(cColor);
}
twdWr_Burst_P();
}
*/
void OSDDrawGauge(uCHAR cVal, uCHAR cMax, uCHAR x, uCHAR y, uCHAR cColor)
{
int index,i,j;
int step_size=100/GAUGE_TOTAL_FONT_L;
OSDSetRamAddr(MENU_RAM_START_ADDRESS+((int)y<< 5)+x);
twdWr_Burst_A(OSD_RAM_DL); // Write OSD index
index= (int)cVal*GAUGE_TOTAL_FONT_L/(int)cMax;
for(i=0;i<index;i++){
twdWr_Burst_D(11);
twdWr_Burst_D(cColor);
}
j=((int)cVal*100/(int)cMax)-index*step_size;
j=j/2;//2.5;
twdWr_Burst_D(8);
twdWr_Burst_D(cColor);
for(i=index+1;i<GAUGE_TOTAL_FONT_L;i++)
{
twdWr_Burst_D(8);
twdWr_Burst_D(cColor);
}
twdWr_Burst_P();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -