📄 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 "System.h"
#include "Struct.h"
#include "TW10xReg.h"
#include "OSDCtrl.h"
#include "TwoWire.h"
#include "OSDDraw.h"
#include "Keypad.h"
#include "Video.h"
#include "Tuner.h"
//#include "OSDDRAW.h"
#ifdef NVRAM
#include "NVRam.h"
extern uWORD idata m_wEepRom;
#endif
extern bit m_bAir_Cable;
extern bit m_bTV_Skip;
extern uCHAR ir_data;
extern void BKPower(void);
#ifdef TIMER1
extern void Timer1Reset(void);
extern void Timer1Start(void);
extern void Timer1Stop(void);
#endif
extern uCHAR m_cSoundSystem;
extern bit m_bBKPowerOn;
extern LoadFilter(uCHAR);
extern BOOL SrcOptimizing(uCHAR cTuneType);
extern OSDPARAMS code sOSDParamsDef, sOSDParamsMin, sOSDParamsMax;
extern uCHAR idata m_cOSDEvent;
extern uCHAR idata m_cOSDFunc;
extern uCHAR idata m_cItem;
extern uCHAR idata m_cSource;
extern uCHAR code OSDPositionTable[];
extern uCHAR idata m_cBuff[4];
extern uWORD idata m_wBuff[3];
bit idata skipon=0;
#if VIDEO_AVAILABLE
extern EEPVIDEO idata EepVideo;
#endif
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
}
void AdjVolume(sCHAR sStep)
{
if( (EepVideo.cVolume+sStep)<=sOSDParamsMax.cVolume
&&(EepVideo.cVolume+sStep)>=sOSDParamsMin.cVolume)
{
EepVideo.cVolume += sStep;
I2CWriteByte(TW101, 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;
}
#if VIDEO_AVAILABLE
extern uCHAR idata m_cStandard;
void AdjTimingB2(sCHAR sStep)
{
sStep=sStep;
#ifdef LOAD_TIME
if(I2CReadByte(TW101,0xb2)+sStep>=0&&I2CReadByte(TW101,0xb2)+sStep<=0xFF)
{
if(m_cStandard==S_NTSC)
{
EepVideo.cB2=I2CReadByte(TW101,0xb2)+sStep;
EepVideo.cB8=I2CReadByte(TW101,0xb8);
I2CWriteByte(TW101,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(TW101,0xb2)+sStep;
EepVideo.cB8_PAL=I2CReadByte(TW101,0xb8);
I2CWriteByte(TW101,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();
}
#endif
}
void AdjTimingB8(sCHAR sStep)
{
sStep=sStep;
#ifdef LOAD_TIME
if(I2CReadByte(TW101,0xb8)+sStep>=0&&I2CReadByte(TW101,0xb8)+sStep<=0xFF)
{
if(m_cStandard==S_NTSC)
{
EepVideo.cB2=I2CReadByte(TW101,0xb2);
EepVideo.cB8=I2CReadByte(TW101,0xb8)+sStep;
I2CWriteByte(TW101,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(TW101,0xb2);
EepVideo.cB8_PAL=I2CReadByte(TW101,0xb8)+sStep;
I2CWriteByte(TW101,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
}
void AdjVideoBright(sCHAR sStep)
{
if( (EepVideo.cBright+sStep)<=V_BRIGHT_MAX && (EepVideo.cBright+sStep)>=V_BRIGHT_MIN)
{
EepVideo.cBright+=sStep;
I2CWriteByte(TW101,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(TW101,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(TW101+4,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(TW101,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(TW101,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(TW101,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(TW101,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);
SetTuner(wTemp);
//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);
//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;
}
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;
}
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
SetTuner(wTemp);
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 + -