📄 osdctrl.c
字号:
//---------------------------------------------------------------------------
// Terawins Inc. Company Confidential Strictly Private
//
// $Archive: OSDCtrl.c $
// $Revision: 2.0 $
// $Author: jwang $
// $Date: 2003/08/13 $
//
// --------------------------------------------------------------------------
// >>>>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// --------------------------------------------------------------------------
// Copyright 2002 (c) Terawins Inc.
// This is an unpublished work.
// --------------------------------------------------------------------------
#include <reg51.h>
#include "common.h"
#include "Struct.h"
#include "System.h"
#include "SRC_ctrl.h"
#include "TW803Reg.h"
#include "OSDCtrl.h"
#include "TwoWire.h"
#include "OSDDraw.h"
#include "Keypad.h"
//#include "Video.h"
#include "Tuner.h"
#include "Global.h"
#include "NVRam.h"
#include "struct.h"
bit idata skipon=0;
void OSDItemAdj(uCHAR cAdj)
{
sCHAR sStep;
if(cAdj==INCREASE)
sStep=1;
else if(cAdj==DECREASE)
sStep=-1;
#ifdef LOAD_TIME
if(cAdj==INCREASE1)
{
AdjTimingB8(1);
return;
}
else if(cAdj==DECREASE1)
{
AdjTimingB8(-1);
return;
}
#endif
OSDItemAdjVideo(sStep);
}
//extern uCHAR idata m_cOSDMenu;
void OSDItemAdjVideo(sCHAR sStep)
{
if(m_cOSDMenu==idVIDEOMENU)
{
switch(m_cOSDFunc){
case idBRIGHTMENU:
AdjVideoBright(sStep);
break;
case idCONTRASTMENU:
AdjVideoContrast(sStep);
break;
case idSHARPMENU:
AdjVideoSharp(sStep);
break;
case idSATMENU:
AdjVideoSat(sStep);
break;
case idHUEMENU:
AdjVideoHue(sStep);
break;
#ifdef T112
case idRGBMENU: // add by Sherman 06'01'18
AdjVideoRGB(sStep);
break;
case idVCOMAMENU: // add by Sherman 06'01'23
AdjVideoVCOMA(sStep);
break;
case idVCOMDMENU: // add by Sherman 06'01'23
AdjVideoVCOMD(sStep);
break;
#endif
#ifdef LOAD_TIME
case idTIMEMENU:
AdjTimingB2(sStep);
break;
#endif
default :break;
}
}
#ifdef TV
else
{
switch(m_cOSDFunc){
case idCHANNEL_TV:
AdjTVChannel(sStep, 1);
break;
#ifdef PAL
case iSOUNDSYSTEM_TV:
AdjTVSoundSystem();
break;
#endif
#ifdef NTSC
case idSKIP_TV:
AdjTVSkip();
break;
case idSOURCE_TV:
AdjTVSource();
//OSDShowTVSource(sStep);
break;
#endif
case idFINETUNE_TV:
AdjTVFineTune(sStep);
break;
case idAUTOMEMORY_TV:
AutoMemory();
break;
case idRECALL_TV:
// OSDShowRESET(0);
ResetTVChannel();
// OSDShowRESET(1);
break;
default: break;
}
}
#endif
}
#if 0
void AdjVolume(sCHAR sStep)
{
if( (EepVideo.cVolume+sStep)<=sOSDParamsMax.cVolume
&&(EepVideo.cVolume+sStep)>=sOSDParamsMin.cVolume)
{
EepVideo.cVolume += sStep;
I2CWriteByte(TW803_P0, 0xE9, EepVideo.cVolume);
OSDShowVideoData();
if(EepVideo.cVolume==sOSDParamsMin.cVolume)
AUDIO_MUTE=1; //MUTE audio
else
AUDIO_MUTE=0; //open audio
}
#ifdef NVRAM
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_VOLUME_INDEX, EepVideo.cVolume);
#endif
return;
}
#endif
//extern uCHAR idata m_cStandard;
#ifdef LOADTIME
void AdjTimingB2(sCHAR sStep)
{
sStep=sStep;
if(I2CReadByte(TW803_P0,0xb2)+sStep>=0&&I2CReadByte(TW803_P0,0xb2)+sStep<=0xFF)
{
if(m_cStandard==S_NTSC)
{
EepVideo.cB2=I2CReadByte(TW803_P0,0xb2)+sStep;
EepVideo.cB8=I2CReadByte(TW803_P0,0xb8);
I2CWriteByte(TW803_P0,0xb2,EepVideo.cB2);
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_B8, EepVideo.cB8);
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_B2, EepVideo.cB2);
twdDelay(NVRDELAY);
EepVideo.cFlag=Panel_ID;
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_FLAG_INDEX, EepVideo.cFlag);
}
else if(m_cStandard==S_PAL)
{
EepVideo.cB2_PAL=I2CReadByte(TW803_P0,0xb2)+sStep;
EepVideo.cB8_PAL=I2CReadByte(TW803_P0,0xb8);
I2CWriteByte(TW803_P0,0xb2,EepVideo.cB2_PAL);
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_B8_PAL, EepVideo.cB8_PAL);
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_B2_PAL, EepVideo.cB2_PAL);
twdDelay(NVRDELAY);
EepVideo.cFlag_PAL=Panel_ID;
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_FLAG_INDEX1, EepVideo.cFlag_PAL);
}
twdDelay(NVRDELAY);
OSDShowVideoData();
}
}
void AdjTimingB8(sCHAR sStep)
{
sStep=sStep;
if(I2CReadByte(TW803_P0,0xb8)+sStep>=0&&I2CReadByte(TW803_P0,0xb8)+sStep<=0xFF)
{
if(m_cStandard==S_NTSC)
{
EepVideo.cB2=I2CReadByte(TW803_P0,0xb2);
EepVideo.cB8=I2CReadByte(TW803_P0,0xb8)+sStep;
I2CWriteByte(TW803_P0,0xb8,EepVideo.cB8);
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_B8,EepVideo.cB8);
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_B2,EepVideo.cB2);
twdDelay(NVRDELAY);
EepVideo.cFlag=Panel_ID;
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_FLAG_INDEX, EepVideo.cFlag);
}
else if(m_cStandard==S_NPAL)
{
EepVideo.cB2_PAL=I2CReadByte(TW803_P0,0xb2);
EepVideo.cB8_PAL=I2CReadByte(TW803_P0,0xb8)+sStep;
I2CWriteByte(TW803_P0,0xb8,EepVideo.cB8_PAL);
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_B8_PAL, EepVideo.cB8_PAL);
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_B2_PAL, EepVideo.cB2_PAL);
twdDelay(NVRDELAY);
EepVideo.cFlag_PAL=Panel_ID;
I2CWriteByte(EEPVIDEOBLOCK, idTIMING_FLAG_INDEX1, EepVideo.cFlag_PAL);
}
twdDelay(NVRDELAY);
OSDShowVideoData();
}
}
#endif
#if VIDEO_AVAILABLE
void AdjVideoBright(sCHAR sStep)
{
if( (EepVideo.cBright+sStep)<=V_BRIGHT_MAX && (EepVideo.cBright+sStep)>=V_BRIGHT_MIN)
{
EepVideo.cBright+=sStep;
I2CWriteByte(TW803_P0,VBRIGHT,EepVideo.cBright); //Ruby 2004-10-09
OSDShowVideoData();
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_BRIGHT_INDEX, EepVideo.cBright);
twdDelay(NVRDELAY);
}
}
void AdjVideoContrast(sCHAR sStep)
{
if( (EepVideo.cContrast+sStep)<=V_CONTRAST_MAX && (EepVideo.cContrast+sStep)>=V_CONTRAST_MIN)
{
EepVideo.cContrast+=sStep;
I2CWriteByte(TW803_P0,VCONTRAST,EepVideo.cContrast); //Ruby 2004-10-09
OSDShowVideoData();
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_CONTRAST_INDEX, EepVideo.cContrast);
twdDelay(NVRDELAY);
}
}
void AdjVideoSharp(sCHAR sStep)
{
if(EepVideo.cSharp>V_SHARP_MAX)
EepVideo.cSharp=V_SHARP_MAX-1;
if(EepVideo.cSharp<V_SHARP_MIN)
EepVideo.cSharp=V_SHARP_MIN;
if( (EepVideo.cSharp+sStep)<=V_SHARP_MAX && (EepVideo.cSharp+sStep)>=V_SHARP_MIN)
{
EepVideo.cSharp+=sStep;
I2CWriteByte(TW803_P2,0x80,V_SHARP_MSK|(EepVideo.cSharp<<1));
OSDShowVideoData();
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_SHARP_INDEX, EepVideo.cSharp);
twdDelay(NVRDELAY);
}
}
void AdjVideoSat(sCHAR sStep)
{
if( (EepVideo.cSat+sStep)<=V_SAT_MAX && (EepVideo.cSat+sStep)>=V_SAT_MIN)
{
EepVideo.cSat+=sStep;
I2CWriteByte(TW803_P0,VSAT,EepVideo.cSat);
OSDShowVideoData();
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_SAT_INDEX, EepVideo.cSat);
twdDelay(NVRDELAY);
}
}
void AdjVideoHue(sCHAR sStep)
{
if( (EepVideo.cHue+sStep)<=V_HUE_MAX && (EepVideo.cHue+sStep)>=V_HUE_MIN)
{
EepVideo.cHue+=sStep;
I2CWriteByte(VIDEO_ADDR,VHUE,EepVideo.cHue-0x80);
OSDShowVideoData();
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_HUE_INDEX, EepVideo.cHue);
twdDelay(NVRDELAY);
}
}
#ifdef T112
void AdjVideoRGB(sCHAR sStep) // add by Sherman 06'01'18
{
if( (EepVideo.cRGB+sStep)<=V_RGB_MAX && (EepVideo.cRGB+sStep)>=V_RGB_MIN)
{
EepVideo.cRGB+=sStep;
I2CWriteByte(TW803_P0,VRGB,EepVideo.cRGB);
OSDShowVideoData();
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_RGB_INDEX, EepVideo.cRGB);
twdDelay(NVRDELAY);
}
}
void AdjVideoVCOMA(sCHAR sStep) // add by Sherman 06'01'23
{
if( (EepVideo.cVCOMA+sStep)<=V_VCOMA_MAX && (EepVideo.cVCOMA+sStep)>=V_VCOMA_MIN)
{
EepVideo.cVCOMA+=sStep;
I2CWriteByte(TW803_P0,VVCOMA,EepVideo.cVCOMA);
OSDShowVideoData();
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_VCOMA_INDEX, EepVideo.cVCOMA);
twdDelay(NVRDELAY);
}
}
void AdjVideoVCOMD(sCHAR sStep) // add by Sherman 06'01'23
{
if( (EepVideo.cVCOMD+sStep)<=V_VCOMD_MAX && (EepVideo.cVCOMD+sStep)>=V_VCOMD_MIN)
{
EepVideo.cVCOMD+=sStep;
I2CWriteByte(TW803_P0,VVCOMD,EepVideo.cVCOMD);
OSDShowVideoData();
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_VCOMD_INDEX, EepVideo.cVCOMD);
twdDelay(NVRDELAY);
}
}
#endif
#ifdef TV
//extern bit m_bLCDOFF;
void AdjTVChannel(sCHAR sStep,bit bShow)
{
uCHAR cNum, cNum_b,cTotal;
uWORD wTemp;
#ifdef NTSC
if(m_bAir_Cable)
cTotal=125;
else
cTotal=83;
#endif
#ifdef PAL
cTotal=95;
#endif
// cNum=TVEEPGetChannel();
//TVSetChannel(I2CReadByte(EEPVIDEOBLOCK, idTVCHANNEL_INDEX)-1);
TVSetChannel(I2CReadByte(EEPVIDEOBLOCK, idTVCHANNEL_INDEX)-1);
cNum = I2CReadByte(EEPVIDEOBLOCK, idTVCHANNEL_INDEX);
cNum_b=cNum;
if(skipon || bShow)
{
cNum+=sStep;
if(sStep)
{
if(cNum>cTotal)
cNum=1;
else if(cNum<1)
cNum=cTotal;
wTemp=TVSetChannel(cNum-1);
if(wTemp&0x8000)
m_bTV_Skip=1;
else
m_bTV_Skip=0;
}
}
else
{
do
{
cNum+=sStep;
if(cNum>cTotal)
cNum=1;
else if(cNum<1)
cNum=cTotal;
wTemp=TVSetChannel(cNum-1);
if(wTemp&0x8000)
m_bTV_Skip=1;
else
m_bTV_Skip=0;
}while(m_bTV_Skip&&(cNum_b!=cNum)&&sStep);
}
I2CWriteByte(EEPVIDEOBLOCK, idTVCHANNEL_INDEX, cNum);
twdDelay(NVRDELAY);
twdDelay(200);
//kenny 20060406==============================
// SetTuner(wTemp);
Tuner_WriteFreq(wTemp);
//kenny 20060406==============================
//SourceSelect(); //Ruby 2004-11-03
if(!bShow)
{
OSDExit();
OSDEnable();
OSDPosition(RIGHT_TOP);
// OSDDrawNum(cNum, 0, 19, 1, COL_NORMAL, DRAW_BLANK|0x03);
}
else
{
//Ruby OSDDrawSkip();
//ruby OSDDrawNum(cNum, 0, 19, 1, COL_TITLE, DRAW_BLANK|0x03);
OSDDrawNum(cNum-1, 0, 19, 1, COL_TITLE, DRAW_BLANK|0x03);
//ruby OSDDrawTVFreq(wTemp);
}
// OSDShowTVData(); // mark by Sherman 05'11'14
}
void AdjTVSkip(void)
{
uCHAR cNum;
uWORD wTVFreq;
m_bTV_Skip=!m_bTV_Skip;
twdDelay(NVRDELAY);
cNum = I2CReadByte(EEPVIDEOBLOCK, idTVCHANNEL_INDEX);
wTVFreq=TVSetChannel(cNum-1);
if(m_bTV_Skip)wTVFreq|=0x8000;
else wTVFreq&=0x7fff;
EEPSaveTVChannel(cNum-1, wTVFreq);
//Ruby OSDDrawSkip();
// ir_data=0;
}
#ifdef PAL // kenny 20060406
void AdjTVSoundSystem(void)
{
if(m_cSoundSystem==PAL_I)
m_cSoundSystem=PAL_DK;
else
m_cSoundSystem=PAL_I;
//Ruby OSDDrawSoundSystem();
I2CWriteByte(0x86, 0x02,m_cSoundSystem);
// ir_data=0;
}
#endif // kenny 20060406
void AdjTVFineTune(sCHAR sStep)
{
uCHAR cTemp;
uWORD wTemp;
cTemp = I2CReadByte(EEPVIDEOBLOCK, idTVCHANNEL_INDEX);
twdDelay(NVRDELAY);
if(m_bAir_Cable)
{
wTemp=I2CReadByte(EEPVIDEOBLOCK+4, idTVCHANNEL_STAT+(cTemp-1)*2);
wTemp<<=8;
twdDelay(NVRDELAY);
wTemp|=I2CReadByte(EEPVIDEOBLOCK+4, idTVCHANNEL_STAT+(cTemp-1)*2+1);
}
else
{
wTemp=I2CReadByte(EEPVIDEOBLOCK+2, idTVCHANNEL_STAT+(cTemp-1)*2);
wTemp<<=8;
twdDelay(NVRDELAY);
wTemp|=I2CReadByte(EEPVIDEOBLOCK+2, idTVCHANNEL_STAT+(cTemp-1)*2+1);
}
wTemp += sStep;
//Ruby OSDDrawTVFreq(wTemp);
#ifdef PAL
//Ruby OSDDrawBand(wTemp);
#endif
//kenny 20060406==============================
// SetTuner(wTemp);
Tuner_WriteFreq(wTemp);
//kenny 20060406==============================
EEPSaveTVChannel(cTemp-1, wTemp);
// OSDShowTVData(); // mark by Sherman 05'11'14
}
void AdjTVSource(void)
{
uCHAR cTemp;
cTemp=I2CReadByte(EEPVIDEOBLOCK, idVIDEO_FLAG_INDEX);
if(m_bAir_Cable)
{
m_bAir_Cable=0;
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_FLAG_INDEX,cTemp&0xFE);
}
else
{
m_bAir_Cable=1;
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_FLAG_INDEX,cTemp|0x01);
}
OSDShowTVData(); // mark by Sherman 05'11'14
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -