keyscan program need help

Discussion in 'Programmer's Corner' started by JetYoung, Jul 4, 2009.

  1. JetYoung

    Thread Starter New Member

    Jul 4, 2009
    1
    0
    unsigned char Key_Scan(void)
    {
    unsigned char LastKey;
    unsigned int PushTime = 0;
    unsigned char LongPressFlag = 0;

    if (Key_Read() == NOKEY) {KeyTime = KEYTIME_FIRST; return NOKEY;} //
    Key_DelayNms(20);
    if (Key_Read() == NOKEY) {return NOKEY;}

    LastKey = Key_Read();
    while(Key_Read() == LastKey)
    {
    Key_DelayNms(1);
    Key_Ondo();

    PushTime++;
    if (PushTime >= KeyTime)
    {
    ***** if (KeyTime == KEYTIME_FIRST) KeyTime = KEYTIME_SLOW;
    ***** if (KeyTime > KEYTIME_FAST) KeyTime -= KEYTIME_STEP;
    LongPressFlag = 1;
    break;
    }
    }

    those two lines marked with *****,i don't understand why they exist ,if PushTime >=KeyTime means this key value is valid,and give a LongPressFlag,what the two lines for???
     
Loading...