📄 menufunc.c
字号:
#define _MENUFUNC_C_
#include "types.h"
#include "board.h"
#include "global.h"
#include "keypaddef.h"
#include "menu.h"
#include "adjust.h"
#include "ms_reg.h"
#include "DEBUG.h"
#include "msosd.h"
#include "power.h"
#include "misc.h"
#include "autofunc.h"
#include "nvram.h"
#include "userpref.h"
#include "panel.h"
#include "mstar.h"
#include "ms_rwreg.h"
#include "adjust.h"
#include "mcu.h"
#include "menustr.h"
#include "msAce.h"
#include "i2c.h"
#include "Tv.h"
#include "DevTuner.h"
#include "Tda7052.h"
#include "menufunc.h"
#include "Game.h"
extern BYTE OsdFontColor;
WORD DecIncValue(MenuItemActionType action, WORD value, WORD minValue, WORD maxValue, BYTE step)
{
if (action==MIA_IncValue || action==MIA_InvDecValue)
{
if (value>=maxValue)
return value;
minValue=value+step;
if (minValue>maxValue)
minValue=maxValue;
value=minValue;
}
else // Decrease value
{
if (value<=minValue)
return value;
maxValue=value-step;
if (maxValue<minValue)
maxValue=minValue;
value=maxValue;
}
return value;
}
#if VGA_ENABLE
WORD GetScale100Value(WORD value, WORD minValue, WORD maxValue)
{
maxValue=maxValue-minValue;
value=value-minValue;
if (value>650)
{
value/=2;
maxValue/=2;
}
value=((WORD)value*100+maxValue/2)/maxValue;//modify word---->dword for tv search ,tzw
return value;
}
#endif
BOOL PowerOffSystem(void)
{
printMsg("turn off");
//devAudioWrite(0);
//Delay1ms(100);
SetAudioMute();
Power_PowerOffSystem();
Power_TurnOffGreenLed();
Clr_PowerOnFlag();
//NVRam_WriteByte(nvrVideoAddr(MonitorFlag), g_VideoSetting.MonitorFlag);
Clr_DoModeSettingFlag();
SetAudioStby();
return TRUE;
}
BOOL PowerOnSystem(void)
{
printMsg("turn on");
Power_PowerOnSystem();
Power_TurnOnGreenLed();
Set_PowerOnFlag();
//NVRam_WriteByte(nvrVideoAddr(MonitorFlag), g_VideoSetting.MonitorFlag);
msSetBlueScreen( _ENABLE, FR_BLUE);
Set_ShowSourceFlag();
#if Enable_Logo_Display
ucLogoDisplayCounter=2;
Set_DrawLogoFlag();
#endif
return TRUE;
}
//==============================================for Video==================================
BOOL AdjustVideoContrast(MenuItemActionType action)
{
WORD tempValue;
if(IsVideoPortInUse())
{
tempValue=DecIncValue(action, g_VideoSetting.VideoContrast, MinDefVideoContrast, MaxDefVideoContrast, 1);
if (tempValue==g_VideoSetting.VideoContrast)
return FALSE;
g_VideoSetting.VideoContrast=tempValue;
tempValue=usrNonLinearCalculate(g_NLCVideoContrast,g_VideoSetting.VideoContrast);
#if TV_ENABLE
if(IsTVInUse())
tempValue+=TV_EXTR_CONTRAST;
#endif
msAdjustVideoContrast(tempValue);
}
else
{
tempValue=DecIncValue(action, g_PcSetting.Contrast, MinDefContrast, MaxDefContrast, 1);
if (tempValue==g_PcSetting.Contrast)
return FALSE;
g_PcSetting.Contrast=tempValue;
msAdjustPCContrast(g_PcSetting.Contrast);
}
return TRUE;
}
WORD GetVideoContrastValue(void)
{
if(IsVideoPortInUse())
return g_VideoSetting.VideoContrast;
else
return g_PcSetting.Contrast;
}
//====================================================
BOOL AdjustVideoBrightness(MenuItemActionType action)
{
WORD tempValue;
if(IsVideoPortInUse())
{
tempValue=DecIncValue(action, g_VideoSetting.VideoBrightness, MinDefVideoBrightness, MaxDefVideoBrightness, 1);
if (tempValue==g_VideoSetting.VideoBrightness)
return FALSE;
g_VideoSetting.VideoBrightness=tempValue;
tempValue=usrNonLinearCalculate(g_NLCVideoBrightness,tempValue);
msAdjustBrightness(tempValue);
}
else
{
tempValue=DecIncValue(action, g_PcSetting.Brightness, MinDefBrightness, MaxDefBrightness, 1);
if (tempValue==g_PcSetting.Brightness)
return FALSE;
g_PcSetting.Brightness=tempValue;
msAdjustBrightness(g_PcSetting.Brightness);
}
return TRUE;
}
WORD GetBrightnessValue(void)
{
if(IsVideoPortInUse())
return g_VideoSetting.VideoBrightness; //GetScale100Value(g_PcSetting.Brightness, 0, 100);
else
return g_PcSetting.Brightness; //GetScale100Value(g_PcSetting.Brightness, 0, 100);
}
//====================================================
#if 0
BOOL AdjustVideoHue(MenuItemActionType action)
{
WORD tempValue;
tempValue=DecIncValue(action, g_VideoSetting.VideoHue, MinDefVideoHue , MaxDefVideoHue, 1);
if (tempValue==g_VideoSetting.VideoHue)
return FALSE;
g_VideoSetting.VideoHue=tempValue;
msAdjustVideoHue(g_VideoSetting.VideoHue);
return TRUE;
}
#endif
//====================================================
BOOL AdjustVideoSaturation(MenuItemActionType action)
{
WORD tempValue;
tempValue=DecIncValue(action, g_VideoSetting.VideoSaturation, MinDefVideoSaturation , MaxDefVideoSaturation, 1);
if (tempValue==g_VideoSetting.VideoSaturation)
return FALSE;
g_VideoSetting.VideoSaturation=tempValue;
tempValue=usrNonLinearCalculate(g_NLCVideoSaturation,g_VideoSetting.VideoSaturation);
msAdjustVideoSaturation(tempValue);
return TRUE;
}
WORD GetVideoSaturationValue(void)
{
return g_VideoSetting.VideoSaturation;
}
BOOL AdjustSource(void)
{
Power_TurnOffPanel();
msSetInterrupt(INTERRUPT_DISABLE);
msSetBlueScreen( _ENABLE, FR_BLUE);
g_VideoSetting.InputType+=1;
g_VideoSetting.InputType%=Input_Nums;
//printf("\r\nSource=%d",g_VideoSetting.InputType);
Set_InputTimingChangeFlag();
Clr_InputTimingStableFlag();
Osd_Hide();
Set_ShowSourceFlag();
#if TV_ENABLE
if (IsTVInUse())
Set_ChannelChangFlag();
#endif
Set_SourceChangFlag(); //junjian 061205 for SECAM to NTSC
msSetupInputPort();
Set_SaveSettingFlag();
SaveUserPref();
return TRUE;
}
WORD GetChromaModeValue(void)
{
#if TV_ENABLE
if(IsTVInUse())
{
#if TV_SYSTEM==TV_NTSC
return CHROMA_NTSC;// force ntsc
#else
return ((g_TVChSetting.TvCurChannelMisc&ColorSysMask)>>4)%CHROMA_NUMS;
#endif
}
else
#endif
return (g_VideoSetting.VideoColorSys%=CHROMA_NUMS);
}
BOOL AdjustChromaMode(MenuItemActionType action)
{
#if TV_ENABLE
BYTE tempchroamvalue;
if(IsTVInUse())
{
#if TV_SYSTEM==TV_NTSC
tempchroamvalue=tempchroamvalue;
return TRUE;
#else
tempchroamvalue=((g_TVChSetting.TvCurChannelMisc&ColorSysMask)>>4)%CHROMA_NUMS;
g_TVChSetting.TvCurChannelMisc &=~ColorSysMask;
if(action==MIA_IncValue)
tempchroamvalue+=1;
else
tempchroamvalue+=(CHROMA_NUMS-1);
tempchroamvalue %=CHROMA_NUMS;
g_TVChSetting.TvCurChannelMisc |=(tempchroamvalue<<4)&ColorSysMask;
chData.ucChannelMisc = g_TVChSetting.TvCurChannelMisc;
SaveTVChannelInfo(g_TVChSetting.ucCurChannelNO, TRUE);
#endif
}
else
#endif
{
if(action==MIA_IncValue)
g_VideoSetting.VideoColorSys+=1;
else
g_VideoSetting.VideoColorSys+=(CHROMA_NUMS-1);
g_VideoSetting.VideoColorSys %=CHROMA_NUMS;
}
SetChromaMode();
msForceChromaDetect(g_VdInfo.ucVideoSystem);
return TRUE;
}
WORD GetAudioVolumeValue(void)
{
return (g_VideoSetting.volume)%101;
}
void devAudioSetVolume(BYTE ucVolume)
{
BYTE tempValue;
if( ucVolume == 0 || g_VideoSetting.MuteStatus)
{
SetAudioMute();
}
else
{
hw_ClrAudioStby();
hw_ClrAudioMute();
tempValue=usrNonLinearCalculate(g_NLCAudioVolume,ucVolume);
devAudioWrite(tempValue);
}
}
BOOL AdjustVolume(MenuItemActionType action)
{
BYTE tempvolume;
tempvolume=g_VideoSetting.volume;
tempvolume=DecIncValue(action, g_VideoSetting.volume, MinVolume, MaxVolume, 1);
if (tempvolume==g_VideoSetting.volume)
return FALSE;
g_VideoSetting.volume=tempvolume;
devAudioSetVolume(tempvolume);
return TRUE;
}
BOOL AdjustMuteStatusValue(MenuItemActionType action)
{
BYTE tempvalue;
tempvalue=g_VideoSetting.MuteStatus;
if(action==MIA_IncValue)
tempvalue+=1;
else
tempvalue+=(2-1);
tempvalue %=2;
g_VideoSetting.MuteStatus=tempvalue;
devAudioSetVolume(g_VideoSetting.volume);
return TRUE;
}
void DrawTopIcon(BYTE ItemIndex,BYTE ReDrawSelect)
{
BYTE PositionOffset=3,PositionOffset1=0;
if(!IsTVInUse() &&ItemIndex==4)
ItemIndex=5;
if(!IsTVInUse())
{
PositionOffset=0;
PositionOffset1=1;
}
OsdFontColor=0xCC;
Osd_DrawStr(0,0, " ");
/**************************PICTURE************************************/
if(ReDrawSelect&_BIT0)
{
#if TV_ENABLE
if(IsTVInUse())
{
Osd_DrawStr(2,1, " ");
Osd_DrawStr(2,2, " ");
Osd_DrawStr(5,1, " ");
Osd_DrawStr(5,2, " ");
Osd_DrawStr(8,1, " ");
Osd_DrawStr(8,2, " ");
Osd_DrawStr(11,1, " ");
Osd_DrawStr(11,2, " ");
Osd_DrawStr(14,1, " ");
Osd_DrawStr(14,2, " ");
}
else
#endif
{
Osd_DrawStr(0,1, " ");
Osd_DrawStr(0,2, " ");
Osd_DrawStr(3,1, " ");
Osd_DrawStr(3,2, " ");
Osd_DrawStr(6,1, " ");
Osd_DrawStr(6,2, " ");
Osd_DrawStr(9,1, " ");
Osd_DrawStr(9,2, " ");
Osd_DrawStr(12,1, " ");
Osd_DrawStr(12,2, " ");
Osd_DrawStr(15,1, " ");
Osd_DrawStr(15,2, " ");
}
OsdFontColor=0x01;
if (ItemIndex==0)
OsdFontColor|=0x50;
Osd_DrawStr(0+PositionOffset1, 1, "\x0E0");
OsdFontColor=0x81;
if (ItemIndex==0)
OsdFontColor|=0x10;
Osd_DrawStr(1+PositionOffset1, 1, "\x0E1");
OsdFontColor=0x03;
if (ItemIndex==0)
OsdFontColor=0x10;
Osd_DrawStr(0+PositionOffset1, 2, "\x0E2");
OsdFontColor=0x83;
if (ItemIndex==0)
OsdFontColor=0x90;
Osd_DrawStr(1+PositionOffset1, 2, "\x0E3");
}
/******************************AUDIO********************************/
if(ReDrawSelect&_BIT1)
{
OsdFontColor=0x00;
if (ItemIndex==1)
OsdFontColor|=0x50;
Osd_DrawStr(3+PositionOffset1, 1, "\x0E4");
OsdFontColor=0x00;
if (ItemIndex==1)
OsdFontColor|=0x50;
Osd_DrawStr(4+PositionOffset1, 1, "\x0E5");
OsdFontColor=0x03;
if (ItemIndex==1)
OsdFontColor=0x10;
Osd_DrawStr(3+PositionOffset1, 2, "\x0E6");
OsdFontColor=0xC3;
if (ItemIndex==1)
OsdFontColor=0xD0;
Osd_DrawStr(4+PositionOffset1, 2, "\x0E7");
}
/******************************FUNCTION********************************/
if(ReDrawSelect&_BIT2)
{
OsdFontColor=0x81;
if (ItemIndex==2)
OsdFontColor|=0x10;
Osd_DrawStr(6+PositionOffset1, 1, "\x0E8");
OsdFontColor=0x02;
if (ItemIndex==2)
OsdFontColor|=0x50;
Osd_DrawStr(7+PositionOffset1, 1, "\x0E9");
OsdFontColor=0x83;
if (ItemIndex==2)
OsdFontColor=0x90;
Osd_DrawStr(6+PositionOffset1, 2, "\x0EA");
OsdFontColor=0x83;
if (ItemIndex==2)
OsdFontColor=0x90;
Osd_DrawStr(7+PositionOffset1, 2, "\x0EB");
}
/******************************SYSTEM********************************/
if(ReDrawSelect&_BIT3)
{
OsdFontColor=0x81;
if (ItemIndex==3)
OsdFontColor|=0x10;
Osd_DrawStr(9+PositionOffset1, 1, "\x0EC");
OsdFontColor=0x02;
if (ItemIndex==3)
OsdFontColor|=0x50;
Osd_DrawStr(10+PositionOffset1, 1, "\x0ED");
OsdFontColor=0x03;
if (ItemIndex==3)
OsdFontColor=0x50;
Osd_DrawStr(9+PositionOffset1, 2, "\x0EE");
OsdFontColor=0x03;
if (ItemIndex==3)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -