/* Includes ------------------------------------------------------------------*/ #include "main.h" #include "sys_app.h" /* USER CODE BEGIN Includes */ #include "app_tof_peoplecount.h" #include "VL53L1X_API.h" #include "VL53l1X_calibration.h" #include "X-NUCLEO-53L1A1.h" /* USER CODE END Includes */ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ /* Private variables ---------------------------------------------------------*/ extern I2C_HandleTypeDef hi2c2; uint16_t dev=0x52; int status = 0; volatile int IntCount; #define isInterrupt 1 /* If isInterrupt = 1 then device working in interrupt mode, else device working in polling mode */ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN PFP */ /* Private function prototypes -----------------------------------------------*/ /* USER CODE END PFP */ int sts_tof_vl53lx_peoplecount(void); /* USER CODE BEGIN 0 */ #define VL53L1X_INT_Pin (GPIO_PIN_10) // WL55JC GPIO_PIN_10, F401xE ==>(GPIO_PIN_4) /* void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if (GPIO_Pin==VL53L1X_INT_Pin) { IntCount++; } } */ /* USER CODE END 0 */ int ProcessPeopleCountingData(int16_t Distance, uint8_t zone, uint8_t RangeStatus) { static int PathTrack[] = {0,0,0,0}; static int PathTrackFillingSize = 1; // init this to 1 as we start from state where nobody is any of the zones static int LeftPreviousStatus = NOBODY; static int RightPreviousStatus = NOBODY; static int PeopleCount = 0; static uint16_t Distances[2][DISTANCES_ARRAY_SIZE]; static uint8_t DistancesTableSize[2] = {0,0}; uint16_t MinDistance; uint8_t i; #ifdef TRACE_PPC #define TIMES_WITH_NO_EVENT 10// was 40 static uint32_t trace_count = TIMES_WITH_NO_EVENT; // replace by 0 if you want to trace the first TIMES_WITH_NO_EVENT values #endif int CurrentZoneStatus = NOBODY; int AllZonesCurrentStatus = 0; int AnEventHasOccured = 0; // Add just picked distance to the table of the corresponding zone if (DistancesTableSize[zone] < DISTANCES_ARRAY_SIZE) { Distances[zone][DistancesTableSize[zone]] = Distance; DistancesTableSize[zone] ++; } else { for (i=1; i= 2) { for (i=1; i if next is 0 : check if exit PathTrack[PathTrackFillingSize-1] = AllZonesCurrentStatus; } //#ifdef TRACE_PPC // if (AnEventHasOccured) { // for (int j=0; j