Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么multil press要去切换到single press状态,直接切换到SHORT PRESS UP状态不是更好嘛, 而且切换到single press状态还有冗余部分 #47

Open
1-seven opened this issue Jun 1, 2024 · 0 comments

Comments

@1-seven
Copy link

1-seven commented Jun 1, 2024

case SINGLE_PRESS:
/1. 首先进入这里前handle->ticks_time_count 已经在multi_press中清零, 而能进入这里的前提是不进入3,如果不进入3,handle->ticks_time_count就必定小于SHORT_PRESS/
if(handle->button_level != handle->active_level) {
handle->button_event = (uint8_t)SHORT_PRESS_UP;
VITASYNC_EVENT_CB(SHORT_PRESS_UP);
//2. 到这里的时候,由1可知handle->ticks_time_count 一定小于SHORT_PRESS(300ms),所以下面的else是冗余部分。
if(handle->ticks_time_count < SHORT_PRESS) {
handle->ticks_time_count = 0;
handle->button_state = MULTI_PRESS_COUNT;
} else {
handle->button_state = SHORT_PRESS_DOWN;
}
//3.如果按键按下时间大于连按间隔时间(程序里面设置是300ms),就进入这里
} else if(handle->ticks_time_count > SHORT_PRESS) {
handle->button_state = SHORT_PRESS_UP;
}
break;

/至于multi press中的single事件回调, 实际上可以通过连续抬起事件去触发, 在回调函数中用switch处理即可。/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant