区分按键单击与双击

static u8 key_double_click_cnt = 0;
if (TASK_BT == task_ctl.work_sta) {
if (key_double_click_cnt > 0) { //双击超时计时.
key_double_click_cnt–;
}

if(1 == key_double_click_cnt) {
return DOUBLE_KEY_CLICK;
}

if(DOUBLE_CLICK_KEY == key_val) {
if(key_double_click_cnt) {
key_double_click_cnt = 0;
return DOUBLE_KEY_2CLICK
} else {
key_double_click_cnt = 400/5;//超时时间
return NO_KEY;
}
}
}
return key_val;

你可能感兴趣的:(嵌入式)