diff --git a/code/application/source/cardv/SrcCode/Dx/565_HUNTING_EVB_LINUX_4G_S530/DxInput_Key.c b/code/application/source/cardv/SrcCode/Dx/565_HUNTING_EVB_LINUX_4G_S530/DxInput_Key.c index cb328e16f..95b5fcd8f 100644 --- a/code/application/source/cardv/SrcCode/Dx/565_HUNTING_EVB_LINUX_4G_S530/DxInput_Key.c +++ b/code/application/source/cardv/SrcCode/Dx/565_HUNTING_EVB_LINUX_4G_S530/DxInput_Key.c @@ -14,13 +14,18 @@ /** \addtogroup mIPRJAPKeyIO */ //@{ - +#include "PrjInc.h" #include "DxCfg.h" #include "IOCfg.h" #include "DxInput.h" #include "KeyDef.h" #include "comm/hwclock.h" #include "comm/hwpower.h" +#include "kwrap/perf.h" + +#if HUNTING_CAMERA_MCU == ENABLE +#include +#endif #if 0 #include "rtc.h" #include "Delay.h" @@ -145,7 +150,7 @@ void DrvKey_Init(void) @return UINT32 */ static UINT32 KeyTestPressCnt = 0; -static BOOL KeyPress_Long = FALSE; +//static BOOL KeyPress_Long = FALSE; static UINT32 SendKeyCnt = 0; #define LongKey_Cnt (40)// times #define SendKey_LessCnt (6 + 1)///(6 + 1)//6 :vaild times @@ -153,6 +158,17 @@ static UINT32 SendKeyCnt = 0; UINT32 DrvKey_DetNormalKey(void) { UINT32 uiKeyCode = 0; + VOS_TICK tticktmp=0; + static VOS_TICK ttick=0; + static UINT32 timeflag = 0; + static UINT32 cmdflag = 0; + static UINT32 time = 0; + + static VOS_TICK retset_ttick=0; + static UINT32 retset_flag = 0; + static UINT32 retset_PressCnt = 0; + static UINT32 retset_time = 0; + static UINT32 retset_cmdflag = 0; #if (ADC_KEY == ENABLE) UINT32 uiKey1Lvl = VolDet_GetKey1Level(); @@ -207,32 +223,64 @@ UINT32 DrvKey_DetNormalKey(void) if (!gpio_getPin(GPIO_KEY_TEST)) { //uiKeyCode |= FLGKEY_SHUTTER2; - KeyTestPressCnt++; - if(KeyTestPressCnt > LongKey_Cnt) //long press - { - KeyPress_Long = TRUE; - uiKeyCode |= FLGKEY_CUSTOM1; - } - }else{ - if(KeyTestPressCnt){ - if(KeyPress_Long){ - if(++SendKeyCnt < SendKey_LessCnt){ //long key - uiKeyCode |= FLGKEY_CUSTOM1; - }else{ - SendKeyCnt = 0; - KeyTestPressCnt = 0; - KeyPress_Long = FALSE; - } - }else{ - if(++SendKeyCnt < SendKey_LessCnt){ //shot key - uiKeyCode |= FLGKEY_SHUTTER2; - }else{ - SendKeyCnt = 0; - KeyTestPressCnt = 0; - KeyPress_Long = FALSE; - } - } + if(0 == timeflag){ + vos_perf_mark(&ttick); + timeflag = 1; } + KeyTestPressCnt++; + vos_perf_mark(&tticktmp); + time = ((tticktmp/1000) - (ttick/1000)); + }else{ + if(KeyTestPressCnt && (0 == sf_get_fw_update())){ + if((!cmdflag) && (0 == sf_get_fw_update()) && (time >= 3000) && (sf_get_pir_statu_flag())){ + cmdflag = 1; + BKG_PostEvent(NVTEVT_BKW_FORMAT_CARD); + }else if((!cmdflag) && (0 == sf_get_fw_update()) && (time >= 10000)){ + cmdflag = 1; + }else if(++SendKeyCnt < SendKey_LessCnt){//shot key + uiKeyCode |= FLGKEY_SHUTTER2; + }else { + printf("[%s:%d] SendKeyCnt:%d KeyTestPressCnt:%d time: %dms\n", __FUNCTION__, __LINE__, SendKeyCnt, KeyTestPressCnt, time); + SendKeyCnt = 0; + KeyTestPressCnt = 0; + timeflag = 0; + ttick = 0; + cmdflag = 0; + } + + }else{ + SendKeyCnt = 0; + KeyTestPressCnt = 0; + timeflag = 0; + ttick = 0; + cmdflag = 0; + } + } + + + if(!(gpio_getPin(GPIO_KEY_RIGHT))){//reset key + if(0 == retset_flag){ + vos_perf_mark(&retset_ttick); + retset_flag = 1; + } + retset_PressCnt++; + vos_perf_mark(&tticktmp); + retset_time = ((tticktmp/1000) - (retset_ttick/1000)); + if((0 == sf_get_fw_update()) && (0 == retset_cmdflag) && (retset_time >= 5000)){ + retset_cmdflag = 1; + Ux_SendEvent(0, NVTEVT_EXE_SYSRESET_NO_WIN, 1, 0); + } + }else { + if(retset_PressCnt) + { + printf("[%s:%d] retset_time: %dms\n", __FUNCTION__, __LINE__, retset_time); + retset_flag = 0; + retset_ttick = 0; + retset_PressCnt = 0; + retset_cmdflag = 0; + } + + } #endif /*