T6_O1L #61

Closed
sundp wants to merge 59 commits from T6_O1L into L8
3 changed files with 18 additions and 8 deletions
Showing only changes of commit c05dc010e5 - Show all commits

View File

@ -1670,6 +1670,7 @@ void OnRestoreSTSCFGContextProcess(void)
//sampling_heartbeat_periodicity = (sampling_heartbeat_periodicity > 0)? sampling_heartbeat_periodicity : 1; // in seconds unit
//sampling_heartbeat_periodicity = sampling_heartbeat_periodicity*1000;
#ifdef STS_P2
STS_TxPeriod_sec = periodicity;
STS_HeartBeatTimerPeriod_sec = sampling_heartbeat_periodicity;
#endif

View File

@ -3,6 +3,7 @@
#include "main.h"
#include "sys_app.h"
/* USER CODE BEGIN Includes */
#include "yunhorn_sts_sensors.h"
#include "app_tof_peoplecount.h"
#ifdef STS_P2
#include "VL53L1X_API.h"
@ -17,17 +18,23 @@
extern I2C_HandleTypeDef hi2c2;
volatile sts_people_count_sensor_data_t sts_people_count_sensor_data={0,0,0,2,'M',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
extern volatile uint32_t STS_TOFScanPeriod_sec, STS_TxPeriod_sec, STS_HeartBeatTimerPeriod_sec;
extern volatile sts_cfg_nvm_t sts_cfg_nvm;
volatile uint8_t sts_tof_presence_state=0, sts_tof_presence_state_changed=0;
/* TIMING_BUDGET, in ms possible values [15, 20, 50, 100, 200, 500] */
/* DISTANCE_THRESHOLD = MAX - ASSUME_CHILD_HEIGHT(800mm) */
volatile sts_ppc_cfg_type_t ppc_cfg[6] = {
{DOOR_JAM_2000, 8, 2000,0,1600,8,33,DISTANCE_MODE_SHORT,175,247},
{DOOR_JAM_2000, 8, 2000,0,1600,8,33,DISTANCE_MODE_SHORT,175,247},
{DOOR_JAM_2400, 10, 2400,0,1600,8,33,DISTANCE_MODE_LONG,175,231},
/*
{DOOR_JAM_2000, 16, 2000,0, 1200,16, tbms_33,DISTANCE_MODE_LONG,199,199},
{DOOR_JAM_2400, 10, 2400,0, 1600,8, tbms_50,DISTANCE_MODE_LONG,175,231},
{DOOR_JAM_3000, 10, 3000,0, 2200,8,tbms_100,DISTANCE_MODE_LONG,175,231},
{DOOR_JAM_3500, 10, 3500,0, 2700,8,tbms_100,DISTANCE_MODE_LONG,175,231},
{DOOR_JAM_4000, 10, 4000,0, 3200,8,tbms_200,DISTANCE_MODE_LONG,175,231},
{DOOR_SIDE_1600, 8, 1600,0, 300,8, tbms_33,DISTANCE_MODE_SHORT,175,231},
*/
};
volatile sts_zone_center_by_rows_of_spads_t zone_center[4]={
{4, 151, 247},
@ -117,13 +124,13 @@ int ProcessPresenceDetectionData(int16_t Distance, uint8_t zone, uint8_t RangeSt
MinDistance = Distances[zone][i];
}
}
APP_LOG(TS_OFF, VLEVEL_M, "\r\nMin Distance =%d ", MinDistance);
//APP_LOG(TS_OFF, VLEVEL_M, "\r\nMin Distance =%d ", MinDistance);
if (MinDistance < ppc_cfg[sts_distance_mode].dist_threshold) {
// Someone is in !
CurrentZoneStatus = SOMEONE;
APP_LOG(TS_OFF, VLEVEL_M, "---> Someone is in");
//APP_LOG(TS_OFF, VLEVEL_M, "---> Someone is in");
}
APP_LOG(TS_OFF, VLEVEL_M, "\r\n");
//APP_LOG(TS_OFF, VLEVEL_M, "\r\n");
//return CurrentZoneStatus;
#if 1
// left zone
@ -276,13 +283,13 @@ int ProcessPeopleCountingData(int16_t Distance, uint8_t zone, uint8_t RangeStatu
MinDistance = Distances[zone][i];
}
}
APP_LOG(TS_OFF, VLEVEL_M, "\r\n MinDistance & dist_threshold ---%d %d", MinDistance,ppc_cfg[sts_distance_mode].dist_threshold);
//APP_LOG(TS_OFF, VLEVEL_M, "\r\n MinDistance & dist_threshold ---%d %d", MinDistance,ppc_cfg[sts_distance_mode].dist_threshold);
if (MinDistance < ppc_cfg[sts_distance_mode].dist_threshold) {
// Someone is in !
CurrentZoneStatus = SOMEONE;
APP_LOG(TS_OFF, VLEVEL_M, ">SOMEONE IN");
//APP_LOG(TS_OFF, VLEVEL_M, ">SOMEONE IN");
}
APP_LOG(TS_OFF, VLEVEL_M, "\r\n");
//APP_LOG(TS_OFF, VLEVEL_M, "\r\n");
// left zone
if (zone == LEFT) {
@ -546,6 +553,8 @@ void STS_TOF_VL53LX_PeopleCounting_Process_Init(void)
{
APP_LOG(TS_OFF, VLEVEL_M,"\n\n# YUNHORN STS-P2 PEOPLE COUNTING PROCESS #\r\n");
sts_tof_vl53lx_peoplecount_init();
sts_people_count_sensor_data.Count_Period = sts_cfg_nvm.periodicity;
sts_people_count_sensor_data.Count_Period_Unit = sts_cfg_nvm.unit;
}
@ -702,7 +711,7 @@ int sts_tof_vl53lx_peoplecount_init(void)
/* Initialize and configure the device according to people counting need */
status = VL53L1X_SensorInit(dev);
sts_distance_mode = sts_door_jam_profile;
sts_distance_mode = (sts_door_jam_profile ==5)?DISTANCE_MODE_SHORT:DISTANCE_MODE_LONG;
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Door Jam Profile=%d, distance Mode =%d \r\n", sts_door_jam_profile, sts_distance_mode);
APP_LOG(TS_OFF, VLEVEL_M, "\r\n MaxDistance=%d, \nMinDistance=%d \ndist_threshold=%d \n timing_budget=%d \n distance_mode=%d \r\n",
ppc_cfg[sts_distance_mode].max_distance, ppc_cfg[sts_distance_mode].min_distance, ppc_cfg[sts_distance_mode].dist_threshold,ppc_cfg[sts_distance_mode].timing_budget,ppc_cfg[sts_distance_mode].distance_mode);
@ -770,7 +779,7 @@ int sts_tof_vl53lx_peoplecount_start(void)
if ((RangeStatus == 0) || (RangeStatus == 4) || (RangeStatus == 7)) {
if (Distance <= ppc_cfg[sts_distance_mode].min_distance) //MIN_DISTANCE) // wraparound case see the explanation at the constants definition place
Distance = ppc_cfg[sts_distance_mode].max_distance + ppc_cfg[sts_distance_mode].min_distance; //MAX_DISTANCE + MIN_DISTANCE;
APP_LOG(TS_OFF, VLEVEL_M, "\r\nRangeStatus=%d Distance=%d \r\n", RangeStatus, Distance);
//APP_LOG(TS_OFF, VLEVEL_M, "\r\nRangeStatus=%d Distance=%d \r\n", RangeStatus, Distance);
}
else // severe error cases
Distance = ppc_cfg[sts_distance_mode].max_distance; //MAX_DISTANCE;