diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index f201a04..e81639d 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -424,6 +424,7 @@ static UTIL_TIMER_Object_t JoinLedTimer; /* Exported functions ---------------------------------------------------------*/ /* USER CODE BEGIN EF */ extern volatile uint8_t ToF_EventDetected; +SysTime_t sts_pir_start_time, sts_pir_duration_check_time; /* USER CODE END EF */ void LoRaWAN_Init(void) @@ -656,6 +657,19 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) #ifdef STS_T6 case PIR_Pin: sts_pir_state= PIR_STATE; + // SysTime_t sts_pir_start_time, sts_pir_duration_check_time; + if (sts_pir_state == 1) { + sts_pir_start_time = SysTimeGet(); + + } else if (sts_pir_state ==0) { + sts_pir_duration_check_time = SysTimeGet(); + if ((sts_pir_duration_check_time.Seconds - sts_pir_start_time.Seconds) < 5) + { + sts_pir_state = 1; + } else { + sts_pir_state = 0; + } + } // HAL_Delay(50); //__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin); // APP_LOG(TS_OFF, VLEVEL_M, "\r\nMotion Detection result=%d \r\n", sts_pir_state); diff --git a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf index b39bb30..559123f 100644 Binary files a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf and b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf differ diff --git a/STS/TOF/App/app_tof_peoplecount.c b/STS/TOF/App/app_tof_peoplecount.c index 8b9b949..c0e743c 100644 --- a/STS/TOF/App/app_tof_peoplecount.c +++ b/STS/TOF/App/app_tof_peoplecount.c @@ -779,6 +779,10 @@ int sts_tof_vl53lx_presence_detection_init(void) return 0; } +uint8_t yes_count=0; +uint8_t no_count=0; +#define TIME_C 4 + int sts_tof_vl53lx_presence_detection_start(void) { //uint8_t byteData, sensorState=0; @@ -839,11 +843,43 @@ int sts_tof_vl53lx_presence_detection_start(void) #if 1 if ((Distance < ppc_cfg[sts_door_jam_profile].dist_threshold) && ((Distance > ppc_cfg[sts_door_jam_profile].min_distance))) { + LED1_ON; + if(yes_count(TIME_C-1)) + { + PresenceState = 1; + + } + else if(no_count>(TIME_C-1)) + { + PresenceState = 0; + } + #endif //uint8_t PresenceState2 = ProcessPresenceDetectionData(Distance, Zone, RangeStatus); //printf("\nPresenceState2 =%d \n\r", PresenceState2);