📄 keypad.c
字号:
#include <math.h>
#include "types.h"
#include "board.h"
#include "keypaddef.h"
#include "ms_reg.h"
#include "global.h"
#include "debug.h"
#include "misc.h"
#include "ms_rwreg.h"
#include "nvram.h"
#include "mcu.h"
#include "Menudef.h"
#include "Menu.h"
//================================================================
BYTE KeypadButton=0;
BYTE KeypadButtonCounter;
extern BYTE MenuPageIndex;
//extern BYTE LastVolumeValue;
extern void PowerOffSystem(void);
extern void PowerOnSystem(void);
BYTE Key_GetKeypadStatus(void)
{
BYTE keypad=0xFF;
if(!Left_key) keypad &= ~KEY_PLUS;
if(!Right_key) keypad &= ~KEY_MINUS;
if(!Menu_key) keypad &= ~KEY_MENU;
if(!Exit_key) keypad &= ~KEY_AUTO;
if(!Power_key) keypad &= ~KEY_POWER;
return keypad;
}
void CheckFactoryKeyStatus(void)
{ BYTE keypadStatus;
keypadStatus=(Key_GetKeypadStatus()^KeypadMask)&KeypadMask;
#if PRV772_KeyPad
keypadStatus=(~keypadStatus)&KeypadMask;
#endif
if (keypadStatus==KEY_ISP)
{
#if (!Enable232ISP)
if(FactoryModeFlag)
#endif
{
Set_ISPFlag();
#if DEBUG_ENABLE
printMsg("ISP");
#endif
Set_PowerOnFlag();
}
}
}
Bool CheckPowerKeyStatus(void)
{
BYTE keypadStatus;
keypadStatus=(Key_GetKeypadStatus()^KeypadMask)&KeypadMask;
#if PRV772_KeyPad
keypadStatus=(~keypadStatus)&KeypadMask;
#endif
if (keypadStatus==KEY_POWER)
{
Set_ForcePowerOffFlag();
return TRUE;
}
else
return FALSE;
}
Bool Key_CheckAutoKeyOnly(void)
{
BYTE keypadStatus;
keypadStatus=(Key_GetKeypadStatus()^KeypadMask)&KeypadMask;
if (keypadStatus==KEY_AUTO)
{
return TRUE;
}
else
return FALSE;
}
void Key_ScanKeypad(void)
{
BYTE keypadStatus;
keypadStatus=(Key_GetKeypadStatus()^KeypadMask)&KeypadMask;
if (keypadStatus)
{
if (keypadStatus==(KEY_FACTORY))
{ printMsg(" key FACTORY");
if (PowerOnFlag&&EnableEnterFactory) //NELSON Modify
{
Clr_EnableEnterFactory(); //NELSON
Set_FactoryModeFlag();
Enable_SerialPort();
NVRam_WriteByte(nvrMonitorAddr(MonitorFlag), MonitorFlags);
Menu_InitAction();
}
else
{
if((!EnableFactoryKeyCount)&&(!FactoryModeFlag))//nelson
EnableFactoryKeyCount=3; //nelson
}
}
else
{
EnableFactoryKeyCount=0;
if (keypadStatus==KEY_PLUS)
{
if (KeypadButton==BTN_Repeat)
KeypadButton=BTN_Repeat;
else
KeypadButton=BTN_Plus;
}
else if (keypadStatus==KEY_MINUS)
{ if (KeypadButton==BTN_Repeat)
KeypadButton=BTN_Repeat;
else
KeypadButton=BTN_Minus;
}
else if (keypadStatus==KEY_MENU)
{
if (KeypadButton==BTN_Menu || KeypadButton==BTN_Repeat || KeypadButton==BTN_FactoryStart)
KeypadButton=BTN_FactoryStart;
else
KeypadButton=BTN_Menu;
}
else if (keypadStatus==KEY_AUTO)
{
if(MenuPageIndex==StandbyMenu || MenuPageIndex==CableNotConnectedMenu || MenuPageIndex==DDCTypeMenu)
KeypadButton=BTN_Repeat;
else
{
if (KeypadButton==BTN_Repeat)
KeypadButton=BTN_Repeat;
else
KeypadButton=BTN_Auto;
}
}
else if (keypadStatus==KEY_POWER)
{
if (KeypadButton==BTN_Power || KeypadButton==BTN_Repeat)
KeypadButton=BTN_Repeat;
else
{ if(KeypadButtonCounter<10)
KeypadButton=BTN_Nothing;
else
KeypadButton=BTN_Power;
}
}
//#if 1//DUAL_INPUT
else if (keypadStatus==KEY_DDCSWITCH)
{
if (KeypadButton==BTN_Exit || KeypadButton==BTN_Repeat)
KeypadButton=BTN_Repeat;
else
{printMsg(" DDC MOVE ");
#if MSTMCU
mStar_WriteByte(DDCEN1,(mStar_ReadByte(DDCEN1)&~BIT3)|BIT4|BIT5);
hw_SetDSUBDDC();
#else
hw_SetDSUBDDC();
#endif
KeypadButton=BTN_Exit;
Set_DistinguishAutoKeyFlag();
}
}
//KEY_RESET_PTIME
else if (keypadStatus==KEY_RESET_PTIME)
{ if (KeypadButton==BTN_Menu)
KeypadButton=BTN_Repeat;
else
KeypadButton=BTN_Menu;
Set_EnableResetPTimeFlag();
}
else
KeypadButton=BTN_Nothing;
}
}
else
{
EnableFactoryKeyCount=0;
KeypadButton=BTN_Nothing;
}
if(KeypadButton==BTN_Power)
KeypadButtonCounter=0;
else
KeypadButtonCounter++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -