From 305bc61274ed126cdd681c2fa151cc4df557bac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=86=AFSir?= Date: Sat, 4 May 2024 05:19:26 +0800 Subject: [PATCH] Add sensor_Count --- Firmware/Core/apps/Inc/key.h | 3 ++- Firmware/Core/apps/src/key.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Firmware/Core/apps/Inc/key.h b/Firmware/Core/apps/Inc/key.h index 12604cd..48fa7ee 100644 --- a/Firmware/Core/apps/Inc/key.h +++ b/Firmware/Core/apps/Inc/key.h @@ -12,5 +12,6 @@ #include "main.h" -void CheckButtonEvents(); +uint16_t getSensor_Count(); +void setSensor_Count(uint16_t count); #endif //APPS_CORE_APPS_INC_KEY_H_ diff --git a/Firmware/Core/apps/src/key.c b/Firmware/Core/apps/src/key.c index 075cb1f..4038790 100644 --- a/Firmware/Core/apps/src/key.c +++ b/Firmware/Core/apps/src/key.c @@ -1,5 +1,6 @@ #include "key.h" +uint16_t sensor_Count = 0; void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if (GPIO_Pin == KEY1_Pin) { if (HAL_GPIO_ReadPin(KEY1_GPIO_Port, KEY1_Pin) == GPIO_PIN_SET) { @@ -19,5 +20,17 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { keyVal = 3; } } + //光耦测速模块 + if(GPIO_Pin == SENOR_Pin){ + if(HAL_GPIO_ReadPin(SENOR_GPIO_Port,SENOR_Pin) == GPIO_PIN_SET){ + sensor_Count++; + } + } +} +uint16_t getSensor_Count(){ + return sensor_Count; +} +void setSensor_Count(uint16_t count){ + sensor_Count = count; }