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

📄 key.c

📁 keil C51 LCD 驱动源码,其中还有I2C驱动,ADC驱动,键盘操作等,是一个完整的keil源代码,供大家参考
💻 C
📖 第 1 页 / 共 5 页
字号:
#include        "LIB\EXTENT.H"
#include        "LIB\WREG516.H"
#include        "LIB\DECLARE.H"
#include        "LIB\GLOBAL.H"
#include        "LIB\OSDMENU.H"
#include        "LIB\OSDM.H"
#include        "LIB\DEFINE.H"
#include        "LIB\MODEDATA.H"
#include        "LIB\EEPROM.H"
#include        "LIB\INITIAL.H"
#include        "LIB\MODEDET.H"
#include        "LIB\TTFC.H"
#include        "LIB\ADC.H"
#include        "LIB\MISC.H"


#define POWER_KEY       0x3E
#define UP_KEY          0x6E
#define DOWN_KEY        0x76
// #define UP_KEY          0x76
// #define DOWN_KEY        0x6E
#define SELECT_KEY      0x5E
#define MENU_KEY        0x7A
#define AUTO_KEY        0x7C

#define NO_KEY          0x7E
#define EXIT_KEY        MENU_KEY
#define ENTER_KEY       SELECT_KEY

//double key 
#define DOUBLE_KEY      UP_KEY & DOWN_KEY 

//Hot key
#define INITIAL_KEY     MENU_KEY & DOWN_KEY
#define BURNINONKEY     ENTER_KEY & DOWN_KEY      //  4,2
#define BURNINOFFKEY    UP_KEY & DOWN_KEY         //  3,2
#define ISP_KEY         ENTER_KEY & MENU_KEY       //  2,1
#define FAC_KEY         UP_KEY & MENU_KEY         //  3,1
#define RECALL_KEY       MENU_KEY


extern Bool autofunction(Bool);
extern  void    EepromRecallAll(void);
extern  void    RecallAll(void);
extern  void    GotoISP(void);

void    Key(void);
void    MenuKey(void);
Byte    GetItemNumber(void);
void    VerticalKey(void);
void    Up_Down_Key(void);
void    EnterKey(void);
void    EnterKeyReturn(void);
void    OsdShowMainBar(Byte,Byte,Byte);
void    OsdShowSubBar(Byte,Byte,Byte);
void    SystemPowerOn(void);
void    SystemPowerOff(Bool);
void    ChangeLanguage(Byte);
void    ShowScallWindow(Byte);
void    ShowScallBar(Word,Word,Word);
void    ModifyValue(Bool);
Byte    GetByteValue(Byte,Byte,Byte,Bool);
Word    GetWordValue(Word,Bool);
void    SetHorPosition(Bool,Bool);
void    SetVerPosition(void);
void    ChangeColorTemp(Byte);
void    ChangeDOSMode(void);
void    ShowCompDOSMode(void);
void    CheckPowerKey(void);
void    SavePowerbit(Byte);

void    KeyCheck()
{
        Byte    keybval,a;
        
        keybval = P2 & 0x3E;
        keybval = keybval | 0x40;
        FgFacMode=0;

        switch(keybval)
        {
                case INITIAL_KEY :
                        if(!FgBurnin)
                                break;
                        ZuracFreeRun(L0_NOOSD);
                        MUTEEnable();
                        OsdShowMessage(INITIAL_MESSAGE);
                        PromptTimer=TIME_5SEC;
                        InitialEeprom();
                        RecallAll();
                        MUTEDisable();
                        FgModeDetect=1; //algu 1120
                        while(PromptTimer!=0);
                        OsdEnable(0);
                      break;
                case BURNINONKEY :
                        FgBurnin=1;
                        ZuracFreeRun(L0_NOOSD);
                        OsdShowMessage(SET_BUININ_MESSAGE);
                        PromptTimer=TIME_5SEC;
                        while(PromptTimer!=0);
                        OsdEnable(0);
                        FgModeDetect=1; //algu 1120
                	EepromCommonStore(0);
                        break;
                case BURNINOFFKEY :
                        FgBurnin=0;
                        ZuracFreeRun(L0_NOOSD);
                        OsdShowMessage(CLEAR_BUININ_MESSAGE);
                        PromptTimer=TIME_5SEC;
                        while(PromptTimer!=0);
                        OsdEnable(0);
                        FgModeDetect=1; //algu 1120
			EepromCommonStore(0);
                        break;
                case FAC_KEY :
                        FgFacMode=1;
                        FgMenuKey=1;
                        EepromCommonRecall(0);
                        EepromCommonRecall(1);
                        EepromCommonRecall(2);
                        EepromColorRecall(ColorTemp);
                        return;
                case RECALL_KEY :
                        ZuracFreeRun(L0_NOOSD);
                        MUTEEnable();
                        OsdShowMessage(ALL_RECALL_MESSAGE);
                        PromptTimer=TIME_5SEC;
                        FgFacMode=1;
                        EepromRead(EE3_UPDATE_USER,1);
                        a=TrmBuf[0];
		//	EepromColorRecall(COLOR_9300);
			EepromColorRecall(a);
                        EepromColorStore(COLOR_USER);
                        RecallAll();
                        FgBurnin =0;
                        EepromCommonStore(0);
                        FgFacMode=0;
                        EepromCommonStore(0);
                        MUTEDisable();
                        FgModeDetect=1;
                        while(PromptTimer!=0);
                        OsdEnable(0);
                        break;
        }
        if(FgBurnin)
        	ES=1;
        else
        	ES=0;
}
//=========================================================
//=========================================================
void    Key()
{
        Byte    keybval;
//        Bool    FgDoKey;
        Byte    ItemNumber;

        keybval = P2 & 0x7E;

        UpdateValue = 0;
//        FgDoKey=0;

        if( KeyBuffer != keybval )
        {
                KeyBuffer = keybval;
                ScanKeyCounter = 4;
        }
        else if( KeyBuffer == NO_KEY)
        {
                FgSelKeyFlag=0;         //algu 1120
//                FgUpKeyFlag=0;
//                FgDownKeyFlag=0;
                FgInputKeyFlag = 0;
                KeyStatus=0;
                FgMenuKey=0;
                if(CountTimer!=0)
                        CountTimer=CountTimer/4;
                FgPowerKeyFlag=0;
                SaveAllData();
        }
        else if( ScanKeyCounter != 0 )
        {
                ScanKeyCounter--;
        }
        else if( CountTimer==0 && (KeyBuffer&0x40) == 0x00 && FgPowerKeyFlag == 0 )
        {
                FgPowerKeyFlag=1;
                FgMenuKey=0;
                FgShowBurnin=0;
                if(FgPowerOff)
                {
                        SystemPowerOn();
                        SavePowerbit(0x80);
                        KeyCheck();             //tonny
                        FgShowBurnin=0;
                        FgPowerBurnin=1;
                        FgModeChange=1;
                //	ES=0;
                }
                else
                {
                        if(!FgShowBurnin  && !FgNoSignal)
                        {
                                ChangeColorTemp(ColorTemp);
                                SaveAllData();
                        }
                        SystemPowerOff(1);
                        SavePowerbit(0x00);
                }
        }
	else if ( FgPowerStby && CountTimer==0 && KeyBuffer != NO_KEY && !FgPowerOff )        //algu 1122
//	else if ( (FgShowBurnin || FgPowerStby) && CountTimer==0 && KeyBuffer != NO_KEY && !FgPowerOff )
//	Vincent 20020131 for clear show no signal when burn in on
	{
//                if (OSDNumber==L0_NO_SIGNAL)    //algu 1129 DPMS
//                {
//                        SystemPowerOn();
//                        FgShowBurnin=0;
//                        if ( VGA_DET== 0 )
//                        {
//                                OSDNumber=L3_NO_SIGNAL;
//                                PromptTimer=0;
//                        }
//                        else
//                        {
//                                
//                                ZuracFreeRun(L0_NO_SIGNAL);
//                                OsdShowMessage(CHECK_SIGNAL_MESSAGE);
//                                if (FgBurnin)
//                                {
//                                        PromptTimer = TIME_3SEC;
//                                }       
//                                else 
//                                        PromptTimer = TIME_90SEC;
//                                                
//                        }                       
//                }       
//                else if (OSDNumber==L0_OVERRANGE )
		if (OSDNumber==L0_OVERRANGE )
                {
                        
                        ZuracFreeRun(L0_OVERRANGE);
                        FgNoSignal=0;
                        OsdShowMessage(OVER_RANGE_MESSAGE);
                        if (FgBurnin)
                                PromptTimer = TIME_3SEC;
                        else 
                                PromptTimer = TIME_25SEC;
                }       
        }       
        else if( CountTimer==0 && KeyBuffer != NO_KEY && !FgPowerOff && !FgShowBurnin && !FgNoSignal)   //algu 1122 && !FgOverRange
        {
        	
           if ( FgFreeRun==0 && FgNoSignal==0 && OSDNumber!=L9_FAILSAFE && OSDNumber!=L3_FAILSAFE )
           {                            
                switch(KeyBuffer)
                {
                        case DOUBLE_KEY:
                                ItemNumber=GetItemNumber();
                                if (ItemNumber==L1_BRIGHTNESS)
                                {
                                        CountTimer=TIME_500MS;          //algu 1122
                                        if(BrightnessValueZ!=50)
                                        {
                                                BrightnessValueZ=50;
                                                ZuracBCAdjust();
                                                ShowScallBar(0,100,BrightnessValueZ);
                                        }
                                        
                                }
                                else if (ItemNumber==L1_CONTRAST)
                                {
                                         CountTimer=TIME_500MS;         //algu 1122
                                         if(ContrastValueZ != 70)
                                         {
                                                ContrastValueZ=70;
                                                ZuracBCAdjust();
                               
                                                ShowScallBar(0,100,ContrastValueZ);
                                         }      
                                         
                                }       
                                break;

                        
                        case MENU_KEY :
                                if(FgMenuKey)
                                        break;
//                                FgDoKey=1;
//                                KeyStatus=0;
                                CountTimer=TIME_500MS;
                                if(FgHatKey)
                                {

⌨️ 快捷键说明

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