|
|
@ -65,25 +65,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
#define DEFAULT_UPDATE_RATE_PRESENCE (65.0F) //(65.0f) //default 80 unit(hz)
|
|
|
|
#define DEFAULT_UPDATE_RATE_PRESENCE (65.0F) //(65.0f) //default 80 unit(hz)
|
|
|
|
//#define DEFAULT_UPDATE_RATE_PRESENCE (80.0F) //(65.0f) //default 80 unit(hz)
|
|
|
|
//#define DEFAULT_UPDATE_RATE_PRESENCE (80.0F) //(65.0f) //default 80 unit(hz)
|
|
|
|
|
|
|
|
#define DEFAULT_SWEEPS_PER_FRAME (16.0F) // sweeps_per_frame
|
|
|
|
#define DEFAULT_HWAAS (63) //default 10 unit(hz)
|
|
|
|
#define DEFAULT_HWAAS (63) //default 10 unit(hz)
|
|
|
|
#define DEFAULT_THRESHOLD (1.2f) //default 1.5 level float [3]
|
|
|
|
#define DEFAULT_THRESHOLD (1.2f) //default 1.5 level float [3]
|
|
|
|
|
|
|
|
|
|
|
|
//acc_detector_presence_configuration_filter_parameters_t
|
|
|
|
//acc_detector_presence_configuration_filter_parameters_t
|
|
|
|
#define DEFAULT_INTER_FRAME_DEVIATION_TIME_CONST (0.5f) //default 0.5 unit(seconds) [6]
|
|
|
|
#define DEFAULT_INTER_FRAME_DEVIATION_TIME_CONST (0.5f) //default 0.5 unit(seconds) [6]
|
|
|
|
#define DEFAULT_INTER_FRAME_FAST_CUTOFF (10.0f) //default 20.0 unit(hz) [8]
|
|
|
|
#define DEFAULT_INTER_FRAME_FAST_CUTOFF (18.0f) // (10.0f) //default 20.0 unit(hz) [8]
|
|
|
|
#define DEFAULT_INTER_FRAME_SLOW_CUTOFF (0.01f) //(0.01f) 0.2 hz unit(hz) [9]
|
|
|
|
#define DEFAULT_INTER_FRAME_SLOW_CUTOFF (0.17f) // (0.01f) //(0.01f) 0.2 hz unit(hz) [9]
|
|
|
|
#define DEFAULT_INTRA_FRAME_TIME_CONST (0) //default 0.0 unit(seconds)
|
|
|
|
#define DEFAULT_INTRA_FRAME_TIME_CONST (0) //default 0.0 unit(seconds)
|
|
|
|
#define DEFAULT_INTRA_FRAME_WEIGHT (0) //default 0.6 for normal slow tracking 1.0 for fast tracking
|
|
|
|
#define DEFAULT_INTRA_FRAME_WEIGHT (0) //default 0.6 for normal slow tracking 1.0 for fast tracking
|
|
|
|
|
|
|
|
|
|
|
|
// 2025 03 26 *** if detection toggles too often, increase the following, if too sluggish, decrease it instead
|
|
|
|
// 2025 03 26 *** if detection toggles too often, increase the following, if too sluggish, decrease it instead
|
|
|
|
//#define DEFAULT_OUTPUT_TIME_CONST (0.8f) //default 0.5 unit(seconds) [5]
|
|
|
|
//#define DEFAULT_OUTPUT_TIME_CONST (0.8f) //default 0.5 unit(seconds) [5]
|
|
|
|
#define DEFAULT_OUTPUT_TIME_CONST (0.5f) //default 0.5 unit(seconds) [5]
|
|
|
|
#define DEFAULT_OUTPUT_TIME_CONST (0.2f) // (0.5f) //default 0.5 unit(seconds) [5]
|
|
|
|
//#define DEFAULT_OUTPUT_TIME_CONST (0.4f) //default 0.5 unit(seconds) [5]
|
|
|
|
//#define DEFAULT_OUTPUT_TIME_CONST (0.4f) //default 0.5 unit(seconds) [5]
|
|
|
|
|
|
|
|
|
|
|
|
#define DEFAULT_NBR_REMOVED_PC (0) //default 0 int [10]
|
|
|
|
#define DEFAULT_NBR_REMOVED_PC (0) //default 0 int [10]
|
|
|
|
|
|
|
|
|
|
|
|
#define DEFAULT_DOWNSAMPLING_FACTOR (2) //default 1
|
|
|
|
#define DEFAULT_DOWNSAMPLING_FACTOR (1) // (2) 20250427 //default 1
|
|
|
|
//#define DEFAULT_RECEIVER_GAIN (0.65f) //default 0.9 gain mdB [4]
|
|
|
|
//#define DEFAULT_RECEIVER_GAIN (0.65f) //default 0.9 gain mdB [4]
|
|
|
|
#define DEFAULT_RECEIVER_GAIN (0.65f) //default 0.9 gain mdB [4]
|
|
|
|
#define DEFAULT_RECEIVER_GAIN (0.65f) //default 0.9 gain mdB [4]
|
|
|
|
|
|
|
|
|
|
|
@ -149,8 +149,14 @@ volatile uint16_t sts_fall_rising_pattern_factor1=0, sts_fall_rising_pattern_fac
|
|
|
|
volatile uint16_t sts_roc_acc_standard_variance=0;
|
|
|
|
volatile uint16_t sts_roc_acc_standard_variance=0;
|
|
|
|
extern volatile uint8_t sts_presence_fall_detection;
|
|
|
|
extern volatile uint8_t sts_presence_fall_detection;
|
|
|
|
static uint8_t sts_rss_init_ok=0;
|
|
|
|
static uint8_t sts_rss_init_ok=0;
|
|
|
|
volatile uint8_t sts_presence_singularity=1;
|
|
|
|
volatile uint8_t sts_presence_singularity=0;
|
|
|
|
|
|
|
|
volatile uint16_t sts_rss_threshold;
|
|
|
|
extern uint8_t sts_lamp_bar_color;
|
|
|
|
extern uint8_t sts_lamp_bar_color;
|
|
|
|
|
|
|
|
volatile acc_detector_presence_handle_t handle;
|
|
|
|
|
|
|
|
volatile acc_detector_presence_result_t result;
|
|
|
|
|
|
|
|
volatile acc_detector_presence_configuration_t presence_configuration;
|
|
|
|
|
|
|
|
bool success;
|
|
|
|
|
|
|
|
uint16_t sweeps_per_frame=16;
|
|
|
|
/* USER CODE END Includes */
|
|
|
|
/* USER CODE END Includes */
|
|
|
|
|
|
|
|
|
|
|
|
/* External variables ---------------------------------------------------------*/
|
|
|
|
/* External variables ---------------------------------------------------------*/
|
|
|
@ -198,8 +204,14 @@ extern uint8_t sts_lamp_bar_color;
|
|
|
|
|
|
|
|
|
|
|
|
static void set_default_configuration_common(acc_detector_presence_configuration_t presence_configuration)
|
|
|
|
static void set_default_configuration_common(acc_detector_presence_configuration_t presence_configuration)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
acc_detector_presence_configuration_update_rate_set(presence_configuration, sts_presence_rss_config.default_update_rate_presence);
|
|
|
|
//acc_detector_presence_configuration_update_rate_set(presence_configuration, sts_presence_rss_config.default_update_rate_presence);
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_update_rate_set(presence_configuration, 5);
|
|
|
|
acc_detector_presence_configuration_downsampling_factor_set(presence_configuration, sts_presence_rss_config.default_downsampling_factor);
|
|
|
|
acc_detector_presence_configuration_downsampling_factor_set(presence_configuration, sts_presence_rss_config.default_downsampling_factor);
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_hw_accelerated_average_samples_set(presence_configuration, DEFAULT_HWAAS);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t sweeps_per_frame=16;
|
|
|
|
|
|
|
|
sweeps_per_frame = acc_detector_presence_configuration_sweeps_per_frame_get(presence_configuration);
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_sweeps_per_frame_set(presence_configuration, sweeps_per_frame);
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_filter_parameters_t filter = acc_detector_presence_configuration_filter_parameters_get(presence_configuration);
|
|
|
|
acc_detector_presence_configuration_filter_parameters_t filter = acc_detector_presence_configuration_filter_parameters_get(presence_configuration);
|
|
|
|
filter.inter_frame_deviation_time_const = DEFAULT_INTER_FRAME_DEVIATION_TIME_CONST;
|
|
|
|
filter.inter_frame_deviation_time_const = DEFAULT_INTER_FRAME_DEVIATION_TIME_CONST;
|
|
|
@ -207,7 +219,7 @@ static void set_default_configuration_common(acc_detector_presence_configuration
|
|
|
|
// will be disabled if this value > 1/2 of update rate, default update rate 65, so must < 30
|
|
|
|
// will be disabled if this value > 1/2 of update rate, default update rate 65, so must < 30
|
|
|
|
filter.inter_frame_fast_cutoff = DEFAULT_INTER_FRAME_FAST_CUTOFF;
|
|
|
|
filter.inter_frame_fast_cutoff = DEFAULT_INTER_FRAME_FAST_CUTOFF;
|
|
|
|
filter.inter_frame_slow_cutoff = DEFAULT_INTER_FRAME_SLOW_CUTOFF;
|
|
|
|
filter.inter_frame_slow_cutoff = DEFAULT_INTER_FRAME_SLOW_CUTOFF;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// no effect if intra-frame-weight set to 0
|
|
|
|
// no effect if intra-frame-weight set to 0
|
|
|
|
filter.intra_frame_time_const = DEFAULT_INTRA_FRAME_TIME_CONST;
|
|
|
|
filter.intra_frame_time_const = DEFAULT_INTRA_FRAME_TIME_CONST;
|
|
|
|
// for slow movement, people sit still, rest in sofa, seat, closestool, etc.
|
|
|
|
// for slow movement, people sit still, rest in sofa, seat, closestool, etc.
|
|
|
@ -216,8 +228,14 @@ static void set_default_configuration_common(acc_detector_presence_configuration
|
|
|
|
|
|
|
|
|
|
|
|
// if detection toggles too often, increase the following, if too sluggish, decrease it instead
|
|
|
|
// if detection toggles too often, increase the following, if too sluggish, decrease it instead
|
|
|
|
filter.output_time_const = DEFAULT_OUTPUT_TIME_CONST; //0.0f;
|
|
|
|
filter.output_time_const = DEFAULT_OUTPUT_TIME_CONST; //0.0f;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_filter_parameters_set(presence_configuration, &filter);
|
|
|
|
acc_detector_presence_configuration_filter_parameters_set(presence_configuration, &filter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
acc_detector_presence_configuration_nbr_removed_pc_set(presence_configuration, DEFAULT_NBR_REMOVED_PC);
|
|
|
|
acc_detector_presence_configuration_nbr_removed_pc_set(presence_configuration, DEFAULT_NBR_REMOVED_PC);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_power_save_mode_set(presence_configuration, ACC_POWER_SAVE_MODE_ACTIVE);
|
|
|
|
acc_detector_presence_configuration_power_save_mode_set(presence_configuration, ACC_POWER_SAVE_MODE_ACTIVE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -230,13 +248,14 @@ static void set_default_configuration(acc_detector_presence_configuration_t pres
|
|
|
|
acc_detector_presence_configuration_detection_threshold_set(presence_configuration, DEFAULT_THRESHOLD);
|
|
|
|
acc_detector_presence_configuration_detection_threshold_set(presence_configuration, DEFAULT_THRESHOLD);
|
|
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
//acc_service_sparse_configuration_sweeps_per_frame_set(sparse_configuration, sweeps_per_frame);
|
|
|
|
//acc_service_sparse_configuration_sweeps_per_frame_set(sparse_configuration, sweeps_per_frame);
|
|
|
|
|
|
|
|
//acc_service_sparse_configuration_sweeps_per_frame_set(sparse_configuration, DEFAULT_SWEEPS_PER_FRAME);
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_start_set(presence_configuration, DEFAULT_START_M);
|
|
|
|
acc_detector_presence_configuration_start_set(presence_configuration, DEFAULT_START_M);
|
|
|
|
acc_detector_presence_configuration_length_set(presence_configuration, DEFAULT_LENGTH_M);
|
|
|
|
acc_detector_presence_configuration_length_set(presence_configuration, DEFAULT_LENGTH_M);
|
|
|
|
acc_detector_presence_configuration_downsampling_factor_set(presence_configuration, DEFAULT_DOWNSAMPLING_FACTOR);
|
|
|
|
acc_detector_presence_configuration_downsampling_factor_set(presence_configuration, DEFAULT_DOWNSAMPLING_FACTOR);
|
|
|
|
acc_detector_presence_configuration_receiver_gain_set(presence_configuration, DEFAULT_RECEIVER_GAIN);
|
|
|
|
acc_detector_presence_configuration_receiver_gain_set(presence_configuration, DEFAULT_RECEIVER_GAIN);
|
|
|
|
|
|
|
|
|
|
|
|
set_default_configuration_common(presence_configuration);
|
|
|
|
//set_default_configuration_common(presence_configuration);
|
|
|
|
|
|
|
|
|
|
|
|
// by set_default_configuration_common
|
|
|
|
// by set_default_configuration_common
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
@ -276,6 +295,8 @@ static void set_default_fall_rise_configuration(acc_detector_presence_configurat
|
|
|
|
|
|
|
|
|
|
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
//acc_service_sparse_configuration_sweeps_per_frame_set(sparse_configuration, sweeps_per_frame);
|
|
|
|
//acc_service_sparse_configuration_sweeps_per_frame_set(sparse_configuration, sweeps_per_frame);
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_sweeps_per_frame_set(presence_configuration, DEFAULT_SWEEPS_PER_FRAME);
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_start_set(presence_configuration, DEFAULT_START_M);
|
|
|
|
acc_detector_presence_configuration_start_set(presence_configuration, DEFAULT_START_M);
|
|
|
|
acc_detector_presence_configuration_length_set(presence_configuration, DEFAULT_LENGTH_M);
|
|
|
|
acc_detector_presence_configuration_length_set(presence_configuration, DEFAULT_LENGTH_M);
|
|
|
|
acc_detector_presence_configuration_downsampling_factor_set(presence_configuration, DEFAULT_DOWNSAMPLING_FACTOR);
|
|
|
|
acc_detector_presence_configuration_downsampling_factor_set(presence_configuration, DEFAULT_DOWNSAMPLING_FACTOR);
|
|
|
@ -315,6 +336,8 @@ static void sts_rss_set_current_configuration_full(acc_detector_presence_configu
|
|
|
|
acc_detector_presence_configuration_update_rate_set(presence_configuration, sts_presence_rss_config.default_update_rate_presence); //DEFAULT_UPDATE_RATE_2);
|
|
|
|
acc_detector_presence_configuration_update_rate_set(presence_configuration, sts_presence_rss_config.default_update_rate_presence); //DEFAULT_UPDATE_RATE_2);
|
|
|
|
acc_detector_presence_configuration_detection_threshold_set(presence_configuration, sts_presence_rss_config.default_threshold);//DEFAULT_DETECTION_THRESHOLD_2);
|
|
|
|
acc_detector_presence_configuration_detection_threshold_set(presence_configuration, sts_presence_rss_config.default_threshold);//DEFAULT_DETECTION_THRESHOLD_2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_sweeps_per_frame_set(presence_configuration, DEFAULT_SWEEPS_PER_FRAME);
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_start_set(presence_configuration, sts_presence_rss_config.default_start_m);
|
|
|
|
acc_detector_presence_configuration_start_set(presence_configuration, sts_presence_rss_config.default_start_m);
|
|
|
|
acc_detector_presence_configuration_length_set(presence_configuration, sts_presence_rss_config.default_length_m); //DEFAULT_LENGTH_M_2);
|
|
|
|
acc_detector_presence_configuration_length_set(presence_configuration, sts_presence_rss_config.default_length_m); //DEFAULT_LENGTH_M_2);
|
|
|
|
|
|
|
|
|
|
|
@ -349,6 +372,8 @@ static void sts_rss_set_configuration_background_evalution(acc_detector_presence
|
|
|
|
acc_detector_presence_configuration_sensor_set(presence_configuration, DEFAULT_SENSOR_ID);
|
|
|
|
acc_detector_presence_configuration_sensor_set(presence_configuration, DEFAULT_SENSOR_ID);
|
|
|
|
acc_detector_presence_configuration_service_profile_set(presence_configuration, sts_presence_rss_config.default_profile);
|
|
|
|
acc_detector_presence_configuration_service_profile_set(presence_configuration, sts_presence_rss_config.default_profile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_sweeps_per_frame_set(presence_configuration, DEFAULT_SWEEPS_PER_FRAME);
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_start_set(presence_configuration, ((float)sts_sensor_install_height/2000.0));
|
|
|
|
acc_detector_presence_configuration_start_set(presence_configuration, ((float)sts_sensor_install_height/2000.0));
|
|
|
|
acc_detector_presence_configuration_length_set(presence_configuration, ((float)(sts_sensor_install_height)/1000.0));
|
|
|
|
acc_detector_presence_configuration_length_set(presence_configuration, ((float)(sts_sensor_install_height)/1000.0));
|
|
|
|
acc_detector_presence_configuration_detection_threshold_set(presence_configuration, (float)300.0/1000.0);
|
|
|
|
acc_detector_presence_configuration_detection_threshold_set(presence_configuration, (float)300.0/1000.0);
|
|
|
@ -360,7 +385,7 @@ static void sts_rss_set_configuration_background_evalution(acc_detector_presence
|
|
|
|
|
|
|
|
|
|
|
|
static void sts_rss_set_current_configuration_simple(acc_detector_presence_configuration_t presence_configuration)
|
|
|
|
static void sts_rss_set_current_configuration_simple(acc_detector_presence_configuration_t presence_configuration)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\nsts_rss_cfg-start: %4d ,length: %4d ,threshold: %4d ,gain: %2d ,rate: %2d ,profile: %1d \r\n",
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\nsts_rss_cfg-start: %4d ,length: %4d ,threshold: %4d ,gain: %2d ,rate: %2d ,profile: %1d \r\n",
|
|
|
|
(int)(sts_presence_rss_config.default_start_m*1000),
|
|
|
|
(int)(sts_presence_rss_config.default_start_m*1000),
|
|
|
|
(int)(sts_presence_rss_config.default_length_m*1000),
|
|
|
|
(int)(sts_presence_rss_config.default_length_m*1000),
|
|
|
|
(int)(sts_presence_rss_config.default_threshold*1000),
|
|
|
|
(int)(sts_presence_rss_config.default_threshold*1000),
|
|
|
@ -371,22 +396,48 @@ static void sts_rss_set_current_configuration_simple(acc_detector_presence_confi
|
|
|
|
acc_detector_presence_configuration_sensor_set(presence_configuration, DEFAULT_SENSOR_ID);
|
|
|
|
acc_detector_presence_configuration_sensor_set(presence_configuration, DEFAULT_SENSOR_ID);
|
|
|
|
acc_detector_presence_configuration_service_profile_set(presence_configuration, sts_presence_rss_config.default_profile);
|
|
|
|
acc_detector_presence_configuration_service_profile_set(presence_configuration, sts_presence_rss_config.default_profile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sweeps_per_frame = acc_detector_presence_configuration_sweeps_per_frame_get(presence_configuration);
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_sweeps_per_frame_set(presence_configuration, sweeps_per_frame);
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_downsampling_factor_set(presence_configuration, sts_presence_rss_config.default_downsampling_factor);
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_hw_accelerated_average_samples_set(presence_configuration, DEFAULT_HWAAS);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_update_rate_set(presence_configuration, 5);
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_detection_threshold_set(presence_configuration, sts_presence_rss_config.default_threshold);//DEFAULT_DETECTION_THRESHOLD_2);
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_start_set(presence_configuration, sts_presence_rss_config.default_start_m);
|
|
|
|
acc_detector_presence_configuration_start_set(presence_configuration, sts_presence_rss_config.default_start_m);
|
|
|
|
acc_detector_presence_configuration_length_set(presence_configuration, sts_presence_rss_config.default_length_m); //DEFAULT_LENGTH_M_2);
|
|
|
|
acc_detector_presence_configuration_length_set(presence_configuration, sts_presence_rss_config.default_length_m); //DEFAULT_LENGTH_M_2);
|
|
|
|
acc_detector_presence_configuration_detection_threshold_set(presence_configuration, sts_presence_rss_config.default_threshold);//DEFAULT_DETECTION_THRESHOLD_2);
|
|
|
|
acc_detector_presence_configuration_power_save_mode_set(presence_configuration, DEFAULT_POWER_SAVE_MODE);
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_receiver_gain_set(presence_configuration, sts_presence_rss_config.default_receiver_gain);
|
|
|
|
acc_detector_presence_configuration_receiver_gain_set(presence_configuration, sts_presence_rss_config.default_receiver_gain);
|
|
|
|
|
|
|
|
|
|
|
|
set_default_configuration_common(presence_configuration);
|
|
|
|
acc_detector_presence_configuration_filter_parameters_t filter = acc_detector_presence_configuration_filter_parameters_get(presence_configuration);
|
|
|
|
|
|
|
|
filter.inter_frame_deviation_time_const = DEFAULT_INTER_FRAME_DEVIATION_TIME_CONST;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// will be disabled if this value > 1/2 of update rate, default update rate 65, so must < 30
|
|
|
|
|
|
|
|
filter.inter_frame_fast_cutoff = DEFAULT_INTER_FRAME_FAST_CUTOFF;
|
|
|
|
|
|
|
|
filter.inter_frame_slow_cutoff = DEFAULT_INTER_FRAME_SLOW_CUTOFF;
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_filter_parameters_set(presence_configuration,&filter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set_default_configuration_common(presence_configuration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void print_current_configuration(acc_detector_presence_configuration_t presence_configuration)
|
|
|
|
static void print_current_configuration(acc_detector_presence_configuration_t presence_configuration)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
static uint32_t print_cnt=0;
|
|
|
|
|
|
|
|
if (print_cnt++%200 != 0) return;
|
|
|
|
float sts_run_start = acc_detector_presence_configuration_start_get(presence_configuration);
|
|
|
|
float sts_run_start = acc_detector_presence_configuration_start_get(presence_configuration);
|
|
|
|
float sts_run_length = acc_detector_presence_configuration_length_get(presence_configuration);
|
|
|
|
float sts_run_length = acc_detector_presence_configuration_length_get(presence_configuration);
|
|
|
|
float sts_run_threshold = acc_detector_presence_configuration_detection_threshold_get(presence_configuration);
|
|
|
|
float sts_run_threshold = acc_detector_presence_configuration_detection_threshold_get(presence_configuration);
|
|
|
|
float sts_run_gain = acc_detector_presence_configuration_receiver_gain_get(presence_configuration);
|
|
|
|
float sts_run_gain = acc_detector_presence_configuration_receiver_gain_get(presence_configuration);
|
|
|
|
float sts_run_update_rate = acc_detector_presence_configuration_update_rate_get(presence_configuration);
|
|
|
|
float sts_run_update_rate = acc_detector_presence_configuration_update_rate_get(presence_configuration);
|
|
|
|
float sts_run_profile = acc_detector_presence_configuration_service_profile_get(presence_configuration);
|
|
|
|
float sts_run_profile = acc_detector_presence_configuration_service_profile_get(presence_configuration);
|
|
|
|
|
|
|
|
float sts_run_sweeps_rate = acc_detector_presence_configuration_sweeps_per_frame_get(presence_configuration);
|
|
|
|
|
|
|
|
float sts_run_downsampling = acc_detector_presence_configuration_downsampling_factor_get(presence_configuration);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\nWork_mode:%2d Start: %4d (mm) Length: %4d (mm) Threshold: %4d (*) Gain= %2d (%) UpdateRate=%4d Profile= %d Sweeps Rate=%d Downsampling=%d\r\n",
|
|
|
|
|
|
|
|
sts_work_mode, (int)(1000.0*sts_run_start), (int)(1000.0*sts_run_length), (int)(1000.0*sts_run_threshold),
|
|
|
|
|
|
|
|
(int)(100.0*sts_run_gain),(int)sts_run_update_rate, (int)sts_run_profile, (int)sts_run_sweeps_rate, (int)sts_run_downsampling);
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_filter_parameters_t sts_run_filter = acc_detector_presence_configuration_filter_parameters_get(presence_configuration);
|
|
|
|
acc_detector_presence_configuration_filter_parameters_t sts_run_filter = acc_detector_presence_configuration_filter_parameters_get(presence_configuration);
|
|
|
|
|
|
|
|
|
|
|
@ -398,31 +449,119 @@ static void print_current_configuration(acc_detector_presence_configuration_t pr
|
|
|
|
float sts_run_f_intra_frame_weight = sts_run_filter.intra_frame_weight;
|
|
|
|
float sts_run_f_intra_frame_weight = sts_run_filter.intra_frame_weight;
|
|
|
|
float sts_run_f_output_time_const = sts_run_filter.output_time_const;
|
|
|
|
float sts_run_f_output_time_const = sts_run_filter.output_time_const;
|
|
|
|
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\nWork_mode:%2d Start: %4d (mm) Length: %4d (mm) Threshold: %4d (*) Gain= %2d (%) UpdateRate=%4d Profile= %d \r\n",
|
|
|
|
|
|
|
|
sts_work_mode, (int)(1000.0*sts_run_start), (int)(1000.0*sts_run_length), (int)(1000.0*sts_run_threshold),
|
|
|
|
|
|
|
|
(int)(100.0*sts_run_gain),(int)sts_run_update_rate, (int)sts_run_profile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H, "\rn\n(1)FastCut:%4u (2)SlowCut:%4u (3)InterFrameDevTime:%4u "
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n(1)FastCut:%4u (2)SlowCut:%4u (3)InterFrameDevTime:%4u "
|
|
|
|
"(4)IntraFrameTimeConst:%4d (5)IntraWeight:%4u (5)OutputTime:%4u \r\n",
|
|
|
|
"(4)IntraFrameTimeConst:%4d (5)IntraWeight:%4u (5)OutputTime:%4u \r\n",
|
|
|
|
(int)(1000.0*sts_run_f_inter_fast_cutoff), (int)(1000*sts_run_f_inter_slow_cutoff), (int)(1000*sts_run_f_inter_frame_dev_time_const),
|
|
|
|
(int)(1000.0*sts_run_f_inter_fast_cutoff), (int)(1000*sts_run_f_inter_slow_cutoff), (int)(1000*sts_run_f_inter_frame_dev_time_const),
|
|
|
|
(int)(1000*sts_run_f_intra_frame_time_const),(int)(1000*sts_run_f_intra_frame_weight),(int)(1000*sts_run_f_output_time_const));
|
|
|
|
(int)(1000*sts_run_f_intra_frame_time_const),(int)(1000*sts_run_f_intra_frame_weight),(int)(1000*sts_run_f_output_time_const));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static uint8_t yes_count =0;
|
|
|
|
|
|
|
|
static uint8_t no_count = 0;
|
|
|
|
|
|
|
|
#define TIME_C 4
|
|
|
|
|
|
|
|
|
|
|
|
static void print_result(acc_detector_presence_result_t result)
|
|
|
|
static void print_result(acc_detector_presence_result_t result)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// 2025-04 27 update according to BYD V1.4 2021-02-21
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (result.presence_detected)
|
|
|
|
if (result.presence_detected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint32_t detected_zone = (uint32_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH);
|
|
|
|
uint32_t detected_zone = (uint32_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH);
|
|
|
|
// 2024-08-05
|
|
|
|
// 2024-08-05
|
|
|
|
//uint32_t detected_zone = (uint32_t)((float)(result.presence_distance) / (float)DEFAULT_ZONE_LENGTH);
|
|
|
|
//uint32_t detected_zone = (uint32_t)((float)(result.presence_distance) / (float)DEFAULT_ZONE_LENGTH);
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"Motion in zone: %u, distance: %d, score: %d\n", (unsigned int)detected_zone,
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"Motion in zone: %u, distance: %d, score: %d\n", (unsigned int)detected_zone,
|
|
|
|
(int)(result.presence_distance * 1000.0f),
|
|
|
|
(int)(result.presence_distance * 1000.0f),
|
|
|
|
(int)(result.presence_score * 1000.0f));
|
|
|
|
(int)(result.presence_score * 1000.0f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"No motion, score: %u\n", (int)(result.presence_score * 1000.0f));
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"No motion, score: %u\n", (int)(result.presence_score * 1000.0f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// 2025-04 27 update according to BYD V1.4 2021-02-21
|
|
|
|
|
|
|
|
uint16_t signal = 0;
|
|
|
|
|
|
|
|
uint16_t dist = 0;
|
|
|
|
|
|
|
|
uint8_t i = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
signal = (int)(result.presence_score * 1000.0f);
|
|
|
|
|
|
|
|
dist = (int)(result.presence_distance * 1000.0f);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t flag=0;
|
|
|
|
|
|
|
|
if (signal> sts_rss_threshold)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(dist<500)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(signal>(sts_rss_threshold+1000))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LED1_ON;
|
|
|
|
|
|
|
|
if(yes_count<TIME_C)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
yes_count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
no_count=0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LED1_ON;
|
|
|
|
|
|
|
|
if(no_count<TIME_C)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
no_count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
yes_count=0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LED1_ON;
|
|
|
|
|
|
|
|
if(yes_count<TIME_C)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
yes_count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
no_count=0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LED1_OFF;
|
|
|
|
|
|
|
|
if(no_count<TIME_C)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
no_count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
yes_count=0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//printf("No motion");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// printf("Wait.....");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
if(yes_count>(TIME_C-1))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//Out1_ON
|
|
|
|
|
|
|
|
//Out2_OFF
|
|
|
|
|
|
|
|
//printf("Motion (%5d), Distance: %4dmm\r\n", signal,dist);
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\nMotion (%5d), Distance: %4dmm", signal, dist);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(no_count>(TIME_C-1))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//Out1_OFF
|
|
|
|
|
|
|
|
//Out2_ON
|
|
|
|
|
|
|
|
// printf("No motion(%5d), Distance: %4dmm\r\n", signal,dist);
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\nNo motion(%5d), Distance: %4dmm", signal, dist);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -484,7 +623,8 @@ int sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance,
|
|
|
|
float average_distance =0.0f;
|
|
|
|
float average_distance =0.0f;
|
|
|
|
float average_score =0.0f;
|
|
|
|
float average_score =0.0f;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < (iterations); i++)
|
|
|
|
//for (int i = 0; i < (iterations); i++)
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
success = acc_detector_presence_get_next(handle, &result);
|
|
|
|
success = acc_detector_presence_get_next(handle, &result);
|
|
|
|
if (!success)
|
|
|
|
if (!success)
|
|
|
@ -493,7 +633,7 @@ int sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance,
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//print_result(result);
|
|
|
|
print_result(result);
|
|
|
|
if (!result.data_saturated)
|
|
|
|
if (!result.data_saturated)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (result.presence_detected)
|
|
|
|
if (result.presence_detected)
|
|
|
@ -506,7 +646,7 @@ int sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
acc_integration_sleep_ms(60); //--- around 1000ms in total
|
|
|
|
acc_integration_sleep_ms(200); //--- around 1000ms in total
|
|
|
|
if (motioncount%10 ==0)
|
|
|
|
if (motioncount%10 ==0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
@ -531,22 +671,114 @@ int sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance,
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
int sts_presence_rss_fall_rise_detection_loop(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
success = acc_detector_presence_get_next(handle, &result);
|
|
|
|
|
|
|
|
if (!success)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"acc_detector_presence_get_next() failed\n");
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
print_result(result);
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int sts_presence_rss_fall_rise_detection_end(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool deactivated = acc_detector_presence_deactivate(handle);
|
|
|
|
|
|
|
|
acc_detector_presence_destroy(&handle);
|
|
|
|
|
|
|
|
acc_rss_deactivate();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (deactivated && success)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"Application finished OK\n");
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int sts_presence_rss_fall_rise_detection_start(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const acc_hal_t *hal = acc_hal_integration_get_implementation();
|
|
|
|
const acc_hal_t *hal = acc_hal_integration_get_implementation();
|
|
|
|
|
|
|
|
|
|
|
|
if (!acc_rss_activate(hal))
|
|
|
|
if (!acc_rss_activate(hal))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"Failed to activate RSS\n");
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"Failed to activate RSS\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
acc_rss_override_sensor_id_check_at_creation(true);
|
|
|
|
acc_rss_override_sensor_id_check_at_creation(true);
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_t presence_configuration = acc_detector_presence_configuration_create();
|
|
|
|
//acc_detector_presence_configuration_t presence_configuration = acc_detector_presence_configuration_create();
|
|
|
|
|
|
|
|
presence_configuration = acc_detector_presence_configuration_create();
|
|
|
|
if (presence_configuration == NULL)
|
|
|
|
if (presence_configuration == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"Failed to create configuration\n");
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"Failed to create configuration\n");
|
|
|
|
|
|
|
|
acc_rss_deactivate();
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// sts_rss_set_current_configuration_simple(presence_configuration);
|
|
|
|
|
|
|
|
set_default_configuration(presence_configuration);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"\r\n##### YUNHORN STS *** Simple *** cfg applied\n");
|
|
|
|
|
|
|
|
print_current_configuration(presence_configuration);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sts_rss_threshold = sts_presence_rss_config.default_threshold*1000.0F;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//print_current_configuration(presence_configuration);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// acc_detector_presence_handle_t handle = acc_detector_presence_create(presence_configuration);
|
|
|
|
|
|
|
|
handle = acc_detector_presence_create(presence_configuration);
|
|
|
|
|
|
|
|
if (handle == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"Failed to create detector\n");
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_destroy(&presence_configuration);
|
|
|
|
|
|
|
|
//acc_detector_presence_destroy(&handle);
|
|
|
|
|
|
|
|
acc_rss_deactivate();
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sts_rss_threshold = sts_presence_rss_config.default_threshold*1000.0F;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"\r\n============= Start Scan\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!acc_detector_presence_activate(handle))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M, "Failed to activate detector \n");
|
|
|
|
|
|
|
|
acc_detector_presence_destroy(&handle);
|
|
|
|
|
|
|
|
acc_rss_deactivate();
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int sts_presence_rss_fall_rise_detection_startx(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const acc_hal_t *hal = acc_hal_integration_get_implementation();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!acc_rss_activate(hal))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"Failed to activate RSS\n");
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
acc_rss_override_sensor_id_check_at_creation(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//acc_detector_presence_configuration_t presence_configuration = acc_detector_presence_configuration_create();
|
|
|
|
|
|
|
|
presence_configuration = acc_detector_presence_configuration_create();
|
|
|
|
|
|
|
|
if (presence_configuration == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"Failed to create configuration\n");
|
|
|
|
acc_rss_deactivate();
|
|
|
|
acc_rss_deactivate();
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -554,7 +786,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
|
|
|
|
|
|
|
|
if ((sts_rss_config_updated_flag != STS_RSS_CONFIG_NON) || (sts_rss_init_ok != 1))
|
|
|
|
if ((sts_rss_config_updated_flag != STS_RSS_CONFIG_NON) || (sts_rss_init_ok != 1))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\n ------ ---------- rss cfg update flag=%02x \r\n", sts_rss_config_updated_flag);
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ------ ---------- rss cfg update flag=%02x \r\n", sts_rss_config_updated_flag);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sts_rss_init_ok==0)
|
|
|
|
if (sts_rss_init_ok==0)
|
|
|
@ -574,7 +806,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
sts_rss_init_ok = 1;
|
|
|
|
sts_rss_init_ok = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\n Update flag=%02x, workmode=%2d \r\n", sts_rss_config_updated_flag, sts_work_mode);
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Update flag=%02x, workmode=%2d \r\n", sts_rss_config_updated_flag, sts_work_mode);
|
|
|
|
switch (sts_rss_config_updated_flag)
|
|
|
|
switch (sts_rss_config_updated_flag)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
@ -585,19 +817,20 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
case STS_RSS_CONFIG_DEFAULT:
|
|
|
|
case STS_RSS_CONFIG_DEFAULT:
|
|
|
|
set_default_configuration(presence_configuration);
|
|
|
|
set_default_configuration(presence_configuration);
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"\r\n##### YUNHORN STS *** Default *** cfg applied\n");
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"\r\n##### YUNHORN STS *** Default *** cfg applied\n");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case STS_RSS_CONFIG_SIMPLE:
|
|
|
|
case STS_RSS_CONFIG_SIMPLE:
|
|
|
|
sts_rss_set_current_configuration_simple(presence_configuration);
|
|
|
|
sts_rss_set_current_configuration_simple(presence_configuration);
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"\r\n##### YUNHORN STS *** Simple *** cfg applied\n");
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"\r\n##### YUNHORN STS *** Simple *** cfg applied\n");
|
|
|
|
|
|
|
|
print_current_configuration(presence_configuration);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case STS_RSS_CONFIG_FULL:
|
|
|
|
case STS_RSS_CONFIG_FULL:
|
|
|
|
sts_rss_set_current_configuration_full(presence_configuration);
|
|
|
|
sts_rss_set_current_configuration_full(presence_configuration);
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"\r\n######### YUNHORN STS *** FULL *** cfg applied\n");
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"\r\n######### YUNHORN STS *** FULL *** cfg applied\n");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case STS_RSS_CONFIG_FALL_DETECTION:
|
|
|
|
case STS_RSS_CONFIG_FALL_DETECTION:
|
|
|
|
set_default_fall_rise_configuration(presence_configuration);
|
|
|
|
set_default_fall_rise_configuration(presence_configuration);
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"\r\n######### YUNHORN STS *** FALL DETECTION *** cfg applied\n");
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"\r\n######### YUNHORN STS *** FALL DETECTION *** cfg applied\n");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -605,35 +838,45 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
|
|
|
|
|
|
|
|
// sts_rss_config_updated_flag = STS_RSS_CONFIG_NON; //update finished, set to 0
|
|
|
|
// sts_rss_config_updated_flag = STS_RSS_CONFIG_NON; //update finished, set to 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sts_rss_threshold = sts_presence_rss_config.default_threshold*1000.0F;
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_handle_t handle = acc_detector_presence_create(presence_configuration);
|
|
|
|
//print_current_configuration(presence_configuration);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// acc_detector_presence_handle_t handle = acc_detector_presence_create(presence_configuration);
|
|
|
|
|
|
|
|
handle = acc_detector_presence_create(presence_configuration);
|
|
|
|
if (handle == NULL)
|
|
|
|
if (handle == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"Failed to create detector\n");
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"Failed to create detector\n");
|
|
|
|
acc_detector_presence_configuration_destroy(&presence_configuration);
|
|
|
|
acc_detector_presence_configuration_destroy(&presence_configuration);
|
|
|
|
acc_detector_presence_destroy(&handle);
|
|
|
|
//acc_detector_presence_destroy(&handle);
|
|
|
|
acc_rss_deactivate();
|
|
|
|
acc_rss_deactivate();
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sts_rss_threshold = sts_presence_rss_config.default_threshold*1000.0F;
|
|
|
|
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"\r\n============= Start Scan\n");
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M,"\r\n============= Start Scan\n");
|
|
|
|
|
|
|
|
|
|
|
|
print_current_configuration(presence_configuration);
|
|
|
|
//print_current_configuration(presence_configuration);
|
|
|
|
|
|
|
|
|
|
|
|
acc_detector_presence_configuration_destroy(&presence_configuration);
|
|
|
|
//acc_detector_presence_configuration_destroy(&presence_configuration);
|
|
|
|
|
|
|
|
|
|
|
|
// BEFORE MERGE FIRST AND SECOND HALF FALL RISE DETECTION
|
|
|
|
// BEFORE MERGE FIRST AND SECOND HALF FALL RISE DETECTION
|
|
|
|
|
|
|
|
|
|
|
|
if (!acc_detector_presence_activate(handle))
|
|
|
|
if (!acc_detector_presence_activate(handle))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H, "Failed to activate detector \n");
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M, "Failed to activate detector \n");
|
|
|
|
|
|
|
|
acc_detector_presence_destroy(&handle);
|
|
|
|
|
|
|
|
acc_rss_deactivate();
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
bool deactivated = false;
|
|
|
|
bool deactivated = false;
|
|
|
|
bool success = true;
|
|
|
|
bool success = true;
|
|
|
|
const int iterations = (DEFAULT_UPDATE_RATE_PRESENCE);
|
|
|
|
const int iterations = 1; //(DEFAULT_UPDATE_RATE_PRESENCE);
|
|
|
|
acc_detector_presence_result_t result;
|
|
|
|
//acc_detector_presence_result_t result;
|
|
|
|
uint8_t average_result = 0;
|
|
|
|
uint8_t average_result = 0;
|
|
|
|
float average_distance =0.0f;
|
|
|
|
float average_distance =0.0f;
|
|
|
|
float average_score =0.0f;
|
|
|
|
float average_score =0.0f;
|
|
|
@ -655,6 +898,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (int i = 0; i < (iterations); i++)
|
|
|
|
for (int i = 0; i < (iterations); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
success = acc_detector_presence_get_next(handle, &result);
|
|
|
|
success = acc_detector_presence_get_next(handle, &result);
|
|
|
|
if (!success)
|
|
|
|
if (!success)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -663,10 +907,10 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//print_result(result);
|
|
|
|
//print_result(result);
|
|
|
|
if (!result.data_saturated)
|
|
|
|
//if (!result.data_saturated)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//APP_LOG(TS_OFF, VLEVEL_H,"\n%u ", i);
|
|
|
|
//APP_LOG(TS_OFF, VLEVEL_H,"\n%u ", i);
|
|
|
|
//print_result(result);
|
|
|
|
print_result(result);
|
|
|
|
if (result.presence_detected)
|
|
|
|
if (result.presence_detected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//print_result(result);
|
|
|
|
//print_result(result);
|
|
|
@ -697,15 +941,15 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
|
|
|
|
|
|
|
|
//acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // 15ms, DEFAULT_UPDATE_RATE);
|
|
|
|
//acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // 15ms, DEFAULT_UPDATE_RATE);
|
|
|
|
//acc_integration_sleep_ms(10); // --- around 1500 ms in total
|
|
|
|
//acc_integration_sleep_ms(10); // --- around 1500 ms in total
|
|
|
|
acc_integration_sleep_ms(2); //--- around 1000ms in total
|
|
|
|
//acc_integration_sleep_ms(2); //--- around 1000ms in total
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
deactivated = acc_detector_presence_deactivate(handle);
|
|
|
|
deactivated = acc_detector_presence_deactivate(handle);
|
|
|
|
acc_detector_presence_destroy(&handle);
|
|
|
|
acc_detector_presence_destroy(&handle);
|
|
|
|
acc_rss_deactivate();
|
|
|
|
acc_rss_deactivate();
|
|
|
|
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\n First Half --- Motion Count = %u \r\n", motion_count);
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\n First Half --- Motion Count = %u \r\n", motion_count);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
//acc_detector_presence_deactivate(handle);
|
|
|
|
//acc_detector_presence_deactivate(handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((sts_work_mode == STS_UNI_MODE))
|
|
|
|
else if ((sts_work_mode == STS_UNI_MODE))
|
|
|
@ -739,7 +983,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
acc_detector_presence_configuration_destroy(&presence_configuration);
|
|
|
|
acc_detector_presence_configuration_destroy(&presence_configuration);
|
|
|
|
|
|
|
|
|
|
|
|
// set to full length of iteration
|
|
|
|
// set to full length of iteration
|
|
|
|
for (int i = 0; i < (iterations); i++)
|
|
|
|
for (int i = 0; i <= (iterations); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
success = acc_detector_presence_get_next(handle, &result);
|
|
|
|
success = acc_detector_presence_get_next(handle, &result);
|
|
|
|
if (!success)
|
|
|
|
if (!success)
|
|
|
@ -787,13 +1031,14 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
//acc_integration_sleep_ms(10); //--- around 1500 ms in total
|
|
|
|
//acc_integration_sleep_ms(10); //--- around 1500 ms in total
|
|
|
|
acc_integration_sleep_ms(2); //--- around 1000ms in total
|
|
|
|
acc_integration_sleep_ms(2); //--- around 1000ms in total
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
deactivated = acc_detector_presence_deactivate(handle);
|
|
|
|
deactivated = acc_detector_presence_deactivate(handle);
|
|
|
|
acc_detector_presence_destroy(&handle);
|
|
|
|
acc_detector_presence_destroy(&handle);
|
|
|
|
acc_rss_deactivate();
|
|
|
|
acc_rss_deactivate();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\n Second Half --- Motion Count Sum to = %u \r\n", motion_count);
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\n Second Half --- Motion Count Sum to = %u \r\n", motion_count);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
//APP_LOG(TS_OFF, VLEVEL_L,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
|
|
|
|
//APP_LOG(TS_OFF, VLEVEL_L,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
|
|
|
|
|
|
|
|
|
|
|
|
motion_count = motion_count%DEFAULT_MOTION_DATASET_LEN; // get all required number of motion data
|
|
|
|
motion_count = motion_count%DEFAULT_MOTION_DATASET_LEN; // get all required number of motion data
|
|
|
@ -807,14 +1052,13 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
average_distance = (float)(1000.0f*average_distance)/(float)average_result; // in meters
|
|
|
|
average_distance = (float)(1000.0f*average_distance)/(float)average_result; // in meters
|
|
|
|
average_score = (float)(1000.0f*average_score)/(float)average_result;
|
|
|
|
average_score = (float)(1000.0f*average_score)/(float)average_result;
|
|
|
|
|
|
|
|
|
|
|
|
sts_presence_rss_distance = average_distance;
|
|
|
|
sts_presence_rss_distance = average_distance;
|
|
|
|
sts_presence_rss_score = average_score;
|
|
|
|
sts_presence_rss_score = average_score;
|
|
|
|
|
|
|
|
|
|
|
|
STS_Yunhorn_DistanceStandardDeviation();
|
|
|
|
//STS_Yunhorn_DistanceStandardDeviation();
|
|
|
|
|
|
|
|
|
|
|
|
// APP_LOG(TS_OFF, VLEVEL_H, "\r\nAverage Distance: %d (mm) Score: %d Singularity: %d \r\n",(int)average_distance, (int)average_score, sts_presence_singularity);
|
|
|
|
// APP_LOG(TS_OFF, VLEVEL_H, "\r\nAverage Distance: %d (mm) Score: %d Singularity: %d \r\n",(int)average_distance, (int)average_score, sts_presence_singularity);
|
|
|
|
// uint8_t pre_sts_rss_result = (average_result > (DEFAULT_UPDATE_RATE_PRESENCE/5))? 1: 0;
|
|
|
|
// uint8_t pre_sts_rss_result = (average_result > (DEFAULT_UPDATE_RATE_PRESENCE/5))? 1: 0;
|
|
|
@ -830,10 +1074,10 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
uint8_t pre_sts_rss_result=0;
|
|
|
|
uint8_t pre_sts_rss_result=0;
|
|
|
|
|
|
|
|
|
|
|
|
if (sts_work_mode == STS_UNI_MODE) {
|
|
|
|
if (sts_work_mode == STS_UNI_MODE) {
|
|
|
|
pre_sts_rss_result = (average_result > 0)? 1: 0;
|
|
|
|
pre_sts_rss_result = (average_result > (uint8_t)(0.7*iterations))? 1: 0;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
pre_sts_rss_result = ((average_result > 0)&&(sts_presence_singularity ==0))? 1: 0;
|
|
|
|
pre_sts_rss_result = ((average_result > (uint8_t)(0.7*iterations))&&(sts_presence_singularity ==0))? 1: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Write_RingBuff(pre_sts_rss_result);
|
|
|
|
//Write_RingBuff(pre_sts_rss_result);
|
|
|
@ -847,7 +1091,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
// APP_LOG(TS_OFF, VLEVEL_M, "\r\nMotionCount=%4d Overall Motion=%d \r\n", (int)motion_count, (int)sts_rss_result);
|
|
|
|
// APP_LOG(TS_OFF, VLEVEL_M, "\r\nMotionCount=%4d Overall Motion=%d \r\n", (int)motion_count, (int)sts_rss_result);
|
|
|
|
//APP_LOG(TS_OFF, VLEVEL_M, "\r\nAverage Result=%d Distance=%d, Score=%d MotionCount=%d ---Overall Result=%d \r\n",
|
|
|
|
//APP_LOG(TS_OFF, VLEVEL_M, "\r\nAverage Result=%d Distance=%d, Score=%d MotionCount=%d ---Overall Result=%d \r\n",
|
|
|
|
// (int)average_result, (int)average_distance, (int)average_score, (int)motion_count, (int)sts_rss_result);
|
|
|
|
// (int)average_result, (int)average_distance, (int)average_score, (int)motion_count, (int)sts_rss_result);
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\nMotion Status: %d %d (mm) %d singularity: %d Rated-> %d \r\n",(int)average_result, (int)average_distance, (int)average_score, (int)sts_presence_singularity, (int)sts_rss_result);
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\nMotion Status: %d %d (mm) %d singularity: %d Rated-> %d \r\n",(int)average_result, (int)average_distance, (int)average_score, (int)sts_presence_singularity, (int)sts_rss_result);
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
|
if (sts_rss_result) //if (average_score !=0) //if (sts_rss_result)
|
|
|
|
if (sts_rss_result) //if (average_score !=0) //if (sts_rss_result)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -923,7 +1167,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"Application finished OK\n");
|
|
|
|
APP_LOG(TS_OFF, VLEVEL_H,"Application finished OK\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -948,7 +1192,8 @@ void STS_Yunhorn_DistanceStandardDeviation(void)
|
|
|
|
sum_presence_distance += (uint32_t)(sts_motion_dataset[j].presence_distance - average_presence_distance);
|
|
|
|
sum_presence_distance += (uint32_t)(sts_motion_dataset[j].presence_distance - average_presence_distance);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sts_presence_singularity = (sum_presence_distance > 0)? 0:1;
|
|
|
|
// sts_presence_singularity = (sum_presence_distance > 0)? 0:1;
|
|
|
|
|
|
|
|
sts_presence_singularity = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// APP_LOG(TS_OFF, VLEVEL_M, "\r\n*** STS_Singularity=%u ***\r\n", sts_presence_singularity);
|
|
|
|
// APP_LOG(TS_OFF, VLEVEL_M, "\r\n*** STS_Singularity=%u ***\r\n", sts_presence_singularity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|