---- rss config for default, simple, full and fall detection

This commit is contained in:
Yunhorn 2024-08-15 18:40:24 +08:00
parent e797d0327f
commit 990e83f58e
4 changed files with 162 additions and 149 deletions

View File

@ -55,7 +55,8 @@
//volatile distance_measure_cfg_t distance_cfg={1.5, 2.0, 1, 63, 2, 10, 0.5, 1.3, 0.2};
// SPARK FUN EXAMPLE
// GOOD --- volatile distance_measure_cfg_t distance_cfg={0.4, 3.5, 4, 63, 0, 10, 0.5, 1.3, 0.2};
volatile distance_measure_cfg_t distance_cfg={0.8, 3.5, 2, 63, 2, 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={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;
@ -111,7 +112,7 @@ int sts_distance_rss_detector_distance(void)
}
bool success = true;
const int iterations = 10; //5;
const int iterations = 5; //5;
uint16_t number_of_peaks = 1;
acc_detector_distance_result_t result[number_of_peaks];
acc_detector_distance_result_info_t result_info;

View File

@ -112,6 +112,7 @@ volatile uint8_t sts_unconscious_state=0;
volatile uint16_t sts_unconscious_threshold=1280, sts_unconscious_duration=0;
extern volatile uint8_t sts_rss_result, sts_rss_config_updated_flag, last_sts_rss_result;
extern volatile uint16_t sts_distance_rss_distance, sts_sensor_install_height;
extern volatile uint8_t sts_work_mode;
volatile float sts_presence_rss_distance, sts_presence_rss_score;
volatile STS_OO_RSS_SensorTuneDataTypeDef sts_presence_rss_config;
@ -123,8 +124,8 @@ volatile uint8_t detected_hs_zone=0;;
volatile uint16_t motion_count=0, motion_feature_count=0;
typedef struct
{
uint16_t presence_score; // 1000*
uint16_t presence_distance; // 1000*, in mm
uint32_t presence_score; // 1000*
uint32_t presence_distance; // 1000*, in mm
} STS_presence_result_t;
static STS_presence_result_t sts_motion_dataset[DEFAULT_MOTION_DATASET_LEN];
@ -132,7 +133,7 @@ static STS_PRESENCE_Motion_Featuer_t sts_motion_feature[DEFAULT_MOTION_FEATURE_L
volatile uint8_t sts_fall_rising_detected_result = STS_PRESENCE_NORMAL;
volatile uint8_t sts_fall_rising_detected_result_changed_flag =0;
volatile uint8_t last_sts_fall_rising_detected_result= STS_PRESENCE_NORMAL;
volatile float last_average_presence_distance;
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;
extern volatile uint8_t sts_presence_fall_detection;
@ -348,24 +349,24 @@ int sts_presence_rss_fall_rise_detection(void)
{
case STS_RSS_CONFIG_DEFAULT:
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;
case STS_RSS_CONFIG_SIMPLE:
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");
break;
case STS_RSS_CONFIG_FULL:
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;
case STS_RSS_CONFIG_FALL_DETECTION:
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;
default:
break;
}
sts_rss_config_updated_flag = STS_RSS_CONFIG_DEFAULT; //update finished, set to 0
//sts_rss_config_updated_flag = STS_RSS_CONFIG_DEFAULT; //update finished, set to 0
acc_detector_presence_handle_t handle = acc_detector_presence_create(presence_configuration);
if (handle == NULL)
@ -404,136 +405,141 @@ int sts_presence_rss_fall_rise_detection(void)
//past 10 times of detection with 5 zones from ground to ceiling
//for (k=0; k<5; k++) {motion_in_zone[k]=0;}
#if 1
for (int i = 0; i < (iterations/2); i++)
if ((sts_work_mode == STS_DUAL_MODE)||(sts_work_mode == STS_RSS_MODE))
{
success = acc_detector_presence_get_next(handle, &result);
if (!success)
{
APP_LOG(TS_OFF, VLEVEL_H,"acc_detector_presence_get_next() failed\n");
break;
}
//print_result(result);
if (!result.data_saturated)
{
//APP_LOG(TS_OFF, VLEVEL_H,"\n%u ", i);
//print_result(result);
if (result.presence_detected)
for (int i = 0; i < (iterations/2); i++)
{
success = acc_detector_presence_get_next(handle, &result);
if (!success)
{
APP_LOG(TS_OFF, VLEVEL_H,"acc_detector_presence_get_next() failed\n");
break;
}
//print_result(result);
average_result++;
average_distance += result.presence_distance;
average_score += result.presence_score;
//detected_zone = (uint16_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH);
//2024-08-05
detected_zone = (uint16_t)((float)(result.presence_distance) / (float)DEFAULT_ZONE_LENGTH);
motion_in_zone[detected_zone]++;
// new add 2024-06-18
//detected_hs_zone = (uint16_t)((float)(sts_sensor_install_height/1000.0f - (result.presence_distance))/(float)DEFAULT_ZONE_LENGTH);
//if (detected_hs_zone == 0)
//APP_LOG(TS_OFF, VLEVEL_L, "\r\nPresence_Distance=%u \r\n", (int)result.presence_distance*1000.0);
//APP_LOG(TS_OFF, VLEVEL_L, "\r\nHS_ZONE=%u", (int)detected_hs_zone);
detected_hs_zone = 10 - detected_zone;
motion_in_hs_zone[detected_hs_zone][(motion_detected_count)]++;
if (!result.data_saturated)
{
//APP_LOG(TS_OFF, VLEVEL_H,"\n%u ", i);
//print_result(result);
if (result.presence_detected)
{
//print_result(result);
average_result++;
average_distance += result.presence_distance;
average_score += result.presence_score;
//detected_zone = (uint16_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH);
//2024-08-05
detected_zone = (uint16_t)((float)(result.presence_distance) / (float)DEFAULT_ZONE_LENGTH);
motion_in_zone[detected_zone]++;
// new add 2024-06-18
//detected_hs_zone = (uint16_t)((float)(sts_sensor_install_height/1000.0f - (result.presence_distance))/(float)DEFAULT_ZONE_LENGTH);
//if (detected_hs_zone == 0)
//APP_LOG(TS_OFF, VLEVEL_L, "\r\nPresence_Distance=%u \r\n", (int)result.presence_distance*1000.0);
//APP_LOG(TS_OFF, VLEVEL_L, "\r\nHS_ZONE=%u", (int)detected_hs_zone);
detected_hs_zone = 10 - detected_zone;
motion_in_hs_zone[detected_hs_zone][(motion_detected_count)]++;
sts_motion_dataset[motion_count].presence_distance = 1000*result.presence_distance;
sts_motion_dataset[motion_count].presence_score = 1000*result.presence_score;
sts_motion_dataset[motion_count].presence_distance = 1000*result.presence_distance;
sts_motion_dataset[motion_count].presence_score = 1000*result.presence_score;
motion_count++;
motion_count++;
}
}
//acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // 15ms, DEFAULT_UPDATE_RATE);
//acc_integration_sleep_ms(1);
}
}
APP_LOG(TS_OFF, VLEVEL_H, "\r\n First Half --- Motion Count = %u \r\n", motion_count);
//acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // 15ms, DEFAULT_UPDATE_RATE);
//acc_integration_sleep_ms(1);
acc_detector_presence_deactivate(handle);
}
APP_LOG(TS_OFF, VLEVEL_H, "\r\n First Half --- Motion Count = %u \r\n", motion_count);
acc_detector_presence_deactivate(handle);
else if ((sts_work_mode == STS_UNI_MODE))
{
// ******** Second Half detection of fall down and rise up
//if (sts_presence_fall_detection == TRUE)
//{
// the following has been updated, no need to re-cofig
#if 0
set_default_fall_rise_configuration(presence_configuration);
if (!acc_detector_presence_reconfigure(&handle, presence_configuration))
{
APP_LOG(TS_OFF, VLEVEL_H,"Failed to reconfigure detector\n");
acc_detector_presence_configuration_destroy(&presence_configuration);
acc_detector_presence_destroy(&handle);
acc_rss_deactivate();
return EXIT_FAILURE;
}
#endif
// ******** Second Half detection of fall down and rise up
//if (sts_presence_fall_detection == TRUE)
//{
set_default_fall_rise_configuration(presence_configuration);
if (!acc_detector_presence_reconfigure(&handle, presence_configuration))
{
APP_LOG(TS_OFF, VLEVEL_H,"Failed to reconfigure detector\n");
acc_detector_presence_configuration_destroy(&presence_configuration);
acc_detector_presence_destroy(&handle);
acc_rss_deactivate();
return EXIT_FAILURE;
}
if (!acc_detector_presence_activate(handle))
{
APP_LOG(TS_OFF, VLEVEL_H, "Failed to activate detector \n");
return false;
}
acc_detector_presence_configuration_destroy(&presence_configuration);
// set to full length of iteration
for (int i = 0; i < (iterations/2); i++)
{
success = acc_detector_presence_get_next(handle, &result);
if (!success)
{
APP_LOG(TS_OFF, VLEVEL_H,"acc_detector_presence_get_next() failed\n");
break;
}
if (!result.data_saturated)
{
//APP_LOG(TS_OFF, VLEVEL_H,"\n%u ", i);
//print_result(result);
if (result.presence_detected)
if (!acc_detector_presence_activate(handle))
{
//print_result(result);
average_result++;
average_distance += result.presence_distance;
average_score += result.presence_score;
//detected_zone = (uint16_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH);
// 2024-08-05
detected_zone = (uint16_t)((float)(result.presence_distance) / (float)DEFAULT_ZONE_LENGTH);
motion_in_zone[detected_zone]++;
// new add 2024-06-18
//detected_hs_zone = (uint16_t)((float)(sts_sensor_install_height/1000.0f - (result.presence_distance))/(float)DEFAULT_ZONE_LENGTH);
//if (detected_hs_zone == 0)
//APP_LOG(TS_OFF, VLEVEL_L, "\r\nPresence_Distance=%u \r\n", (int)result.presence_distance*1000.0);
//APP_LOG(TS_OFF, VLEVEL_L, "\r\nHS_ZONE=%u", detected_hs_zone);
detected_hs_zone = 10 - detected_zone;
motion_in_hs_zone[detected_hs_zone][(motion_detected_count)]++;
sts_motion_dataset[motion_count].presence_distance = 1000*result.presence_distance;
sts_motion_dataset[motion_count].presence_score = 1000*result.presence_score;
APP_LOG(TS_OFF, VLEVEL_H, "Failed to activate detector \n");
return false;
}
acc_detector_presence_configuration_destroy(&presence_configuration);
// set to full length of iteration
for (int i = 0; i < (iterations/2); i++)
{
success = acc_detector_presence_get_next(handle, &result);
if (!success)
{
APP_LOG(TS_OFF, VLEVEL_H,"acc_detector_presence_get_next() failed\n");
break;
}
motion_count++;
if (!result.data_saturated)
{
//APP_LOG(TS_OFF, VLEVEL_H,"\n%u ", i);
//print_result(result);
if (result.presence_detected)
{
//print_result(result);
average_result++;
average_distance += result.presence_distance;
average_score += result.presence_score;
//detected_zone = (uint16_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH);
// 2024-08-05
detected_zone = (uint16_t)((float)(result.presence_distance) / (float)DEFAULT_ZONE_LENGTH);
motion_in_zone[detected_zone]++;
// new add 2024-06-18
//detected_hs_zone = (uint16_t)((float)(sts_sensor_install_height/1000.0f - (result.presence_distance))/(float)DEFAULT_ZONE_LENGTH);
//if (detected_hs_zone == 0)
//APP_LOG(TS_OFF, VLEVEL_L, "\r\nPresence_Distance=%u \r\n", (int)result.presence_distance*1000.0);
//APP_LOG(TS_OFF, VLEVEL_L, "\r\nHS_ZONE=%u", detected_hs_zone);
detected_hs_zone = 10 - detected_zone;
motion_in_hs_zone[detected_hs_zone][(motion_detected_count)]++;
sts_motion_dataset[motion_count].presence_distance = 1000*result.presence_distance;
sts_motion_dataset[motion_count].presence_score = 1000*result.presence_score;
motion_count++;
}
}
//acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // 15 ms, DEFAULT_UPDATE_RATE);
//acc_integration_sleep_ms(1);
}
}
APP_LOG(TS_OFF, VLEVEL_H, "\r\n Second Half --- Motion Count Sum to = %u \r\n", 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
sts_fall_rising_detected_result = STS_PRESENCE_NORMAL;
if ((sts_presence_fall_detection == TRUE)&& (motion_count>10))
STS_YunhornCheckStandardDeviation();
//acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // 15 ms, DEFAULT_UPDATE_RATE);
//acc_integration_sleep_ms(1);
}
APP_LOG(TS_OFF, VLEVEL_H, "\r\n Second Half --- Motion Count Sum to = %u \r\n", 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
sts_fall_rising_detected_result = STS_PRESENCE_NORMAL;
if ((sts_presence_fall_detection == TRUE)&& (motion_count>10))
STS_YunhornCheckStandardDeviation();
// RSS feature 1: Motion, No-motion process
sts_rss_result = (average_result > 3)? 1: 0;
APP_LOG(TS_OFF, VLEVEL_H, "\r\n MotionDetect Average result=%u : RSS result -- = %u \r\n", average_result, sts_rss_result);
@ -555,6 +561,7 @@ int sts_presence_rss_fall_rise_detection(void)
{
LED1_ON;
OnSensorRSS3BStateChanged();
sts_fall_rising_detected_result_changed_flag = sts_fall_rising_detected_result;
} else {
LED1_OFF;
@ -641,7 +648,7 @@ void STS_YunhornCheckStandardDeviation(void)
uint32_t standard_variance_presence_distance = 0, standard_variance_presence_score=0;
// ROC -- rate of change
uint32_t roc_distance[DEFAULT_MOTION_DATASET_LEN]={0}, sum_roc_distance=0, average_roc_distance=0, variance_roc_distance=0, standard_variance_roc_distance=0;
uint32_t roc_acc[DEFAULT_MOTION_DATASET_LEN]={0}, sum_roc_acc=0.0f, average_roc_acc=0.0f, variance_roc_acc=0.0f, standard_variance_roc_acc=0.0f;;
uint32_t roc_acc[DEFAULT_MOTION_DATASET_LEN]={0}, sum_roc_acc=0, average_roc_acc=0, variance_roc_acc=0, standard_variance_roc_acc=0;
//act as speed of change at given time slot acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE);
uint8_t SAMPLE_DATASET_NUM = MIN(motion_count,DEFAULT_MOTION_DATASET_LEN );
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Sample dataset for deviation process =%u \r\n",SAMPLE_DATASET_NUM);
@ -659,18 +666,18 @@ void STS_YunhornCheckStandardDeviation(void)
average_presence_distance = ((uint32_t)sum_presence_distance/(uint32_t)(SAMPLE_DATASET_NUM));
average_presence_score = ((uint32_t)sum_presence_score/(uint32_t)(SAMPLE_DATASET_NUM));
// 1) VARIANCE
// 1) VARIANCE^2
for (j = 0; j < SAMPLE_DATASET_NUM; j++)
{
variance_presence_distance += (uint32_t)pow(sts_motion_dataset[j].presence_distance - average_presence_distance,2)/(SAMPLE_DATASET_NUM-1);
variance_presence_score += (uint32_t)pow(sts_motion_dataset[j].presence_score - average_presence_score,2)/(SAMPLE_DATASET_NUM-1);
sum_presence_distance += (uint32_t)pow(sts_motion_dataset[j].presence_distance - average_presence_distance,2);
sum_presence_score += (uint32_t)pow(sts_motion_dataset[j].presence_score - average_presence_score,2);
}
//variance_presence_distance /= (uint32_t)(SAMPLE_DATASET_NUM-1);
//variance_presence_score /= (uint32_t)(SAMPLE_DATASET_NUM-1);
variance_presence_distance =sum_presence_distance/(uint32_t)(SAMPLE_DATASET_NUM-1);
variance_presence_score =sum_presence_score/(uint32_t)(SAMPLE_DATASET_NUM-1);
//STANDARD VARIANCE sigma
standard_variance_presence_distance = (uint32_t)sqrt(variance_presence_distance);
standard_variance_presence_score = (uint32_t)sqrt(variance_presence_score);
standard_variance_presence_distance = (uint32_t)sqrt(sum_presence_distance/SAMPLE_DATASET_NUM);
standard_variance_presence_score = (uint32_t)sqrt(sum_presence_score/SAMPLE_DATASET_NUM);
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Standard Variance_Presence_Distance=%u \r\n Standard Variance Presence Score=%u\r\n",
standard_variance_presence_distance, standard_variance_presence_score);
@ -686,13 +693,13 @@ void STS_YunhornCheckStandardDeviation(void)
for (j = 0; j < (SAMPLE_DATASET_NUM-1); j++)
{
variance_roc_distance += (uint32_t)(pow(roc_distance[j] - average_roc_distance,2)/SAMPLE_DATASET_NUM);
sum_roc_distance += (uint32_t)(pow(roc_distance[j] - average_roc_distance,2));
}
// average
//variance_roc_distance /= (uint32_t)(SAMPLE_DATASET_NUM);
variance_roc_distance =sum_roc_distance/(uint32_t)(SAMPLE_DATASET_NUM-2);
//????
standard_variance_roc_distance = (uint32_t)sqrt((uint32_t)variance_roc_distance);
standard_variance_roc_distance = (uint32_t)sqrt((uint32_t)variance_roc_distance)/(SAMPLE_DATASET_NUM-1);
// ROC Acceleration
@ -703,16 +710,16 @@ void STS_YunhornCheckStandardDeviation(void)
sum_roc_acc += ((uint32_t)roc_acc[i]);
}
average_roc_acc = (uint32_t)sum_roc_acc/(SAMPLE_DATASET_NUM-2);
average_roc_acc = (uint32_t)sum_roc_acc/(SAMPLE_DATASET_NUM-3);
for (j = 0; j < (SAMPLE_DATASET_NUM-2); j++)
for (j = 0; j < (SAMPLE_DATASET_NUM-3); j++)
{
variance_roc_acc += (uint32_t)pow((uint32_t)((uint32_t)roc_acc[j] - (uint32_t)average_roc_acc),2)/(SAMPLE_DATASET_NUM-1);
sum_roc_acc += (uint32_t)pow((uint32_t)((uint32_t)roc_acc[j] - (uint32_t)average_roc_acc),2);
}
//variance_roc_acc /= (uint32_t)(SAMPLE_DATASET_NUM-1);
variance_roc_acc = sum_roc_acc/(uint32_t)(SAMPLE_DATASET_NUM-4);
standard_variance_roc_acc = (uint32_t)sqrt((uint32_t)variance_roc_acc);
standard_variance_roc_acc = (uint32_t)sqrt((uint32_t)sum_roc_acc)/(SAMPLE_DATASET_NUM-3);
//Normallize to m/s --- * DEFAULT_MOTION_DATASET_LEN for One single second
#if 0
@ -726,33 +733,38 @@ void STS_YunhornCheckStandardDeviation(void)
#endif
// print result
//#ifdef LOG_RSS
APP_LOG(TS_OFF, VLEVEL_M, "\r\n---Sensor Install Height=%6u-----\r\n-------------Distance Average =%6u; Standard_Variance =%6u \r\n",
APP_LOG(TS_OFF, VLEVEL_M, "\r\n---Sensor Install Height=%4u (mm)-----\r\n-------------Distance Average =%6u (mm); Standard_Variance =%04u (mm)\r\n",
(int)sts_sensor_install_height, (int)(average_presence_distance), (int)(standard_variance_presence_distance));
//#endif
//#ifdef LOG_RSS
APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n-------------Motion Average =%6u; Standard_Variance =%6u \r\n",
APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n-------------Motion Average (score)=%04u; Standard_Variance (score)=%04u \r\n",
(int)(average_presence_score), (int)(standard_variance_presence_score));
//#endif
//#ifdef LOG_RSS
APP_LOG(TS_OFF, VLEVEL_M, "\r\n-------------ROC Dist Average =%6u; Standard_Variance =%6u \r\n",
APP_LOG(TS_OFF, VLEVEL_M, "\r\n-------------ROC Dist Average (mm/s) =%6u; Standard_Variance =%6u (mm/s)\r\n",
(int)(average_roc_distance), (int)(standard_variance_roc_distance));
APP_LOG(TS_OFF, VLEVEL_M, "\r\n-------------ROC ACC Average =%6u; Standard_Variance =%6u \r\n",
APP_LOG(TS_OFF, VLEVEL_M, "\r\n-------------ROC ACC Average =%6u (mm/s2); Standard_Variance =%6u (mm/s2)\r\n",
(int)(average_roc_acc), (int)(standard_variance_roc_acc));
//sts_fall_rising_pattern_factor1 = (int)(standard_variance_roc_distance);
sts_fall_rising_pattern_factor1 = (int)(average_roc_distance);
sts_fall_rising_pattern_factor2 = (int)(fabs(average_presence_distance - last_average_presence_distance));
if (last_average_presence_distance >0)
sts_fall_rising_pattern_factor2 = (uint16_t)(abs((uint16_t)average_presence_distance - (uint16_t)last_average_presence_distance));
//sts_fall_rising_pattern_factor2 = (uint16_t)(abs((uint16_t)average_presence_distance - (uint16_t)sts_sensor_install_height));
//APP_LOG(TS_OFF, VLEVEL_M, "\r\n*************** factor2=%6u ---- average_distance=%6u ----install height=%6u\r\n", sts_fall_rising_pattern_factor2,average_presence_distance,sts_sensor_install_height )
sts_fall_rising_pattern_factor3 = (int)(standard_variance_presence_score);
APP_LOG(TS_OFF, VLEVEL_L,"\r\nAvg-Dist =%6u, Last_AVG-Dist =%6u \r\n", (int)(average_presence_distance), (int)(last_average_presence_distance));
APP_LOG(TS_OFF, VLEVEL_L,"\r\nStandard Variance Presence_score=%u \r\n", (int)(standard_variance_presence_score));
APP_LOG(TS_OFF, VLEVEL_L,"\r\nAvg-Dist =%6u (mm), Last_AVG-Dist =%6u (mm)\r\n", (int)(average_presence_distance), (int)(last_average_presence_distance));
APP_LOG(TS_OFF, VLEVEL_L,"\r\nStandard Variance Presence_score =%u (score)\r\n", (int)(standard_variance_presence_score));
APP_LOG(TS_OFF, VLEVEL_M, "\r\nThreshold 1: Acc = %6u ---- Measure 1 = %6u ---- \r\n",
(int)(sts_fall_detection_acc_threshold), (int)(sts_fall_rising_pattern_factor1/10));
APP_LOG(TS_OFF, VLEVEL_M, "\r\nThreshold 1: Acc = %6u (mm/s) ---- Measure 1 = %6u (mm/s)---- \r\n",
(int)(sts_fall_detection_acc_threshold), (int)(sts_fall_rising_pattern_factor1));
APP_LOG(TS_OFF, VLEVEL_M, "\r\nThreshold 2: Dis = %6u cm --- Measure 2 = %6u cm ---- \r\n",
APP_LOG(TS_OFF, VLEVEL_M, "\r\nThreshold 2: Dis = %6u (cm) --- Measure 2 = %6u (cm) ---- \r\n",
(int)(sts_fall_detection_depth_threshold), (int)(sts_fall_rising_pattern_factor2/10));
APP_LOG(TS_OFF, VLEVEL_M, "\r\nMeasure 3 = %6u (score) ---- \r\n", (int)(sts_fall_rising_pattern_factor3));
//#endif
// *******************************************
@ -779,7 +791,7 @@ void STS_YunhornCheckStandardDeviation(void)
// Considering factor #2 --- fall down depth, say > 30 cm 40 cm in given factor 1 time unit
//
if ((sts_fall_rising_pattern_factor2 > sts_fall_detection_depth_threshold ) && (average_presence_distance > 1000*DEFAULT_START_M))
if ((sts_fall_rising_pattern_factor2 > (sts_fall_detection_depth_threshold*10) ) && (average_presence_distance > 1000*DEFAULT_START_M))
{
sts_fall_rising_detected_result = STS_PRESENCE_FALL;
//last_sts_fall_rising_detected_result = sts_fall_rising_detected_result;

View File

@ -273,7 +273,7 @@ void STS_YunhornSTSEventP2_Process(void)
//STS_Lamp_Bar_Refresh(); //TODO XXX eliminate refresh every second.... try
if ((sts_work_mode >= STS_RSS_MODE) && (sts_work_mode <= STS_TOF_RSS_MODE))
{
if (sts_presence_fall_detection == TRUE) {
if (sts_presence_fall_detection == FALSE) { // otherwise, has been set to full/simple/etc.
sts_rss_config_updated_flag = STS_RSS_CONFIG_FALL_DETECTION;
}
sts_presence_rss_fall_rise_detection();
@ -283,7 +283,7 @@ void STS_YunhornSTSEventP2_Process(void)
last_sts_rss_result = sts_rss_result;
//sts_fall_rising_detected_result_changed_flag = (sts_fall_rising_detected_result == last_sts_fall_rising_detected_result)?0:1;
sts_fall_rising_detected_result_changed_flag = (sts_fall_rising_detected_result != last_sts_fall_rising_detected_result)?1:0;
//sts_fall_rising_detected_result_changed_flag = (sts_fall_rising_detected_result != last_sts_fall_rising_detected_result)?1:0;
last_sts_fall_rising_detected_result = sts_fall_rising_detected_result;
@ -657,7 +657,7 @@ void STS_Combined_Status_Processing(void)
}
if ((sts_rss_result_changed_flag))//|| (sts_reed_hall_changed_flag)||(sts_fall_rising_detected_result_changed_flag))
if ((sts_rss_result_changed_flag)|| (sts_reed_hall_changed_flag)||(sts_fall_rising_detected_result_changed_flag))
{
//sts_rss_result_changed_flag =0;
//sts_reed_hall_changed_flag =0;

View File

@ -2527,7 +2527,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size)
UTIL_MEM_set_8((void*)outbuf, 0x0, sizeof(outbuf));
UTIL_MEM_cpy_8((void*)outbuf,(void*)tlv_buf, tlv_buf_size);
i = tlv_buf_size;
APP_LOG(TS_OFF, VLEVEL_L, "###### RSS Full CFG=%s\r\n",(char *)outbuf);
APP_LOG(TS_OFF, VLEVEL_M, "###### RSS Full CFG=%s\r\n",(char *)outbuf);
// Step 2: Save valid config to NVM
sts_cfg_nvm.mtmcode1 = sts_mtmcode1;