From a3bb280c7e8b277f7131063b5c771a742fc793b2 Mon Sep 17 00:00:00 2001 From: CaoWangrenbo Date: Fri, 5 Jan 2024 16:00:06 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/by_rt_button.h | 4 +--- app/isr.c | 12 +++++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/by_rt_button.h b/app/by_rt_button.h index e124b70..2b84c70 100644 --- a/app/by_rt_button.h +++ b/app/by_rt_button.h @@ -3,9 +3,7 @@ #include "stdio.h" #include "ch32v30x.h" -// #define rotate_button_press_short 1 -// #define rotate_button_forward 2 -// #define rotate_button_backward 3 + typedef enum rotate_button_event{ rotate_button_press_short = 1, rotate_button_press_long = 2, diff --git a/app/isr.c b/app/isr.c index 1ddb4cb..fb875c8 100644 --- a/app/isr.c +++ b/app/isr.c @@ -218,26 +218,24 @@ void EXTI15_10_IRQHandler(void) EXTI_ClearITPendingBit(EXTI_Line10); } if (SET == EXTI_GetITStatus(EXTI_Line11)) { - static uint64_t time_fly = 0; + static uint64_t time_via = 0; if (RESET == gpio_get_level(E11)) { system_delay_us(200); if (RESET == gpio_get_level(E11)) { - time_fly = system_get_tick(); - // rotate_button = rotate_button_press_short; + time_via = system_get_tick(); } EXTI_ClearITPendingBit(EXTI_Line11); } else { system_delay_us(200); if (SET == gpio_get_level(E11)) { - // rotate_button = rotate_button_press_short; - time_fly = system_get_tick() - time_fly; - if (time_fly > LONG_PRESS_THRESHOLD_TICK) { + 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_fly = 0; + time_via = 0; } EXTI_ClearITPendingBit(EXTI_Line11); }