pref: 优化长短按判断

This commit is contained in:
2024-01-06 16:47:15 +08:00
parent 8f0a04b962
commit abca5d603c
3 changed files with 17 additions and 23 deletions

View File

@@ -219,24 +219,18 @@ void EXTI15_10_IRQHandler(void)
}
if (SET == EXTI_GetITStatus(EXTI_Line11)) {
static uint64_t time_via = 0;
system_delay_ms(10);
if (RESET == gpio_get_level(E11)) {
system_delay_us(200);
if (RESET == gpio_get_level(E11)) {
time_via = system_get_tick();
}
time_via = system_get_tick();
EXTI_ClearITPendingBit(EXTI_Line11);
} else {
system_delay_us(200);
if (SET == gpio_get_level(E11)) {
time_via = system_get_tick() - time_via;
if (time_via > LONG_PRESS_THRESHOLD_TICK) {
rotate_button = rotate_button_press_long;
} else {
rotate_button = rotate_button_press_short;
}
time_via = 0;
} else if (SET == gpio_get_level(E11)) {
time_via = system_get_tick() - time_via;
if (time_via > LONG_PRESS_THRESHOLD_TICK) {
rotate_button = rotate_button_press_long;
} else {
rotate_button = rotate_button_press_short;
}
time_via = 0;
EXTI_ClearITPendingBit(EXTI_Line11);
}
if (SET == EXTI_GetITStatus(EXTI_Line12)) {