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

📄 input.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 4 页
字号:
                }                bState = 0;                break;        }    }#endif  // #if (IR_CODE_TYPE == SW_NEC)// =============================================================================// =============================================================================#if (IR_CODE_TYPE == HW_NEC)    // save status    __INTISRintProc12ndStatus.dwPLAT_IR_DATA = REG_PLAT_IR_DATA;    __INTISRintProc12ndStatus.dwPLAT_IR_RAW_CODE = REG_PLAT_IR_RAW_CODE;#ifdef RESET_IR_AFTER_IR_INT#ifdef SUPPORT_GAME_IR    if (_blGameIRMode)    {        INPUT_SetGameIR();    }    else    {        _ResetIR();    }#else   // #ifdef SUPPORT_GAME_IR    //kevin0.75, reset IR    _ResetIR();#endif  // #ifdef SUPPORT_GAME_IR#endif  // #ifdef RESET_IR_AFTER_IR_INT    // set function pointer for ISR and DSR    __pINTDSRRoutine[INT_NO10][__dwINTDSRCounter[INT_NO10] ++] = DSR_IR;#endif  // #if (IR_CODE_TYPE == HW_NEC)// =============================================================================}#endif  // #if (PLATFORM == ECOS_OS)// ***********************************************************************//  Function    :   DSR_IR//  Description :   Read remote controller input when IR INT is triggered//  Arguments   :   NONE//  Return      :   input key//  Side Effect :// *********************************************************************** VOID    DSR_IR(VOID){// =============================================================================#if (IR_CODE_TYPE == SW_KONKA)    BYTE i;    if(bIRStep!=19)            return;   // not reach 19, do nothing    bIRFlag = 1;      // means in receiving IR code now{    bIRStep = 0;  // reach 19, reset the step first    bDataCode = 0;    _bCustomerCode = 0;// the timing: 100 = 1ms    for (i=0;i<8;i++)    {        if (IR_code[i+3] >= 230 && IR_code[i+3] <= 270)  // 2.5ms low  = 1   1.5ms low = 0            _bCustomerCode |=  (0x80 >> i);        else if(IR_code[i+3] >= 130 && IR_code[i+3] <= 200) // 170            _bCustomerCode &=  ~(0x80 >> i);        else      {         _bKeyGet = KEY_NO_KEY;        bIRFlag = 0;   // process finish            return ;    }    }    if (_bCustomerCode == 0x06)  // the customer code for Konka IR    {        for (i=0;i<8;i++)        {            if (IR_code[i+11] >= 230 && IR_code[i+11] <= 270)  // is 1  2.5ms  low, 250                bDataCode |=  (0x80 >> i);            else if(IR_code[i+11] >= 130 && IR_code[i+11] <= 200)  // 170                _bCustomerCode &=  ~(0x80 >> i);            else              {                 _bKeyGet = KEY_NO_KEY;        bIRFlag = 0;   // process finish                return;            }        }//Alan2.05        _bKeyGet = aIRMap[bDataCode];         _bKeyGet = _IRInfo.aIRMap[bDataCode];     }    else    //if(_bCustomerCode == 0x06)        _bKeyGet = KEY_NO_KEY;#endif  // #if (IR_CODE_TYPE == SW_KONKA)// =============================================================================// =============================================================================#if (IR_CODE_TYPE == HW_NEC)    DWORD dwTimeISRKey;     dwTimeISRKey = OS_GetSysTimer();#ifdef SUPPORT_GAME_IR    if (_blGameIRMode)    {        _bKeyGet = INPUT_Game_RemoteScan();    }    else#endif  // #ifdef SUPPORT_GAME_IR    {        _bKeyGet = INPUT_RemoteScan();    }//    _dwTimeISRKeyPrev2 = dwTimeISRKey;#endif  // #if (IR_CODE_TYPE == HW_NEC)// =============================================================================    if (_bKeyGet != KEY_NO_KEY)    {        if ( _bKeyGet == _bISRKeyPrev )        {            // re-push the same key within 250 msec#if (IR_CODE_TYPE == HW_NEC)            if ( (dwTimeISRKey- _dwTimeISRKeyPrev) < COUNT_250_MSEC )#else   // #if (IR_CODE_TYPE == HW_NEC)            if(!bIRCheck)#endif  // #if (IR_CODE_TYPE == HW_NEC)            {                // only these keys have continue capability                if (    (_bKeyGet!=KEY_VOL_UP) &&                        (_bKeyGet!=KEY_VOL_DOWN) &&                        (_bKeyGet!=KEY_KEYUP) &&                        (_bKeyGet!=KEY_KEYDOWN)     )                {                    _bKeyGet = KEY_NO_KEY;                }                                //kevin0.72, adjust continuous key timing to let it less sensitive                //kevin0.68, discard continuous keys (KEY_VOL_UP....) within 150ms; otherwise there will be 2 KEY_VOL_UPs when pressing a single KEY_VOL_UP#if (IR_CODE_TYPE == HW_NEC)                else if( (dwTimeISRKey-_dwTimeISRKeyPrev) < COUNT_200_MSEC )                  {                    _bKeyGet = KEY_NO_KEY;                      //return; //not update _dwTimeISRKeyPrev                }#endif  // #if (IR_CODE_TYPE == HW_NEC)            }        }                       if ( _bKeyGet != KEY_NO_KEY )        {//            printf("Key: %lx\n", _bKeyGet);#if (IR_CODE_TYPE == HW_NEC)            _dwTimeISRKeyPrev = dwTimeISRKey;            _dwTimeISRKeyPrev2 = dwTimeISRKey;#endif  // #if (IR_CODE_TYPE == HW_NEC)            //__bISRKeyRead = TRUE;            __bISRKey = _bKeyGet;            _bISRKeyPrev = _bKeyGet;        }    }#if (IR_CODE_TYPE == HW_NEC)//  _dwTimeISRKeyPrev = dwTimeISRKey; //UTL_GetSysTimer();#endif  // #if (IR_CODE_TYPE == HW_NEC)#if (IR_CODE_TYPE == SW_KONKA)    bIRFlag = 0;    // hwtan.nec.0331 for SW_IR#endif  // #if (IR_CODE_TYPE == SW_NEC)    return ;}// ***********************************************************************//  Function    :   INPUT_RemoteScan//  Description :   Read remote controller input when IR INT is triggered//  Arguments   :   NONE//  Return      :   input key//  Side Effect :// ***********************************************************************#if (IR_CODE_TYPE == HW_NEC)BYTE    INPUT_RemoteScan(VOID){//IR stage#define IR_STAGE_IDLE   0x1#define IR_STAGE_DATA   0x2#define IR_STAGE_REPEAT 0x4//IR INT source#define IR_INT_INVALID  0x1 //data code invalid/customer code invalid/repeat code timeout#define IR_INT_DATA     0x2#define IR_INT_REPEAT   0x4    static BYTE bIRstage = IR_STAGE_IDLE;    BYTE    bIRINT;    DWORD   dwData;    DWORD   dwRawCode;    BYTE    bData;    // LLY2.36, just polling the rising edge of IR repeat flag to check if any key input.    if(_bIRCheckMode==IR_CHECK_MODE_POLLING)    {        BYTE    bRepeat;        dwData = REG_PLAT_IR_DATA;        dwRawCode = REG_PLAT_IR_RAW_CODE;        bRepeat = (BYTE)((dwData&0x00000100)>>8);//        printf("%lx - %lx\n", _bPreRepeatFlag, bRepeat);        if(!_bPreRepeatFlag && bRepeat)        {            if( !(dwData & 0x00000400L) // bit[10] = 1, means invalid data code#ifdef CHECK_IR_CUSTOMER_CODE                // check customer code (To Do: LSB first)                && ( (BYTE)(dwRawCode>>24) == _bCustomerCode )                && ( (BYTE)(dwRawCode>>16) == _bCustomerCode1 )#endif  // #ifdef CHECK_IR_CUSTOMER_CODE                )            {                bIRINT = IR_INT_DATA;            }            else            {                bIRINT = IR_INT_INVALID;            }            //printf("0 to 1: %lx\n", bIRINT);        }        /*        else if( (_bPreRepeatFlag == bRepeat)             && ( (OS_GetSysTimer() - _dwTimeISRKeyPrev2) < COUNT_250_MSEC) )        {//            printf("Same\n");            bIRINT = IR_INT_REPEAT;        }        */        else        {            bIRINT = IR_INT_INVALID;        }        _bPreRepeatFlag = bRepeat;//        if(!_bPreRepeatFlag)//        {//            printf("%lx\n", _bPreRepeatFlag);//        }    }    else    {#if (PLATFORM == ECOS_OS)    dwData = __INTISRintProc12ndStatus.dwPLAT_IR_DATA;    dwRawCode = __INTISRintProc12ndStatus.dwPLAT_IR_RAW_CODE;#else    dwData = REG_PLAT_IR_DATA;    dwRawCode = REG_PLAT_IR_RAW_CODE;#endif    //Decide IR INT source    if ( ( dwData & 0x00000100)          //&& ( (UTL_GetSysTimer() - _dwTimeISRKeyPrev2) < COUNT_150_MSEC ) //kevin0.85, fix next repeat KEY is regarded as repeat key of prev KEY when moving out of and again to IR receiver range          && ( (OS_GetSysTimer() - _dwTimeISRKeyPrev2) < COUNT_250_MSEC ) //kevin0.91, fix cont. KEY VOL-/+ may stop in the middle, but not at min/max        )    {        bIRINT = IR_INT_REPEAT;    }    else if (  ( !(dwData & 0x00000500)  ) //0x00000400 | 0x00000100#ifdef    CHECK_IR_CUSTOMER_CODE                // check customer code (To Do: LSB first)                && ( (BYTE)(dwRawCode>>24) == _bCustomerCode )                && ( (BYTE)(dwRawCode>>16) == _bCustomerCode1 ) #endif                  )    {        bIRINT = IR_INT_DATA;    }    else    {        bIRINT = IR_INT_INVALID;            }    }    //Read data    if ( bIRstage & IR_STAGE_IDLE)      {        if (bIRINT & IR_INT_DATA)   //data code        {            bData = (BYTE)(dwData & 0x000000ff);#ifdef   SHOW_IR_MAP            printf("IR Raw Code = %8x\n", dwData);#endif            bIRstage = IR_STAGE_DATA;        }        else //IR_INT_REPEAT/IR_INT_INVALID        {            bData = 0xFF;            //bIRstage remains unchanged        }    }    else //IR_STAGE_DATA/IR_STAGE_REPEAT    {        if (bIRINT & IR_INT_DATA) //data code        {            bData = (BYTE)(dwData & 0x000000ff);#ifdef   SHOW_IR_MAP            printf("IR Raw Code = %8x\n", dwData);#endif            //bIRstage remains unchanged

⌨️ 快捷键说明

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