improve swing logic
This commit is contained in:
parent
34294dd93b
commit
70448304f0
|
@ -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);
|
||||
|
|
Binary file not shown.
|
@ -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)
|
||||
{
|
||||
yes_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
no_count=0;
|
||||
}
|
||||
|
||||
PresenceState = 1;
|
||||
|
||||
} else {
|
||||
PresenceState = 0;
|
||||
} else
|
||||
{
|
||||
LED1_OFF;
|
||||
if(no_count<TIME_C)
|
||||
{
|
||||
no_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
yes_count=0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue