add threshold and window size for sliding window
This commit is contained in:
parent
031899caed
commit
04258d18e3
|
@ -86,7 +86,7 @@ enum RSS_CFG_order{
|
|||
RSS_CFG_POWER_MODE, // 16
|
||||
RSS_CFG_UPDATE_FLAG, // 17 ADD AT 2025-04-11
|
||||
RSS_CFG_BG_MOTION_NOISE, // 18
|
||||
RSS_CFG_RESERVE2, // 19
|
||||
RSS_CFG_SLID_WIN, // 19 THRESHOLD AND WIN
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -832,7 +832,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\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, "\r\nMotion Status: %d %d (mm) %d Rated-> %d \r\n",(int)average_result, (int)average_distance, (int)average_score, (int)sts_rss_result);
|
||||
#if 0
|
||||
if (sts_rss_result) //if (average_score !=0) //if (sts_rss_result)
|
||||
{
|
||||
|
|
|
@ -119,6 +119,9 @@ volatile uint8_t sts_tof_result = STS_RESULT_NO_MOTION;
|
|||
volatile uint8_t last_sts_rss_result=STS_RESULT_NO_MOTION;
|
||||
_Bool Motion_Flag = 0;
|
||||
|
||||
volatile uint8_t sts_rss_cfg_slid_win_threshold=8;
|
||||
volatile uint8_t sts_rss_cfg_slid_win_size=12;
|
||||
|
||||
//extern volatile uint8_t last_sts_reed_hall_result;
|
||||
extern volatile uint8_t last_lamp_bar_color;
|
||||
extern volatile float sts_presence_rss_distance;
|
||||
|
@ -760,6 +763,8 @@ void STS_PRESENCE_SENSOR_NVM_CFG(void)
|
|||
//sts_rss_config_updated_flag = (STS_RSS_CONFIG_FULL); //set to 2 for FULL config effect in next detection
|
||||
//sts_presence_rss_config.default_config_update_flag = (uint8_t) sts_rss_config_updated_flag;
|
||||
sts_rss_config_updated_flag = (uint8_t)(sts_cfg_nvm.p[RSS_CFG_UPDATE_FLAG]);
|
||||
sts_rss_cfg_slid_win_threshold = (uint8_t)(sts_cfg_nvm.p[RSS_CFG_SLID_WIN])>>4;
|
||||
sts_rss_cfg_slid_win_size = (uint8_t)(sts_cfg_nvm.p[RSS_CFG_SLID_WIN])&0x0F;
|
||||
|
||||
APP_LOG(TS_ON, VLEVEL_H, "\r\n##### Reboot --- with NVM CFG'ED RSS flag =%02x \r\n", sts_rss_config_updated_flag);
|
||||
}
|
||||
|
@ -783,6 +788,8 @@ void STS_PRESENCE_SENSOR_NVM_CFG_SIMPLE(void)
|
|||
sts_rss_config_updated_flag = (STS_RSS_CONFIG_SIMPLE); //set to 1 for simple config effect in next detection
|
||||
//sts_presence_rss_config.default_config_update_flag = (uint8_t) sts_rss_config_updated_flag;
|
||||
sts_rss_config_updated_flag = (uint8_t)(sts_cfg_nvm.p[RSS_CFG_UPDATE_FLAG]);
|
||||
sts_rss_cfg_slid_win_threshold = (uint8_t)(sts_cfg_nvm.p[RSS_CFG_SLID_WIN])>>4;
|
||||
sts_rss_cfg_slid_win_size = (uint8_t)(sts_cfg_nvm.p[RSS_CFG_SLID_WIN])&0x0F;
|
||||
}
|
||||
|
||||
void STS_PRESENCE_SENSOR_Init_Send_Data(void)
|
||||
|
@ -1538,8 +1545,10 @@ void Radar_Filtering_clutter(volatile uint8_t *color)
|
|||
#if 1
|
||||
|
||||
#define FILTER_LEN 15
|
||||
#define SLIDING_WIN_LEN 12
|
||||
#define SLIDING_THRESHOLD 8
|
||||
// #define SLIDING_WIN_LEN 12
|
||||
// #define SLIDING_THRESHOLD 8
|
||||
// replaced by sts_rss_cfg_slid_win_threshold and sts_rss_cfg_slid_win_size
|
||||
//
|
||||
static uint8_t motion_read[FILTER_LEN]={0};
|
||||
static uint8_t idx_filter=0;
|
||||
|
||||
|
@ -1552,7 +1561,7 @@ void STS_RSS_Filter(uint8_t pre_sts_rss_result)
|
|||
|
||||
uint8_t sum_filter = 0;
|
||||
uint8_t k=0;
|
||||
for (j=0; j<SLIDING_WIN_LEN; j++)
|
||||
for (j=0; j<sts_rss_cfg_slid_win_size; j++)
|
||||
{
|
||||
|
||||
if ((idx_filter - j) >=0)
|
||||
|
@ -1571,11 +1580,11 @@ void STS_RSS_Filter(uint8_t pre_sts_rss_result)
|
|||
if (sts_rss_result)
|
||||
{
|
||||
//sts_rss_result= ((sum_filter >= SLIDING_THRESHOLD))? 1:0;
|
||||
sts_rss_result= ((sum_filter > (SLIDING_WIN_LEN - SLIDING_THRESHOLD)))? 1:0;
|
||||
|
||||
// sts_rss_result= ((sum_filter > (SLIDING_WIN_LEN - SLIDING_THRESHOLD)))? 1:0;
|
||||
sts_rss_result= ((sum_filter > (sts_rss_cfg_slid_win_size - sts_rss_cfg_slid_win_threshold)))? 1:0;
|
||||
} else {
|
||||
|
||||
sts_rss_result= ((sum_filter > SLIDING_THRESHOLD))? 1:0;
|
||||
sts_rss_result= ((sum_filter > sts_rss_cfg_slid_win_threshold))? 1:0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
|
|||
0x03, //power saving mode ACTIVE [3] = 3U
|
||||
0x02, //P[17] RSS CFG UPDATE FLAG 2025-04-14
|
||||
0x6E, //P[18] RSS_CFG_BG_MOTION_NOISE 2025-04-14
|
||||
0x00, //reserve --P[19] RESERVE2
|
||||
0x8C, //P[19] RSS SLIDING WINDOW CFG: 0x08 AS threshold, 0x0C as window size
|
||||
}, // above 20 bytes
|
||||
0x00, //reserve2
|
||||
0x00, //reserve3
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue