From a6a0759e70adbfaf9b2b090bd0c25541be8bb104 Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期四, 05 六月 2025 14:07:55 +0800 Subject: [PATCH] 2.85,加入按下按键点击震动100ms 原来是10ms没感觉 --- Src/stm32l0xx_it.c | 31 +++++++++++++++++++++++++------ 1 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Src/stm32l0xx_it.c b/Src/stm32l0xx_it.c index d91cb50..874f8f4 100644 --- a/Src/stm32l0xx_it.c +++ b/Src/stm32l0xx_it.c @@ -43,6 +43,8 @@ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ float nomove_count=0; +float button_delay = 1; +u16 button_start; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ @@ -67,7 +69,7 @@ /* USER CODE END EV */ /******************************************************************************/ -/* Cortex-M0+ Processor Interruption and Exception Handlers */ +/* Cortex-M0+ Processor Interruption and Exception Handlers */ /******************************************************************************/ /** * @brief This function handles Non maskable interrupt. @@ -93,6 +95,7 @@ while (1) { /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + printf("HardFault_Handler.\r\n"); SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; /* USER CODE END W1_HardFault_IRQn 0 */ } @@ -151,24 +154,40 @@ void EXTI0_1_IRQHandler(void) { /* USER CODE BEGIN EXTI0_1_IRQn 0 */ + static u16 lastcount=0; + u16 count_diff; + SystemClock_Config(); if(GET_IMUINT) { nomove_count = 0; } - if(!GET_USERKEY) + if(!GET_USERKEY) { userkey_state = 1; - + if(button_delay>=1) + { + button_start = GetLPTime(); + button_delay = 0; + }else{ + u16 button_time = GetLPTime()-button_start; + if(button_time<0) + button_time+=1000; + if(button_time>50&&button_time<300) + { +// DoubleClickProcess(); + } + + } if(g_com_map[MOTOR_ENABLE]) { MOTOR_ON; - delay_ms(10); + delay_ms(100); MOTOR_OFF; } nomove_count = 0; - waitusart_timer = tag_frequency*USART_KEEPWAKE_TIME; - UsartInit(); +// waitusart_timer = tag_frequency*USART_KEEPWAKE_TIME; + // UsartInit(); // MOTOR_ON; } -- Gitblit v1.9.3