/**
  ******************************************************************************
  * @file          : app_tof_peoplecount.h
  * @author        : IMG SW Application Team
  * @brief         : This file provides code for the configuration
  *                  of the STMicroelectronics.X-CUBE-TOF1.3.2.0 instances.
  ******************************************************************************
  *
  * @attention
  *
  * Copyright (c) 2022 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __APP_TOF_PEOPLECOUNT_H
#define __APP_TOF_PEOPLECOUNT_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/

/* Exported defines ----------------------------------------------------------*/


 // People Counting defines
 #define NOBODY                    0
 #define SOMEONE                   1
 #define LEFT                      0
 #define RIGHT                     1

 #define DOOR_JAM_2400             1
 #define DOOR_JAM_2000             2
 #define ON_SIDE                   3

 #define DISTANCE_MODE_LONG        2


 // define here the profile for your case.
 #define PPC_PROFILE DOOR_JAM_2400

 #define TRACE_PPC				     0

 //PPC_PROFILE DOOR_JAM_2400
 #if PPC_PROFILE == DOOR_JAM_2400
 #define PROFILE_STRING                               "DOOR_JAM_2400"
 #define DISTANCES_ARRAY_SIZE                         10   // nb of samples
 #define MAX_DISTANCE                                 2400 // mm   was 2400
 #define MIN_DISTANCE                                 0   // mm
 #define DIST_THRESHOLD                               1600  // mm
 #define ROWS_OF_SPADS                                8 // 8x16 SPADs ROI
 #define TIMING_BUDGET                                33  // was 20 ms, I found 33 ms has better succes rate with lower reflectance target
 #define DISTANCE_MODE                                DISTANCE_MODE_LONG
 #endif

 #if ROWS_OF_SPADS == 4
 #define FRONT_ZONE_CENTER                            151
 #define BACK_ZONE_CENTER                             247
 #elif ROWS_OF_SPADS == 6
 #define FRONT_ZONE_CENTER                            159
 #define BACK_ZONE_CENTER                             239
 #elif ROWS_OF_SPADS == 8
 #define FRONT_ZONE_CENTER                            175 // was 167, see UM2555 on st.com, centre = 175 has better return signal rate for the ROI #1
 #define BACK_ZONE_CENTER                             231
 #endif

/* Exported functions --------------------------------------------------------*/

void STS_TOF_VL53LX_PeopleCounting_Process(void);

int sts_tof_vl53lx_peoplecount(void);
int ProcessPeopleCountingData(int16_t Distance, uint8_t zone, uint8_t RangeStatus);

#ifdef __cplusplus
}
#endif

#endif /* __APP_TOF_PEOPLECOUNT_H */
