⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menufunc.c

📁 LCD OSD 程序用於8051 開發lcd
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "types.h"
#include "board.h"
#include "global.h"
#include "keypaddef.h"
#include "menudef.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 "mstar.h"
#include "ms_rwreg.h"
#include "adjust.h"
#include "mcu.h"
#include "menustr.h"

void SaveUserPref(void);
void Read9300KSetting(void);
void Read6500KSetting(void);
void Save9300KSetting(void);
void Save6500KSetting(void);
extern void mStar_AutoDVI(void);
extern Bool ExecuteKeyEvent(MenuItemActionType menuAction);

WORD DecIncValue(MenuItemActionType action, WORD value, WORD minValue, WORD maxValue, BYTE step)
{ 
	if (action==MIA_IncValue)
    	{ 
    		if (value>=maxValue)
        		return maxValue;


      		minValue=value+step;
      		if (minValue>maxValue)
      			minValue=maxValue;
      		value=minValue;
    	}
  	else // Decrease value
    	{ 
    		if (value<=minValue)
        		return minValue;
      		maxValue=value-step*10/6;
      		if (maxValue<minValue)
      			maxValue=minValue;
      		value=maxValue;
    	}
  	return value;
}

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;

	if(value > 100)
		value=100;

  	return value;
}
Bool ResetOsdTimer(void)
{ if (!FactoryModeFlag)

//****olivia1225  the osd time is too long
OsdCounter=25;
//OsdCounter=45;//UserPrefOsdTime;
  else
    OsdCounter=0;
  return TRUE;
}

Bool EnablePowerDownCounter(void)
{ 	if(FactoryModeFlag)
		PowerDownCounter=5;
	else
		PowerDownCounter=20;
 // Set_ForcePowerSavingFlag();
  return TRUE;

}
Bool EnablePowerDownCounter1(void)
{ 	if(SrcInputType==Input_Analog1)	//counter only for analog inpurt
	PowerDownCounter=15;
//  Set_ForcePowerSavingFlag();
  return TRUE;

}
Bool PowerOffSystem(void)
{ printMsg("turn off");
  Power_TurnOffLed();
  Power_PowerOffSystem();
  Clr_PowerOnFlag();
  Clr_FactoryModeFlag();
  NVRam_WriteByte(nvrMonitorAddr(MonitorFlag), MonitorFlags);
  return TRUE;
}

Bool PowerOnSystem(void)
{ printMsg("turn on");

//*****eagle wu0108
hw_ClrStandby();
Delay1ms(300);


  Power_PowerOnSystem();

  if(!FactoryModeFlag)
      {Power_TurnOnGreenLed();
      Power_TurnOffAmberLed(); 
  	}
  else
  	{
      Power_TurnOnAmberLed();
      Power_TurnOffGreenLed(); 
  	}

  Set_PowerOnFlag();
  NVRam_WriteByte(nvrMonitorAddr(MonitorFlag), MonitorFlags);
  return TRUE;
}

//================================================================================
//================================================================================
//================================================================================
Bool AdjustBrightnessContrast(MenuItemActionType action)
{ WORD tempValue;
  if (action==MIA_IncValue1 || action==MIA_DecValue1)
    { action-=2;
      tempValue=DecIncValue(action, UserPrefContrast, MinContrastValue, MaxContrastValue, 1);
      if (tempValue==UserPrefContrast)
        return FALSE;
      UserPrefContrast=tempValue;
      mStar_AdjustContrast(UserPrefContrast);
    }
  else
    { action-=4;
      tempValue=DecIncValue(action, UserPrefBrightness, 0, 100, 1);
      if (tempValue==UserPrefBrightness)
        return FALSE;
      UserPrefBrightness=tempValue;
      mStar_AdjustBrightness(UserPrefBrightness);
    }

  
  return TRUE;
}
WORD GetContrastValue(void)
{ return GetScale100Value(UserPrefContrast, MinContrastValue, MaxContrastValue);
}
WORD GetBrightnessValue(void)
{ return UserPrefBrightness; //GetScale100Value(UserPrefBrightness, 0, 100);
}

//====================================================
//====================================================
WORD GetColorTemp(void)
{ return UserPrefColorTemp1;
}
Bool AdjustColorTemp(MenuItemActionType action)
{ action=action;
  UserPrefColorTemp1=(UserPrefColorTemp1+1)%2;
  UserPrefColorTemp=UserPrefColorTemp1;
  mStar_AdjustContrast(UserPrefContrast);

  return TRUE;
}


//====================================================
Bool AdjustBlueColor(MenuItemActionType action)
{ WORD tempValue;

  
  if (UserPrefColorTemp==CTEMP_9300K)
  {
  tempValue=DecIncValue(action, UserPrefBlueColor9300K, 0, MaxColorValue, 1);
  if (tempValue==UserPrefBlueColor9300K)
    return FALSE;    
  UserPrefBlueColor9300K=tempValue;
  }
  else if (UserPrefColorTemp==CTEMP_6500K)
  {
  tempValue=DecIncValue(action, UserPrefBlueColor6500K, 0, MaxColorValue, 1);
  if (tempValue==UserPrefBlueColor6500K)
    return FALSE;    
  UserPrefBlueColor6500K=tempValue;
  //UserPrefBlueColor=UserPrefBlueColor6500K;
  }
  
  else//UserPrefColorTemp=CTEMP_USER;
  {
  tempValue=DecIncValue(action, UserPrefBlueColor, 0, MaxUserColorValue, 1);
  if (tempValue==UserPrefBlueColor)
    return FALSE;    
  UserPrefBlueColor=tempValue;
  }

//#if UsesRGB
  mStar_AdjustContrast(UserPrefContrast);
  /*
#else
  mStar_AdjustBlueColor(UserPrefBlueColorSRGB);
  mStar_AdjustBlueColor(UserPrefBlueColor9300K);
  mStar_AdjustBlueColor(UserPrefBlueColor6500K);
  mStar_AdjustBlueColor(UserPrefBlueColor5400K);
  mStar_AdjustBlueColor(UserPrefBlueColor);
#endif
  */

  return TRUE;
}

WORD GetBlueColorValue(void)
{ 
  
   if (UserPrefColorTemp==CTEMP_9300K)
    return GetScale100Value(UserPrefBlueColor9300K, 0, MaxColorValue);
  else if (UserPrefColorTemp==CTEMP_6500K)
    return  GetScale100Value(UserPrefBlueColor6500K, 0, MaxColorValue);
  
   else if (FactoryModeFlag&&((MenuPageIndex==Factory1Menu)||(MenuItemIndex==5)))//UserPrefColorTemp=CTEMP_USER;
    return  GetScale100Value(UserPrefBlueColor, 0, MaxColorValue);
  else
    return  GetScale100Value(UserPrefBlueColor, 0, MaxUserColorValue);
}

WORD GetRealBlueColorValue(void)
{ 
  
   if (UserPrefColorTemp==CTEMP_9300K)
    return UserPrefBlueColor9300K;
  else if (UserPrefColorTemp==CTEMP_6500K)
    return  UserPrefBlueColor6500K;
  
   else if (FactoryModeFlag&&((MenuPageIndex==Factory1Menu)||(MenuItemIndex==5)))//UserPrefColorTemp=CTEMP_USER;
    return  UserPrefBlueColor;
  else
    return  GetScale100Value(UserPrefBlueColor, 0, MaxUserColorValue);
}

WORD GetUserBlueColorValue(void)
 {return  GetScale100Value(UserPrefBlueColor, 0, MaxUserColorValue);

}
//====================================================
Bool AdjustGreenColor(MenuItemActionType action)
{ WORD tempValue;

  
  if (UserPrefColorTemp==CTEMP_9300K)
  {
  tempValue=DecIncValue(action, UserPrefGreenColor9300K, 0, MaxColorValue, 1);
  if (tempValue==UserPrefGreenColor9300K)
    return FALSE;    
  UserPrefGreenColor9300K=tempValue;
  }
  else if (UserPrefColorTemp==CTEMP_6500K)
  {
  tempValue=DecIncValue(action, UserPrefGreenColor6500K, 0, MaxColorValue, 1);
  if (tempValue==UserPrefGreenColor6500K)
    return FALSE;    
  UserPrefGreenColor6500K=tempValue;
 // UserPrefGreenColor=UserPrefGreenColor6500K;
  }
  
  else//UserPrefColorTemp=CTEMP_USER;
  {
  tempValue=DecIncValue(action, UserPrefGreenColor, 0, MaxUserColorValue, 1);
  if (tempValue==UserPrefGreenColor)
    return FALSE;    
  UserPrefGreenColor=tempValue;
  }

//#if UsesRGB
  mStar_AdjustContrast(UserPrefContrast);
  /*
#else
  mStar_AdjustGreenColor(UserPrefGreenColorSRGB);
  mStar_AdjustGreenColor(UserPrefGreenColor9300K);
  mStar_AdjustGreenColor(UserPrefGreenColor6500K);
  mStar_AdjustGreenColor(UserPrefGreenColor5400K);
  mStar_AdjustGreenColor(UserPrefGreenColor);
#endif
  */  

  return TRUE;
}

WORD GetGreenColorValue(void)
{
if (UserPrefColorTemp==CTEMP_9300K)
    return GetScale100Value(UserPrefGreenColor9300K, 0, MaxColorValue);
  else if (UserPrefColorTemp==CTEMP_6500K)
    return  GetScale100Value(UserPrefGreenColor6500K, 0, MaxColorValue);
  
  else if (FactoryModeFlag&&((MenuPageIndex==Factory1Menu)||(MenuItemIndex==5)))//UserPrefColorTemp=CTEMP_USER;
    return  GetScale100Value(UserPrefGreenColor, 0, MaxColorValue);
  else
    return  GetScale100Value(UserPrefGreenColor, 0, MaxUserColorValue);
  
}

WORD GetRealGreenColorValue(void)
{
if (UserPrefColorTemp==CTEMP_9300K)
    return UserPrefGreenColor9300K;
  else if (UserPrefColorTemp==CTEMP_6500K)
    return  UserPrefGreenColor6500K;
  
  else if (FactoryModeFlag&&((MenuPageIndex==Factory1Menu)||(MenuItemIndex==5)))//UserPrefColorTemp=CTEMP_USER;
    return  UserPrefGreenColor;
  else
    return  GetScale100Value(UserPrefGreenColor, 0, MaxUserColorValue);
  
}
WORD GetUserGreenColorValue(void)
 {return  GetScale100Value(UserPrefGreenColor, 0, MaxUserColorValue);

}
//====================================================
Bool AdjustRedColor(MenuItemActionType action)
{ WORD tempValue;

  
  if (UserPrefColorTemp==CTEMP_9300K)
  {
  tempValue=DecIncValue(action, UserPrefRedColor9300K, 0, MaxColorValue, 1);
  if (tempValue==UserPrefRedColor9300K) 
    return FALSE;    
  UserPrefRedColor9300K=tempValue;
  }
  else if (UserPrefColorTemp==CTEMP_6500K)
  {
  tempValue=DecIncValue(action, UserPrefRedColor6500K, 0, MaxColorValue, 1);
  if (tempValue==UserPrefRedColor6500K)
    return FALSE;    
  UserPrefRedColor6500K=tempValue;
  //UserPrefRedColor=UserPrefRedColor6500K;
  }
  
  else//UserPrefColorTemp=CTEMP_USER;
  {
  tempValue=DecIncValue(action, UserPrefRedColor, 0, MaxUserColorValue, 1);
  if (tempValue==UserPrefRedColor)
    return FALSE;    
  UserPrefRedColor=tempValue;
  }


//#if UsesRGB
  mStar_AdjustContrast(UserPrefContrast);
  /*
#else
  mStar_AdjustRedColor(UserPrefRedColorSRGB);
  mStar_AdjustRedColor(UserPrefRedColor9300K);
  mStar_AdjustRedColor(UserPrefRedColor6500K);
  mStar_AdjustRedColor(UserPrefRedColor5400K);
  mStar_AdjustRedColor(UserPrefRedColor);
#endif  
  */  
  return TRUE;
}

WORD GetRedColorValue(void)
{
if (UserPrefColorTemp==CTEMP_9300K)
    return GetScale100Value(UserPrefRedColor9300K, 0, MaxColorValue);
  else if (UserPrefColorTemp==CTEMP_6500K)
    return  GetScale100Value(UserPrefRedColor6500K, 0, MaxColorValue);
  
  else if (FactoryModeFlag&&((MenuPageIndex==Factory1Menu)||(MenuItemIndex==5)))//UserPrefColorTemp=CTEMP_USER;
    return  GetScale100Value(UserPrefRedColor, 0, MaxColorValue);
  else
    return  GetScale100Value(UserPrefRedColor, 0, MaxUserColorValue);
}
WORD GetRealRedColorValue(void)
{
if (UserPrefColorTemp==CTEMP_9300K)
    return UserPrefRedColor9300K;
  else if (UserPrefColorTemp==CTEMP_6500K)
    return UserPrefRedColor6500K;
  
  else if (FactoryModeFlag&&((MenuPageIndex==Factory1Menu)||(MenuItemIndex==5)))//UserPrefColorTemp=CTEMP_USER;
    return  UserPrefRedColor;
  else
    return  GetScale100Value(UserPrefRedColor, 0, MaxUserColorValue);
}

WORD GetUserRedColorValue(void)
 {return  GetScale100Value(UserPrefRedColor, 0, MaxUserColorValue);

}

//jon information set HV position to 50/50
#define MaxHStart	UserPrefAutoHStart+50
#define MinHStart		UserPrefAutoHStart-50
#define MaxVStart	UserPrefAutoVStart*2
#define MinVStart		0
//#define MaxHStart	2*StandardModeHStart
//#define MinHStart	0
//====================================================
Bool AdjustHVPosition(MenuItemActionType action)
{ WORD tempValue;
  if (action==MIA_IncValue1 || action==MIA_DecValue1)
    { if (action==MIA_IncValue1)
        action=MIA_DecValue;
      else
        action=MIA_IncValue;

      tempValue=DecIncValue(action, UserPrefHStart, MinHStart, MaxHStart, 1);
      if (tempValue==UserPrefHStart)
        return FALSE;
      UserPrefHStart=tempValue;
      mStar_AdjustHPosition(UserPrefHStart);
    }
  else
    { action-=4;
//      tempValue=DecIncValue(action, UserPrefVStart, 0, 2*StandardModeVStart, 1);
      tempValue=DecIncValue(action, UserPrefVStart, MinVStart,MaxVStart, 1);
      if (tempValue==UserPrefVStart)
        return FALSE;
      UserPrefVStart=tempValue;
      mStar_AdjustVPosition(UserPrefVStart);
    }

  return TRUE;
}
WORD GetHPositionValue(void)
{ return 100-GetScale100Value(UserPrefHStart, MinHStart, MaxHStart);//, 0);
}

//jon modify HV position set HV to 50/50
WORD GetVPositionValue(void)
{ return GetScale100Value(UserPrefVStart, MinVStart, MaxVStart);
}

//====================================================

#define MaxClock	(StandardModeHTotal+60)
#define MinClock	(StandardModeHTotal-60)
Bool AdjustClock(MenuItemActionType action)
{ WORD tempValue;

  tempValue=DecIncValue(action, UserPrefHTotal, MinClock, MaxClock, 1);
  if (tempValue==UserPrefHTotal)
    return FALSE;
  UserPrefHTotal=tempValue;
  mStar_AdjustHTotal(UserPrefHTotal);
  return TRUE;
}
WORD GetClockValue(void) // adjust range
{ return GetScale100Value(UserPrefHTotal, MinClock, MaxClock);
}

//====================================================
Bool AdjustPhase(MenuItemActionType action)
{ WORD tempValue;

  tempValue=DecIncValue(action, UserPrefPhase, 0, 63, 1);
  if (tempValue==UserPrefPhase)
    return FALSE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -