?? key.c
字號:
//****************************************************************************
// @Project Includes
//****************************************************************************
#include "GLOBAL.H"
#include "Key.H"
#include "MAIN.H"
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
//****************************************************************************
// @Global Variables
//****************************************************************************
bit Key_Press_Flag;
bit Key_Release_Flag;
bit Key_Exist_Flag;
unsigned char Key_Value; //74HC166 value
unsigned char Key_Command_State;
unsigned char Key_Command_State_Old;
unsigned char Key_Command;
//****************************************************************************
// @User Code
//****************************************************************************
//**********Delay**********
void delay(unsigned int j)
{
while(j)
j--;
}
//**********74HC165操作**********
unsigned char Key_GetData8(void)
{
unsigned char i;
unsigned char Key_data=0;
HC166_Disable; //將并行口的數據鎖存
EA = 0;
delay(0xFF);
EA = 1;
P1_1 = 0;
_nop_();
_nop_();
_nop_();
P1_1 = 1;
HC166_Enable;
EA = 0;
delay(0xFF);
EA = 1;
for(i=0;i<8;i++)
{
Key_data=Key_data<<1;
if(P1_0==1)
Key_data=Key_data|0x01;
P1_1 = 0;
_nop_();
_nop_();
_nop_();
P1_1 = 1;
}
return(Key_data);
}
//**********Key值處理**********
void Key_Read(void)
{
Key_Command_State_Old = Key_Command_State;
Key_Value = Key_GetData8();
switch(Key_Value)
{
case Key_Mode_Select:
{
Key_Command_State = Key_Mode_Select;
Key_Press_Flag = 1;
Key_Release_Flag = 0;
break;
}
case Key_Circle_Select:
{
Key_Command_State = Key_Circle_Select;
Key_Press_Flag = 1;
Key_Release_Flag = 0;
break;
}
case Key_Temperature_Up:
{
Key_Command_State = Key_Temperature_Up;
Key_Press_Flag = 1;
Key_Release_Flag = 0;
break;
}
case Key_Temperature_Down:
{
Key_Command_State = Key_Temperature_Down;
Key_Press_Flag = 1;
Key_Release_Flag = 0;
break;
}
case Key_Fan_Up:
{
Key_Command_State = Key_Fan_Up;
Key_Press_Flag = 1;
Key_Release_Flag = 0;
break;
}
case Key_Fan_Down:
{
Key_Command_State = Key_Fan_Down;
Key_Press_Flag = 1;
Key_Release_Flag = 0;
break;
}
case Key_Auto_Enable:
{
Key_Command_State = Key_Auto_Enable;
Key_Press_Flag = 1;
Key_Release_Flag = 0;
break;
}
case Key_Window_Heat:
{
Key_Command_State = Key_Window_Heat;
Key_Press_Flag = 1;
Key_Release_Flag = 0;
break;
}
default:
{
if(P1_7==0)
{
Key_Command_State = Key_AC_In;
Key_Press_Flag = 1;
Key_Release_Flag = 0;
}
else
{
Key_Release_Flag = 1;
}
break;
}
}
if(Key_Release_Flag)
{
if(Key_Press_Flag)
Key_Exist_Flag = 1;
else
Key_Command = 0; //no command
}
if(Key_Command_State_Old == Key_Command_State)
{
if(Key_Exist_Flag)
{
Key_Command = Key_Command_State;
Key_Command_State = 0;
Key_Command_State_Old = 0;
Key_Exist_Flag = 0;
Key_Press_Flag = 0;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -