打印

高手们来看看,关于组合键的问题

[复制链接]
2489|10
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
colinluan|  楼主 | 2008-8-11 21:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
如何实现键盘组合键的功能呢?
如果按键不多,可以每一个键单独检测,然后根据每个键的标志来判断是否有几个键同时按下。
但是如果按键多的时候,每一个键单独检测就不行了。只能用按键扫描。当检测到按键以后要等到弹起才能进行下一次操作。这样当一个键按下时,别的键就无法扫描了。
还望高手指点一下,有什么办法可以实现组合键的功能。

相关帖子

沙发
xwj| | 2008-8-11 22:05 | 只看该作者

思路问题

使用特权

评论回复
板凳
dai_weis| | 2008-8-11 22:48 | 只看该作者

扫描和按下根本就没有关系

完全可以各自干各自的工作

使用特权

评论回复
地板
xwj| | 2008-8-11 22:55 | 只看该作者

是的,LZ最大的问题就是非要“每一个键单独检测”

应该吧所有案件视为一个整体

使用特权

评论回复
5
computer00| | 2008-8-11 23:06 | 只看该作者

可以试试俺的按键扫描程序~~~~很简单的

volatile uint8 idata KeyCurrent,KeyOld,KeyNoChangedTime;
volatile uint8 idata KeyPress;
volatile uint8 idata KeyDown,KeyUp,KeyLast;

volatile uint8 KeyCanChange;

/********************************************************************
函数功能:定时器0初始化,用来做键盘扫描,定时时间大约为5ms。
入口参数:无。
返    回:无。
备    注:无。
********************************************************************/
void InitTimer0(void)
{
 TMOD&=0xF0;
 TMOD|=0x01;
 ET0=1;
 TR0=1;
}
/*******************************************************************/


/********************************************************************
函数功能:键盘初始化
入口参数:无。
返    回:无。
备    注:无。
********************************************************************/
void InitKeyboard(void)
{
 KeyIO=0xFF;      //键盘对应的口设置为输入状态
 KeyPress=0;          //无按键按下
 KeyNoChangedTime=0;
 KeyOld=0;
 KeyCurrent=0;
 KeyLast=0;
 KeyDown=0;
 KeyUp=0;
 InitTimer0();          //初始化定时器
 KeyCanChange=1;      //允许键值改变
}
/*******************************************************************/

/********************************************************************
函数功能:定时器0中断处理。
入口参数:22.1184M晶体约5ms中断一次。
返    回:无。
备    注:无。
********************************************************************/
void Timer0Isr(void) interrupt 1

//定时器0重装,定时间隔为5ms,加15是为了修正重装所花费时间
//这个值可以通过软件仿真来确定,在这里设置断点,调整使两次运行
//时间差刚好为5ms即可。
 TH0=(65536-Fclk/1000/12*5+15)/256;     
 TL0=(65536-Fclk/1000/12*5+15)%256;   // 

 if(!KeyCanChange)return;     //如果正在处理按键,则不再扫描键盘 

 //开始键盘扫描
 //保存按键状态到当前按键情况
 //KeyCurrent总共有8个bit
 //当某个开关按下时,对应的bit为1
 KeyCurrent=GetKeyValue(); //读取键值,GetKeyValue()其实是个宏,不是函数,
                           //这里故意写成函数的样子,美观。它的定义在
                           //key.h文件中

 if(KeyCurrent!=KeyOld)  //如果两次值不等,说明按键情况发生了改变
  {
   KeyNoChangedTime=0;       //键盘按下时间为0
   KeyOld=KeyCurrent;        //保存当前按键情况
   return;  //返回
  }
 else
  {
   KeyNoChangedTime++;         //按下时间累计
   if(KeyNoChangedTime>=1)     //如果按下时间足够
    {
    KeyNoChangedTime=1;
    KeyPress=KeyOld;      //保存按键
    KeyDown|=(~KeyLast)&(KeyPress); //求出新按下的键
    KeyUp|=KeyLast&(~KeyPress);     //求出新释放的键
   KeyLast=KeyPress;                 //保存当前按键情况
   }
  }
}
/*******************************************************************/

使用特权

评论回复
6
colinluan|  楼主 | 2008-8-12 14:26 | 只看该作者

圈圈的按键收藏了

圈圈的按键写法还是第一次见到,特别是KeyDown跟KeyUp,确实不错。

使用特权

评论回复
7
computer00| | 2008-8-12 23:36 | 只看该作者

这里还有使用方法简介

使用特权

评论回复
8
iammercy| | 2008-8-14 09:21 | 只看该作者

RE

/*******************************************************************************************
 *                                UI_DoorProcess
 *input parameters:
 *        gbDoorTemp
 *output parameters:
 *        TBD
 *Function:
 *        key debounce
 *******************************************************************************************/
#define    DOOROPEN_DEBOUNCE_TIMER        30                //door open debounce
#define    DOORCLOSE_DEBOUNCE_TIMER    250                //door close debounce

void    UI_DoorProcess(void)
{
    static    bit        bdata    debounce;        //registers used to debounce
    static    Byte    idata    debounceTimer;
    static    bit        bdata    doorState;    
    
    if(_testbit_(gbFlag1ms_1))
    {
//1> judge key state change ----------------------------------------------------------------
        if( doorState != gbDoorTemp )
        {
//2> begin to bebounce if key state change -------------------------------------------------
            doorState = gbDoorTemp;        
            if(gbDoorTemp)
            {        
                debounceTimer = DOOROPEN_DEBOUNCE_TIMER;
            }
            else
            {
                debounceTimer = DOORCLOSE_DEBOUNCE_TIMER;    
            }
            debounce = 1;
        }
//3> finish debounce if door state keep unchanged during the debounce period----------------
        if(debounce)
        {
            if(!(--debounceTimer))
            {
                gbDoorValue = doorState;         //save door value
                if(gbDoorValue)
                {
                    ExecuteDoorOpenFunc();
                }
                else
                {
                    ExecuteDoorCloseFunc();    
                }
                debounce = 0;
            }
        }
    }
}

/*******************************************************************************************
 *                                UI_LEDDisplay
 *                                                                    
 *        ---------    ---------        ---------    ---------                
 *        |        |    |        |        |        |    |        |                
 *        |_______|    |_______| DP1    |_______|    |_______|    CLOCK    Arrow 1~37    
 *        |        |    |        |        |        |    |        |                
 *        |        |    |        | DP2    |        |    |        |    KG            
 *        ---------    ---------        ---------    ---------
 *        7segDigit1    7segDigit2        7segDigit3    7segDigit4
 *        
 *input parameters:
 *        gBDigitSegPart1            -- 7SegDigit1 and DP1
 *        gBDigitSegPart2            -- 7SegDigit2 and DP2
 *        gBDigitSegPart3            -- 7SegDigit3 and DP3(CLOCK icon)
 *        gBDigitSegPart4            -- 7SegDigit4 and DP4(KG icon)
 *        gBArrowSegPart1            -- Arrow 1~6
 *        gBArrowSegPart2            -- Arrow 7~12
 *        gBArrowSegPart3            -- Arrow 13~18
 *        gBArrowSegPart4            -- Arrow 19~24
 *        gWArrowSegPart5            -- Arrow 25~37
 *output parameters:
 *        gBKeyTemp[0~3]
 *Function:
 *        LED display and keyline scan
 *******************************************************************************************/
void    UI_LEDDisplay(void)
{
    static    Byte comLoop;
    if(_testbit_(gbFlag2ms_0))            
    {
        COM1_PIN = 1;                    //display nothing
        COM2_PIN = 1;
        COM3_PIN = 1;
        COM4_PIN = 1;
        COM5_PIN = 1;
        switch(comLoop)
        {
//1> scan key and door,then prepare content for display-------------------------------------
            case    0:                    
                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~KeyIn pins input pull high
                    KEYIN_PINS_CFG  = Bin(00000000);    
                    KEYIN_PINS_PULL = Bin(11111111);    
                    KEYIN_PINS      = Bin(11111111);
                    KEYOUT1_PIN = 1;
                    KEYOUT2_PIN = 1;
                    KEYOUT3_PIN = 1;                                        
                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scan key line4
                    KEYOUT4_PIN = 0;
                    Delay();
                    gBKeyTemp[0]  = ~KEYIN_PINS;
                    gBKeyTemp[0]  &= Bin(01111111);
                    Delay();
                    KEYOUT4_PIN = 1;        
                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scan key line3
                    KEYOUT3_PIN = 0;                
                    Delay();
                    gBKeyTemp[1]  = ~KEYIN_PINS;
                    gBKeyTemp[1]  &= Bin(01111111);
                    Delay();
                    KEYOUT3_PIN = 1;
                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scan key line2
                    KEYOUT2_PIN = 0;    
                    Delay();            
                    gBKeyTemp[2]  = ~KEYIN_PINS;
                    gBKeyTemp[2]  &= Bin(01111111);
                    Delay();
                    KEYOUT2_PIN = 1;                
                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scan key line1
                    KEYOUT1_PIN = 0;    
                    Delay();            
                    gBKeyTemp[3]  = ~KEYIN_PINS;                    
                    gBKeyTemp[3]  &= Bin(01111111);
                    Delay();
                    KEYOUT1_PIN = 1;                
                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scan door
                    if( KEYIN_PINS & Bin(10000000) )
                    {
                        gbDoorTemp = 1;
                    }
                    else
                    {
                        gbDoorTemp = 0;
                    }
                    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~restart next LED display loop
                    SEG_PINS_CFG  = Bin(11111111);    
                    SEG_PINS_PULL = Bin(00000000);
                    SEG_PINS      = Bin(11111111);                                
                    SetLED();
                    comLoop++;
                    break;
//2> show content of COM1-------------------------------------------------------------------
            case    1:
                    SEG_PINS         = gBDigitSegPart1;            
                    Write74164(gBArrowSegPart1);
                    COM1_PIN = 0;                        
                    comLoop++;
                    break;
//3> show content of COM2-------------------------------------------------------------------
            case    2:
                    SEG_PINS        = gBDigitSegPart2;    
                    Write74164(gBArrowSegPart2);
                    COM2_PIN = 0;                        
                    comLoop++;
                    break;
//4> show content of COM3-------------------------------------------------------------------
            case    3:
                    SEG_PINS        = gBDigitSegPart3;            
                    Write74164(gBArrowSegPart3);
                    COM3_PIN = 0;
                    comLoop++;
                    break;
//5> show content of COM4-------------------------------------------------------------------
            case    4:
                    SEG_PINS        = gBDigitSegPart4;
                    Write74164(gBArrowSegPart4);
                    COM4_PIN = 0;
                    comLoop++;
                    break;
//6> show content of COM5-------------------------------------------------------------------
            default:
                    SEG_PINS        = LOBYTE(gWArrowSegPart5);    
                    Write74164(HIBYTE(gWArrowSegPart5));
                    COM5_PIN = 0;
                    comLoop=0;
                    break;
        }        
    }
}
/**********************************************************************************************
 *                                Single Key Press interface                        
 *
 * Function Description:
 * Input parameter     :
 * Output paramter     :
 * remarks                  :
 **********************************************************************************************/

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~00    P2.3 - P1.0    
//N/C
static    bit    Key00_PressDown(void)            
{
    return    0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~01  P2.3 - P1.1
//A-05    Corn
static    bit    Key01_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,A05_START,A05_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~02  P2.3 - P1.2
//A-09    MeatBone
static    bit    Key02_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,A09_START,A09_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~03  P2.3 - P1.3
//A-10    Wings
static    bit    Key03_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,A10_START,A10_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~04  P2.3 - P1.4
//A-08    Bread
static    bit    Key04_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,A08_START,A08_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~05  P2.3 - P1.5
//A-07    Milk/Coffee
static    bit    Key05_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,A07_START,A07_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~06  P2.3 - P1.6
//A-06    DeepFrezee
static    bit    Key06_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,A06_START,A06_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~07  P2.2 - P1.0
//A-04    egg
static    bit    Key07_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,A04_START,A04_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~08  P2.2 - P1.1
//A-03    shrump
static    bit    Key08_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,A03_START,A03_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~09  P2.2 - P1.2
//A-02    Ribs
static    bit    Key09_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,A02_START,A02_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~10  P2.2 - P1.3
//A-01    fish
static    bit    Key10_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,A01_START,A01_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~11  P2.2 - P1.4
//SC-6    noddle
static    bit    Key11_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,SC6_START,SC6_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~12  P2.2 - P1.5
//SC-5    Dumpling
static    bit    Key12_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,SC5_START,SC5_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~13  P2.2 - P1.6
//SC-4    beancurd 
static    bit    Key13_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,SC4_START,SC4_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~14  P2.1 - P1.0
//odor
static    bit    Key14_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,ODOR_START,ODOR_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~15  P2.1 - P1.1
//SC-3    Meat
static    bit    Key15_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,SC3_START,SC3_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~16  P2.1 - P1.2
//SC-2    Vegetable
static    bit    Key16_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,SC2_START,SC2_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~17    P2.1 - P1.3
//SC-1    Rice
static    bit    Key17_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,SC1_START,SC1_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~18    P2.1 - P1.4
//10SEC
static    bit    Key18_PressDown(void)            
{
    return    ExecuteTimeMemuKeyFunc(TENS_DIGIT,10);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~19  P2.1 - P1.5
//1MIN
static    bit    Key19_PressDown(void)            
{
    return    ExecuteTimeMemuKeyFunc(SINGLE_DIGIT,60);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~20  P2.1 - P1.6
//10MIN
static    bit    Key20_PressDown(void)            
{
    return    ExecuteTimeMemuKeyFunc(TENS_DIGIT,600);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~21  P2.0 - P1.0
//Pause/Cancel/Saving
static    bit    Key21_PressDown(void)
{
    return    ExecuteCancelKeyFunc();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~22  P2.0 - P1.1
//Start/+30s
static    bit    Key22_PressDown(void)
{
    return    ExecuteStartKeyFunc();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~23  P2.0 - P1.2
//Clock/Preset
static    bit    Key23_PressDown(void)          
{
    return    ExecuteClockKeyFunc();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~24  P2.0 - P1.3
//Defrost
static    bit    Key24_PressDown(void)            
{
    return    ExecuteDefrostMemuKeyFunc();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~25  P2.0 - P1.4
//Lightwave
static    bit    Key25_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(1,GRILL_START,GRILL_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~26  P2.0 - P1.5
//Baby
static    bit    Key26_PressDown(void)            
{
    return    ExecuteCookMemuKeyFunc(0,BABY_START,BABY_END);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~27  P2.0 - P1.6
//Microwave
static    bit    Key27_PressDown(void)
{
    gbPowerCheckReq = 1;
    return    ExecuteCookMemuKeyFunc(1,MICRO_START,MICRO_END);
}

KeyCommand  code    KeyCommandUnit[28] = 
{
        { &Key00_PressDown},
        { &Key01_PressDown},
        { &Key02_PressDown},
        { &Key03_PressDown},
        { &Key04_PressDown},
        { &Key05_PressDown},
        { &Key06_PressDown},
        { &Key07_PressDown},
        { &Key08_PressDown},
        { &Key09_PressDown},
        { &Key10_PressDown},
        { &Key11_PressDown},
        { &Key12_PressDown},
        { &Key13_PressDown},
        { &Key14_PressDown},
        { &Key15_PressDown},
        { &Key16_PressDown},
        { &Key17_PressDown},
        { &Key18_PressDown},
        { &Key19_PressDown},
        { &Key20_PressDown},
        { &Key21_PressDown},
        { &Key22_PressDown},
        { &Key23_PressDown},
        { &Key24_PressDown},
        { &Key25_PressDown},
        { &Key26_PressDown},
        { &Key27_PressDown},
};
/*******************************************************************************************
 *                                UI_KeyProcess
 *input parameters:
 *        gBKeyTemp[0~3]
 *output parameters:
 *        TBD
 *Function:
 *        key debounce
 *******************************************************************************************/
#define    KEY_DEBOUNCE_TIMER        32                //key debounce 32ms
void    UI_KeyProcess(void)
{
    Byte    data    i,j;
    Byte    data    keyBuf;                    //registers used to judge how many key pressed
    Byte    data    keyCount;
    Byte    data    keyIndex;

    bit     bdata    FgNeedToBuzz;            //flag will mark if key take effect

    static    bit        bdata    debounce;        //registers used to debounce
    static    Byte    idata    debounceTimer;
    static    Byte    idata    keyState[4];    
    
    if(_testbit_(gbFlag1ms_2))
    {
//1> judge key state change ----------------------------------------------------------------
        for(i=0;i<4;i++)
        {
            if(keyState != gBKeyTemp)
            {
//2> begin to bebounce if key state change -------------------------------------------------
                keyState = gBKeyTemp;
                debounceTimer = KEY_DEBOUNCE_TIMER;
                debounce = 1;        
            }
        }
//3> finish debounce if key state keep unchanged during the debounce period-----------------
        if(debounce)
        {
            if(!(--debounceTimer))
            {
                debounce = 0;
//4> judge how many key press and save the key value of the pressed key    --------------------        
                for(i=0,keyIndex=0,keyCount=0;i<4;i++)    
                {
                    keyBuf = keyState;
                    for(j=0;j<7;j++)        //note:the key matrix is 4 by 7
                    {
                        keyBuf>>=1;
                        if(CY)
                        {                    
                            if(keyCount<3)    //at most save 3 pressed key to prevent ghost key        
                            {
                                gBKeyValue[keyCount] = keyIndex;
                            }                            
                            keyCount++;
                        }                            
                        keyIndex++;
                    }
                }    
//5> process of all key release ------------------------------------------------------------
                if(keyCount == 0)
                {
                    if(_testbit_(gbCancelKeyEntry))    //cancle key: enter energy saver mode
                    {    
                        gBOSMode = OS_ENERGY_SAVER;
                        FgNeedToBuzz = 1;
                    }
                    gBKeyPressFlag = NO_KEY_PRESS;
                }
//6> process of multi-key press ------------------------------------------------------------
                else if(keyCount >1)
                {
                    if(_testbit_(gbCancelKeyEntry))    //cancel+demo key: enter demo mode
                    {
                        if(keyCount ==2)
                        {
                            if(gBKeyValue[0]==KEY_PAUSE_CANCEL_SAVE)
                            {
                                if(gBKeyValue[1]==KEY_DEFROST)
                                {                                
                                    if(ExecuteCancelPulsDefrostKeyFunc())
                                    {
                                        gbBuzzToneReq = 1;
                                        gBBuzzToneType    = BUZZ_DEMO;
                                    }
                                } 
                                else if(gBKeyValue[1] == KEY_MICRO)
                                {
                                    FgNeedToBuzz = ExecuteCancelPulsMicroKeyFunc();
                                }
                            }
                        }                
                    }
                    gBKeyPressFlag = MULTI_KEY_PRESS;        
                }
//7> process of single-key press ------------------------------------------------------------
                else
                {
                    gbCancelKeyEntry = 0;
                    if(gBKeyPressFlag == NO_KEY_PRESS )    
                    {            
                        //execute single key press function
                        FgNeedToBuzz=(*KeyCommandUnit[gBKeyValue][0]].KeyCommandProPtr)();
                        gBKeyPressFlag = VALID_KEY_PRESS;    
                    }
                    else
                    {
                        gBKeyPressFlag = INVALID_KEY_PRESS;    
                    }
                }    
//8> buzz if key take effect ----------------------------------------------------------------
                if(_testbit_(FgNeedToBuzz))
                {
                    gbCfgModifyReq = 1;
                    gbBuzzToneReq = 1;
                    gBBuzzToneType    = BUZZ_KEYPRESS;
                }
//9> reset door open 10min if any key press--------------------------------------------------                
                gbDoorOpen10minResetReq = 1;    
            }
        }
    }
}

使用特权

评论回复
9
linqing171| | 2008-8-20 15:52 | 只看该作者

先发电路图。

如果是行列扫描的话,组合键第一个按下的好知道,第二个分析的时候,要考虑之前已经知道的第一个按下的哪个。

使用特权

评论回复
10
cuilaiabc| | 2013-12-17 11:06 | 只看该作者
LZ辛苦,谢谢奉献

使用特权

评论回复
11
zjh6607476| | 2013-12-17 11:23 | 只看该作者
就是加按键**,自己去处理就好了!!不要只想着独立出来的一个按键!!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

43

主题

83

帖子

0

粉丝