wip workable for 3 min only then error
This commit is contained in:
parent
a5ce3af359
commit
981452db3b
|
@ -771,7 +771,7 @@ void STS_SENSOR_Distance_Test_Process(void);
|
|||
void STS_PRESENCE_SENSOR_Function_Test_Process(uint8_t *self_test_result, uint8_t count);
|
||||
void STS_PRESENCE_SENSOR_Distance_Measure_Process(void);
|
||||
void STS_PRESENCE_SENSOR_Background_Measure_Process(uint16_t *bg_distance, uint16_t *bg_motion_noise);
|
||||
void sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance, uint16_t *evaluated_score);
|
||||
int sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance, uint16_t *evaluated_score);
|
||||
void STS_Sensor_Init(void);
|
||||
void STS_Sensor_Prepare(void);
|
||||
|
||||
|
|
|
@ -118,11 +118,11 @@ void SystemApp_Init(void)
|
|||
/*Initialize the Sensors */
|
||||
EnvSensors_Init();
|
||||
// LED1 Flash 3 times for normal power on
|
||||
LED1_TOGGLE; HAL_Delay(500);
|
||||
LED1_TOGGLE; HAL_Delay(500);
|
||||
LED1_TOGGLE; HAL_Delay(500);
|
||||
LED1_TOGGLE; HAL_Delay(500);
|
||||
LED1_TOGGLE; HAL_Delay(500);
|
||||
LED1_TOGGLE; HAL_Delay(100);
|
||||
LED1_TOGGLE; HAL_Delay(100);
|
||||
LED1_TOGGLE; HAL_Delay(100);
|
||||
LED1_TOGGLE; HAL_Delay(100);
|
||||
LED1_TOGGLE; HAL_Delay(100);
|
||||
LED1_TOGGLE;
|
||||
/*Init low power manager*/
|
||||
UTIL_LPM_Init();
|
||||
|
|
|
@ -57,12 +57,14 @@
|
|||
// GOOD --- volatile distance_measure_cfg_t distance_cfg={0.4, 3.5, 4, 63, 0, 10, 0.5, 1.3, 0.2};
|
||||
// 2024-08-15 volatile distance_measure_cfg_t distance_cfg={0.8, 3.5, 2, 63, 2, 10, 0.5, 1.3, 0.2};
|
||||
//volatile distance_measure_cfg_t distance_cfg={0.8, 3.5, 4, 63, 2, 10, 0.5, 1.3, 0.2};
|
||||
volatile distance_measure_cfg_t distance_cfg={0.8, 3.5, 4, 63, 2, 10, 0.4, 1.2, 0.2};
|
||||
volatile distance_measure_cfg_t distance_cfg ={0.8, 3.5, 4, 63, 2, 10, 0.4, 1.2, 0.2};
|
||||
volatile distance_measure_cfg_t presence_distance_cfg ={0.8, 3.5, 4, 63, 2, 10, 0.4, 1.2, 0.2};
|
||||
//volatile distance_measure_cfg_t distance_cfg={1.5, 3.3, 2, 63, 4, 10, 0.8182f, 0.4, 0.2};
|
||||
extern volatile uint16_t sts_distance_rss_distance, sts_sensor_install_height;
|
||||
|
||||
extern volatile uint8_t sts_presence_distance_flag;
|
||||
volatile uint8_t sts_distance_rss_distance_peak=0;
|
||||
static void sts_distance_rss_update_configuration(acc_detector_distance_configuration_t distance_configuration);
|
||||
|
||||
//static void sts_distance_rss_update_presence_config(acc_detector_distance_configuration_t distance_configuration, distance_measure_cfg_t presence_distance_cfg);
|
||||
|
||||
static void print_distances(acc_detector_distance_result_t *result, uint16_t reflection_count);
|
||||
|
||||
|
@ -71,6 +73,9 @@ int sts_distance_rss_detector_distance(void);
|
|||
|
||||
int sts_distance_rss_detector_distance(void)
|
||||
{
|
||||
sts_distance_rss_distance =0;
|
||||
sts_distance_rss_distance_peak =0;
|
||||
|
||||
const acc_hal_t *hal = acc_hal_integration_get_implementation();
|
||||
|
||||
if (!acc_rss_activate(hal))
|
||||
|
@ -89,8 +94,15 @@ int sts_distance_rss_detector_distance(void)
|
|||
acc_rss_deactivate();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (sts_presence_distance_flag == 1)
|
||||
{
|
||||
|
||||
// sts_distance_rss_update_presence_config(distance_configuration, presence_distance_cfg);
|
||||
|
||||
} else {
|
||||
sts_distance_rss_update_configuration(distance_configuration);
|
||||
}
|
||||
|
||||
sts_distance_rss_update_configuration(distance_configuration);
|
||||
|
||||
acc_detector_distance_handle_t distance_handle = acc_detector_distance_create(distance_configuration);
|
||||
|
||||
|
@ -114,10 +126,11 @@ int sts_distance_rss_detector_distance(void)
|
|||
|
||||
bool success = true;
|
||||
const int iterations = 1; //5;
|
||||
uint16_t number_of_peaks = 1; // FSB first significant Bin
|
||||
uint16_t number_of_peaks = 5; // FSB first significant Bin
|
||||
acc_detector_distance_result_t result[number_of_peaks];
|
||||
acc_detector_distance_result_info_t result_info;
|
||||
float tmp_distance = 0.0f;
|
||||
uint16_t tmp_num_of_peaks = 0;
|
||||
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
|
@ -129,15 +142,30 @@ int sts_distance_rss_detector_distance(void)
|
|||
break;
|
||||
}
|
||||
for(uint8_t j=0; j< result_info.number_of_peaks; j++)
|
||||
tmp_distance = tmp_distance + (result[j].distance_m); //KalmanFilter(result[j].distance_m);
|
||||
{
|
||||
tmp_distance = tmp_distance + (result[j].distance_m); //KalmanFilter(result[j].distance_m);
|
||||
}
|
||||
tmp_num_of_peaks += result_info.number_of_peaks;
|
||||
print_distances(result, result_info.number_of_peaks);
|
||||
}
|
||||
|
||||
sts_distance_rss_distance = (uint16_t)(1000*tmp_distance)/(number_of_peaks*iterations);
|
||||
|
||||
// ensure it's a valid installation height
|
||||
//sts_sensor_install_height = (uint16_t)MAX(sts_distance_rss_distance,2000);
|
||||
sts_sensor_install_height = (uint16_t)sts_distance_rss_distance;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nAverage Distance =%u mm --- Assume Sensor Install Height = %u mm\r\n", (uint16_t)sts_distance_rss_distance, (uint16_t)sts_sensor_install_height);
|
||||
//sts_distance_rss_distance = (uint16_t)(1000*tmp_distance)/(number_of_peaks*iterations);
|
||||
sts_distance_rss_distance = (uint16_t)(1000*tmp_distance)/(tmp_num_of_peaks);
|
||||
//sts_distance_rss_distance_peak = result_info.number_of_peaks;
|
||||
sts_distance_rss_distance_peak = tmp_num_of_peaks/iterations;
|
||||
|
||||
if (sts_presence_distance_flag == 1)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nAverage Distance =%u mm Peak:%d\r\n", (uint16_t)sts_distance_rss_distance, sts_distance_rss_distance_peak);
|
||||
|
||||
} else
|
||||
{
|
||||
sts_sensor_install_height = (uint16_t)sts_distance_rss_distance;
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\nAssume Sensor Install Height = %u mm\r\n", (uint16_t)sts_sensor_install_height);
|
||||
}
|
||||
|
||||
bool deactivated = acc_detector_distance_deactivate(distance_handle);
|
||||
|
||||
|
@ -172,7 +200,26 @@ static void sts_distance_rss_update_configuration(acc_detector_distance_configur
|
|||
acc_detector_distance_configuration_cfar_threshold_window_set(distance_configuration,DEFAULT_FAR_RANGE_CFAR_THRESHOLD_WINDOW);
|
||||
acc_detector_distance_configuration_record_background_sweeps_set(distance_configuration, 16);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void sts_distance_rss_update_presence_config(acc_detector_distance_configuration_t distance_configuration, distance_measure_cfg_t presence_distance_cfg)
|
||||
{
|
||||
acc_detector_distance_configuration_mur_set(distance_configuration, DEFAULT_FAR_RANGE_MUR); // NEW ADD
|
||||
acc_detector_distance_configuration_requested_start_set(distance_configuration, presence_distance_cfg.start_m);
|
||||
acc_detector_distance_configuration_requested_length_set(distance_configuration, presence_distance_cfg.length_m);
|
||||
acc_detector_distance_configuration_receiver_gain_set(distance_configuration,presence_distance_cfg.gain);
|
||||
acc_detector_distance_configuration_maximize_signal_attenuation_set(distance_configuration, DEFAULT_FAR_MAXIMIZE_SIGNAL_ATTENUATION); // NEW ADD
|
||||
acc_detector_distance_configuration_service_profile_set(distance_configuration, presence_distance_cfg.acc_profile);
|
||||
acc_detector_distance_configuration_downsampling_factor_set(distance_configuration, presence_distance_cfg.downsampling);
|
||||
acc_detector_distance_configuration_sweep_averaging_set(distance_configuration,presence_distance_cfg.sweep_average);
|
||||
acc_detector_distance_configuration_threshold_type_set(distance_configuration, ACC_DETECTOR_DISTANCE_THRESHOLD_TYPE_CFAR);
|
||||
acc_detector_distance_configuration_threshold_sensitivity_set(distance_configuration, presence_distance_cfg.threshold);
|
||||
//acc_detector_distance_configuration_hw_accelerated_average_samples_set(distance_configuration, distance_cfg.hwaas);
|
||||
//acc_detector_distance_configuration_threshold_type_set(distance_configuration, DEFAULT_FAR_RANGE_THRESHOLD_TYPE); //NEW ADD
|
||||
acc_detector_distance_configuration_cfar_threshold_guard_set(distance_configuration, DEFAULT_FAR_RANGE_CFAR_THRESHOLD_GUARD);
|
||||
acc_detector_distance_configuration_cfar_threshold_window_set(distance_configuration,DEFAULT_FAR_RANGE_CFAR_THRESHOLD_WINDOW);
|
||||
acc_detector_distance_configuration_record_background_sweeps_set(distance_configuration, 16);
|
||||
}
|
||||
#endif
|
||||
//backup. ... previous setting ----don't delete
|
||||
/*
|
||||
static void sts_distance_rss_update_configuration(acc_detector_distance_configuration_t distance_configuration)
|
||||
|
@ -195,11 +242,11 @@ static void sts_distance_rss_update_configuration(acc_detector_distance_configur
|
|||
//
|
||||
static void print_distances(acc_detector_distance_result_t *result, uint16_t reflection_count)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "Found %u peaks:\n", (unsigned int)reflection_count);
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "Found %u peaks: ", (unsigned int)reflection_count);
|
||||
|
||||
for (uint16_t i = 0; i < reflection_count; i++)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "Amplitude %u at %u mm\n", (unsigned int)result[i].amplitude,
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "Amplitude %u at %u mm\n", (unsigned int)result[i].amplitude,
|
||||
(unsigned int)(result[i].distance_m * 1000));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
/* USER CODE BEGIN Includes */
|
||||
#include "acc_definitions_common.h"
|
||||
#include "acc_detector_presence.h"
|
||||
#include "acc_detector_distance.h"
|
||||
#include "acc_hal_definitions.h"
|
||||
#include "acc_hal_integration.h"
|
||||
#include "acc_integration.h"
|
||||
|
@ -146,9 +147,17 @@ volatile uint8_t last_sts_fall_rising_detected_result= STS_PRESENCE_NORMAL;
|
|||
volatile uint16_t last_average_presence_distance=0;
|
||||
volatile uint16_t sts_fall_rising_pattern_factor1=0, sts_fall_rising_pattern_factor2=0, sts_fall_rising_pattern_factor3=0;
|
||||
volatile uint16_t sts_roc_acc_standard_variance=0;
|
||||
volatile uint8_t sts_presence_distance_flag=1;
|
||||
extern volatile uint8_t sts_distance_rss_distance_peak;
|
||||
volatile uint8_t sts_distance_presence_in_window=0;
|
||||
extern volatile distance_measure_cfg_t presence_distance_cfg;
|
||||
extern volatile distance_measure_cfg_t distance_cfg;
|
||||
extern volatile uint8_t sts_presence_fall_detection;
|
||||
static uint8_t sts_rss_init_ok=0;
|
||||
extern uint8_t sts_lamp_bar_color;
|
||||
|
||||
static void sts_distance_rss_update_presence_config(acc_detector_distance_configuration_t distance_configuration, distance_measure_cfg_t presence_distance_cfg);
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
|
@ -395,11 +404,14 @@ static void print_current_configuration(acc_detector_presence_configuration_t pr
|
|||
float sts_run_f_intra_frame_time_const = sts_run_filter.intra_frame_time_const;
|
||||
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;
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\nWork_mode:%2d Start: %4d (mm) Length: %4d (mm) Threshold: %4d (*) Gain= %2d (%) UpdateRate=%4d Profile= %d \r\n",
|
||||
#if 0
|
||||
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);
|
||||
|
||||
#endif
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n[M%2d,S:%4d,L:%4d,T:%4d,G:%2d %, R:%2d, P:%d ==",
|
||||
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 "
|
||||
"(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),
|
||||
|
@ -429,7 +441,7 @@ static void print_result(acc_detector_presence_result_t result)
|
|||
* sts_rss_result
|
||||
*/
|
||||
|
||||
void sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance, uint16_t *evaluated_score)
|
||||
int sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance, uint16_t *evaluated_score)
|
||||
{
|
||||
|
||||
const acc_hal_t *hal = acc_hal_integration_get_implementation();
|
||||
|
@ -529,6 +541,35 @@ void sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance
|
|||
|
||||
int sts_presence_rss_fall_rise_detection(void)
|
||||
{
|
||||
#if 0
|
||||
uint8_t exit_status = EXIT_SUCCESS, i=0;
|
||||
//do
|
||||
//{
|
||||
sts_presence_distance_flag = 1;
|
||||
presence_distance_cfg.start_m = sts_presence_rss_config.default_start_m;
|
||||
presence_distance_cfg.length_m = sts_presence_rss_config.default_length_m;
|
||||
LED1_TOGGLE;
|
||||
exit_status = sts_distance_rss_detector_distance();
|
||||
sts_presence_distance_flag = 0;
|
||||
|
||||
// HAL_Delay(10);
|
||||
// i++;
|
||||
//} while ((exit_status == EXIT_FAILURE) && (i < 1));
|
||||
if (exit_status == EXIT_FAILURE)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"\r\nFailed to Get Distance \n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((sts_distance_rss_distance < 1000.0*(presence_distance_cfg.start_m + presence_distance_cfg.length_m)) && (sts_distance_rss_distance > 1000.0*presence_distance_cfg.length_m ))
|
||||
{
|
||||
sts_distance_presence_in_window = 1;
|
||||
} else {
|
||||
sts_distance_presence_in_window = 0;
|
||||
}
|
||||
}
|
||||
LED1_TOGGLE;
|
||||
#endif
|
||||
const acc_hal_t *hal = acc_hal_integration_get_implementation();
|
||||
|
||||
if (!acc_rss_activate(hal))
|
||||
|
@ -539,6 +580,50 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
|
||||
acc_rss_override_sensor_id_check_at_creation(true);
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++
|
||||
|
||||
acc_detector_distance_configuration_t distance_configuration = acc_detector_distance_configuration_create();
|
||||
|
||||
if (distance_configuration == NULL)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "acc_detector_distance_configuration_create() failed\n");
|
||||
acc_rss_deactivate();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
//if (sts_presence_distance_flag == 1)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n RSS CFG start: %4d Length:%4d \r\n", (int)(1000.0*sts_presence_rss_config.default_start_m), (int)(1000.0*sts_presence_rss_config.default_length_m));
|
||||
presence_distance_cfg.start_m = sts_presence_rss_config.default_start_m;
|
||||
presence_distance_cfg.length_m = sts_presence_rss_config.default_length_m;
|
||||
|
||||
|
||||
sts_distance_rss_update_presence_config(distance_configuration, presence_distance_cfg);
|
||||
|
||||
}
|
||||
|
||||
acc_detector_distance_handle_t distance_handle = acc_detector_distance_create(distance_configuration);
|
||||
|
||||
if (distance_handle == NULL)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "acc_detector_distance_create() failed\n");
|
||||
acc_detector_distance_configuration_destroy(&distance_configuration);
|
||||
acc_rss_deactivate();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
acc_detector_distance_configuration_destroy(&distance_configuration);
|
||||
#if 0
|
||||
if (!acc_detector_distance_activate(distance_handle))
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "acc_detector_distance_activate() failed\n");
|
||||
acc_detector_distance_destroy(&distance_handle);
|
||||
acc_rss_deactivate();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
//+++++++++++++++++++++++++++++++++++
|
||||
|
||||
acc_detector_presence_configuration_t presence_configuration = acc_detector_presence_configuration_create();
|
||||
if (presence_configuration == NULL)
|
||||
{
|
||||
|
@ -697,7 +782,72 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
}
|
||||
|
||||
deactivated = acc_detector_presence_deactivate(handle);
|
||||
acc_detector_presence_destroy(&handle);
|
||||
// acc_detector_presence_destroy(&handle);
|
||||
|
||||
// ++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
if (!acc_detector_distance_activate(distance_handle))
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "acc_detector_distance_activate() failed\n");
|
||||
acc_detector_distance_destroy(&distance_handle);
|
||||
acc_rss_deactivate();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
bool success = true;
|
||||
const int iterations = 1; //5;
|
||||
uint16_t number_of_peaks = 5; // FSB first significant Bin
|
||||
acc_detector_distance_result_t result[number_of_peaks];
|
||||
acc_detector_distance_result_info_t result_info;
|
||||
float tmp_distance = 0.0f;
|
||||
uint16_t tmp_num_of_peaks = 0;
|
||||
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
success = acc_detector_distance_get_next(distance_handle, result, number_of_peaks, &result_info);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "acc_detector_distance_get_next() failed\n");
|
||||
break;
|
||||
}
|
||||
for(uint8_t j=0; j< result_info.number_of_peaks; j++)
|
||||
{
|
||||
tmp_distance = tmp_distance + (result[j].distance_m); //KalmanFilter(result[j].distance_m);
|
||||
}
|
||||
tmp_num_of_peaks += result_info.number_of_peaks;
|
||||
//print_distances(result, result_info.number_of_peaks);
|
||||
}
|
||||
|
||||
|
||||
// ensure it's a valid installation height
|
||||
//sts_sensor_install_height = (uint16_t)MAX(sts_distance_rss_distance,2000);
|
||||
//sts_distance_rss_distance = (uint16_t)(1000*tmp_distance)/(number_of_peaks*iterations);
|
||||
sts_distance_rss_distance = (uint16_t)(1000*tmp_distance)/(tmp_num_of_peaks);
|
||||
//sts_distance_rss_distance_peak = result_info.number_of_peaks;
|
||||
sts_distance_rss_distance_peak = tmp_num_of_peaks/iterations;
|
||||
|
||||
if (sts_presence_distance_flag == 1)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nAverage Distance =%u mm Peak:%d\r\n", (uint16_t)sts_distance_rss_distance, sts_distance_rss_distance_peak);
|
||||
|
||||
} else
|
||||
{
|
||||
sts_sensor_install_height = (uint16_t)sts_distance_rss_distance;
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\nAssume Sensor Install Height = %u mm\r\n", (uint16_t)sts_sensor_install_height);
|
||||
}
|
||||
|
||||
bool deactivated = acc_detector_distance_deactivate(distance_handle);
|
||||
|
||||
acc_detector_distance_destroy(&distance_handle);
|
||||
|
||||
|
||||
// ++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
|
||||
acc_rss_deactivate();
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\n First Half --- Motion Count = %u \r\n", motion_count);
|
||||
|
@ -806,7 +956,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
|
||||
average_distance = (1000.0f*average_distance)/average_result; // in meters
|
||||
average_score = (1000.0f*average_score)/average_result;
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\nAverage Distance: %d (mm) Score: %d \r\n",(int)average_distance, (int)average_score);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, " | AD: %4d AS: %4d |",(int)average_distance, (int)average_score);
|
||||
sts_presence_rss_distance = average_distance;
|
||||
sts_presence_rss_score = average_score;
|
||||
// uint8_t pre_sts_rss_result = (average_result > (DEFAULT_UPDATE_RATE_PRESENCE/5))? 1: 0;
|
||||
|
@ -823,14 +973,15 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
if (sts_work_mode == STS_UNI_MODE) {
|
||||
pre_sts_rss_result = (average_result > 0)? 1: 0;
|
||||
} else {
|
||||
pre_sts_rss_result = (average_result > 0)? 1: 0;
|
||||
pre_sts_rss_result = ((average_result > 0) || (sts_distance_presence_in_window))? 1: 0;
|
||||
}
|
||||
STS_RSS_Filter(pre_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",
|
||||
// (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 %d Rated-> %d \r\n",(int)average_result, (int)average_distance, (int)average_score, (int)motion_count, (int)sts_rss_result);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, " Motion Status: %d %d (mm) %d %d Rated-> %d \r\n",
|
||||
(int)(int)average_result, (int)average_distance, (int)average_score, (int)motion_count, (int)sts_rss_result);
|
||||
#if 0
|
||||
if (sts_rss_result) //if (average_score !=0) //if (sts_rss_result)
|
||||
{
|
||||
|
@ -1124,6 +1275,46 @@ void STS_YunhornCheckStandardDeviation(void)
|
|||
}
|
||||
|
||||
|
||||
static void sts_distance_rss_update_presence_config(acc_detector_distance_configuration_t distance_configuration, distance_measure_cfg_t presence_distance_cfg)
|
||||
{
|
||||
#define DEFAULT_FAR_RANGE_MUR ACC_SERVICE_MUR_6
|
||||
#define DEFAULT_FAR_RANGE_SERVICE_PROFILE ACC_SERVICE_PROFILE_2
|
||||
#define DEFAULT_FAR_MAXIMIZE_SIGNAL_ATTENUATION false
|
||||
#define STS_DISTANCE_START_M (0.8f)
|
||||
#define STS_DISTANCE_LENGTH_M (1.4f)
|
||||
#define STS_DISTANCE_PROFILE ACC_SERVICE_PROFILE_2
|
||||
#define STS_DISTANCE_HWAAS (63)
|
||||
#define DEFAULT_FAR_RANGE_CFAR_THRESHOLD_GUARD 0.12f
|
||||
#define DEFAULT_FAR_RANGE_CFAR_THRESHOLD_WINDOW 0.03f
|
||||
#ifndef MIN
|
||||
#define MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
|
||||
#endif
|
||||
|
||||
|
||||
acc_detector_distance_configuration_mur_set(distance_configuration, DEFAULT_FAR_RANGE_MUR); // NEW ADD
|
||||
acc_detector_distance_configuration_requested_start_set(distance_configuration, presence_distance_cfg.start_m);
|
||||
acc_detector_distance_configuration_requested_length_set(distance_configuration, presence_distance_cfg.length_m);
|
||||
|
||||
acc_detector_distance_configuration_receiver_gain_set(distance_configuration, distance_cfg.gain);
|
||||
acc_detector_distance_configuration_maximize_signal_attenuation_set(distance_configuration, DEFAULT_FAR_MAXIMIZE_SIGNAL_ATTENUATION); // NEW ADD
|
||||
acc_detector_distance_configuration_service_profile_set(distance_configuration, distance_cfg.acc_profile);
|
||||
acc_detector_distance_configuration_downsampling_factor_set(distance_configuration, distance_cfg.downsampling);
|
||||
acc_detector_distance_configuration_sweep_averaging_set(distance_configuration,distance_cfg.sweep_average);
|
||||
acc_detector_distance_configuration_threshold_type_set(distance_configuration, ACC_DETECTOR_DISTANCE_THRESHOLD_TYPE_CFAR);
|
||||
acc_detector_distance_configuration_threshold_sensitivity_set(distance_configuration, distance_cfg.threshold);
|
||||
//acc_detector_distance_configuration_hw_accelerated_average_samples_set(distance_configuration, distance_cfg.hwaas);
|
||||
//acc_detector_distance_configuration_threshold_type_set(distance_configuration, DEFAULT_FAR_RANGE_THRESHOLD_TYPE); //NEW ADD
|
||||
acc_detector_distance_configuration_cfar_threshold_guard_set(distance_configuration, DEFAULT_FAR_RANGE_CFAR_THRESHOLD_GUARD);
|
||||
acc_detector_distance_configuration_cfar_threshold_window_set(distance_configuration,DEFAULT_FAR_RANGE_CFAR_THRESHOLD_WINDOW);
|
||||
acc_detector_distance_configuration_record_background_sweeps_set(distance_configuration, 16);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ volatile uint8_t sts_rss_result_changed_flag = 0;
|
|||
volatile uint8_t sts_rss_result = STS_RESULT_NO_MOTION;
|
||||
volatile uint8_t sts_rss_2nd_result = STS_RESULT_NO_MOTION; //2nd RSS sensor status
|
||||
volatile uint8_t sts_tof_result = STS_RESULT_NO_MOTION;
|
||||
volatile uint8_t last_sts_rss_result=STS_RESULT_NO_MOTION;
|
||||
volatile uint8_t last_sts_rss_result=STS_RESULT_MOTION;
|
||||
_Bool Motion_Flag = 0;
|
||||
|
||||
//extern volatile uint8_t last_sts_reed_hall_result;
|
||||
|
@ -355,7 +355,7 @@ void STS_YunhornSTSEventP2_Process(void)
|
|||
}
|
||||
|
||||
STS_Combined_Status_Processing();
|
||||
} else APP_LOG(TS_OFF, VLEVEL_H, "\r\n RSS detection error =%d \r\n", res);
|
||||
} else APP_LOG(TS_OFF, VLEVEL_M, "\r\n RSS detection error =%d \r\n", res);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1079,7 +1079,7 @@ void STS_PRESENCE_SENSOR_Background_Measure_Process(uint16_t *bg_distance, uint1
|
|||
sts_work_mode = STS_RSS_BACKGROUND_MODE;
|
||||
sts_lamp_bar_color = STS_BLUE;
|
||||
|
||||
sts_presence_rss_background_evaluation_process(&distance_center, &motion_noise);
|
||||
int status=sts_presence_rss_background_evaluation_process(&distance_center, &motion_noise);
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\n Background Distance center at %d mm, and Motion Noise =%d \r\n", distance_center, motion_noise);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ void MX_LoRaWAN_Init(void)
|
|||
SystemApp_Init();
|
||||
/* USER CODE BEGIN MX_LoRaWAN_Init_2 */
|
||||
//STS_Lamp_Bar_Self_Test_Simple();
|
||||
//STS_Lamp_Bar_Self_Test();
|
||||
STS_Lamp_Bar_Self_Test();
|
||||
/* USER CODE END MX_LoRaWAN_Init_2 */
|
||||
LoRaWAN_Init();
|
||||
/* USER CODE BEGIN MX_LoRaWAN_Init_3 */
|
||||
|
|
|
@ -738,11 +738,11 @@ void STS_Sensor_Init(void)
|
|||
UTIL_TIMER_Create(&YunhornSTSRSSWakeUpTimer, YUNHORN_STS_RSS_WAKEUP_CHECK_TIME, UTIL_TIMER_ONESHOT, OnYunhornSTSOORSSWakeUpTimerEvent, NULL);
|
||||
UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
||||
|
||||
UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, YUNHORN_STS_HEART_BEAT_CHECK_TIME, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL);
|
||||
UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, YUNHORN_STS_HEART_BEAT_CHECK_TIME, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL);
|
||||
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
||||
|
||||
UTIL_TIMER_Start(&STSLampBarColorTimer);
|
||||
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
//UTIL_TIMER_Start(&STSDurationCheckTimer);
|
||||
|
||||
#else
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue