This commit is contained in:
Yunhorn 2025-04-14 12:50:15 +08:00
parent a3d9717e9a
commit cebc42f735
5 changed files with 75 additions and 7 deletions

View File

@ -373,7 +373,7 @@ typedef struct STS_OO_RSS_SensorTuneDataTypeDef
float default_downsampling_factor; //[2](2) //default 1 float default_downsampling_factor; //[2](2) //default 1
float default_receiver_gain; //[45](0.45f) //default 0.9 gain mdB [4] float default_receiver_gain; //[45](0.45f) //default 0.9 gain mdB [4]
uint8_t config_update_flag; // 1,2,3,4,5 uint8_t default_config_update_flag; // 1,2,3,4,5
} STS_OO_RSS_SensorTuneDataTypeDef; } STS_OO_RSS_SensorTuneDataTypeDef;
@ -775,7 +775,9 @@ void STS_Sensor_Init(void);
void STS_Sensor_Prepare(void); void STS_Sensor_Prepare(void);
float KalmanFilter(float inData); float KalmanFilter(float inData);
uint8_t STS_RSS_Filter(uint8_t pre_sts_rss_result); #define PRESET_NUMERATOR 5
#define PRESET_DENOMINATOR 8
void STS_RSS_Filter(uint8_t pre_sts_rss_result);
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
/* /*
In this example TIM2 input clock (TIM2CLK) is set to APB1 clock (PCLK1), In this example TIM2 input clock (TIM2CLK) is set to APB1 clock (PCLK1),

View File

@ -694,7 +694,7 @@ int sts_presence_rss_fall_rise_detection(void)
} else { } else {
pre_sts_rss_result = (average_result > 0)? 1: 0; pre_sts_rss_result = (average_result > 0)? 1: 0;
} }
sts_rss_result = STS_RSS_Filter(pre_sts_rss_result); 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\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",

View File

@ -117,6 +117,7 @@ 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_rss_2nd_result = STS_RESULT_NO_MOTION; //2nd RSS sensor status
volatile uint8_t sts_tof_result = STS_RESULT_NO_MOTION; 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_NO_MOTION;
_Bool Motion_Flag = 0;
//extern volatile uint8_t last_sts_reed_hall_result; //extern volatile uint8_t last_sts_reed_hall_result;
extern volatile uint8_t last_lamp_bar_color; extern volatile uint8_t last_lamp_bar_color;
@ -762,6 +763,8 @@ void STS_PRESENCE_SENSOR_NVM_CFG(void)
// sts_rss_config_updated_flag = (sts_rss_config_updated_flag|STS_RSS_CONFIG_FULL); //set to 2 for FULL config effect in next detection // sts_rss_config_updated_flag = (sts_rss_config_updated_flag|STS_RSS_CONFIG_FULL); //set to 2 for FULL config effect in next detection
sts_rss_config_updated_flag = (STS_RSS_CONFIG_FULL); //set to 2 for FULL config effect in next detection 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]);
} }
void STS_PRESENCE_SENSOR_NVM_CFG_SIMPLE(void) void STS_PRESENCE_SENSOR_NVM_CFG_SIMPLE(void)
@ -781,6 +784,8 @@ void STS_PRESENCE_SENSOR_NVM_CFG_SIMPLE(void)
// sts_rss_config_updated_flag = (sts_rss_config_updated_flag|STS_RSS_CONFIG_SIMPLE); //set to 1 for simple config effect in next detection // sts_rss_config_updated_flag = (sts_rss_config_updated_flag|STS_RSS_CONFIG_SIMPLE); //set to 1 for simple config effect in next detection
sts_rss_config_updated_flag = (STS_RSS_CONFIG_SIMPLE); //set to 1 for simple config effect in next detection 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]);
} }
void STS_PRESENCE_SENSOR_Init_Send_Data(void) void STS_PRESENCE_SENSOR_Init_Send_Data(void)
@ -1541,10 +1546,71 @@ uint8_t STS_RSS_Filter(uint8_t pre_sts_rss_result)
} }
#endif #endif
#define FILTER_LEN 8
#define SLIDING_WIN_LEN 5
static uint8_t motion_read[FILTER_LEN]={0};
static uint8_t idx_filter=0;
void STS_RSS_Filter(uint8_t pre_sts_rss_result)
{
_Bool pNew_Motion_Flag = 0;
static uint8_t Motion_Changed_Flag = 1;
static uint8_t numerator = PRESET_NUMERATOR;
static uint8_t denominator = PRESET_DENOMINATOR;
pNew_Motion_Flag = pre_sts_rss_result;
if(pNew_Motion_Flag != Motion_Flag)
{
Motion_Changed_Flag = 1;
}
if(Motion_Changed_Flag == 1)
{
denominator++;
if(pNew_Motion_Flag != Motion_Flag){
numerator++;
}
if(denominator >= PRESET_DENOMINATOR)
{
if(numerator >= PRESET_NUMERATOR) //的确改变
{
Motion_Flag = !Motion_Flag;
if(Motion_Flag)
{
//M100C_Send_Data(10,0,ZhanYong);
//*color = 2;
sts_rss_result = STS_RESULT_MOTION;
}
else
{
//M100C_Send_Data(10,0,KeYong);
//*color = 1;
sts_rss_result = STS_RESULT_NO_MOTION;
}
}
denominator = 0;
numerator = 0;
Motion_Changed_Flag = 0;
}
}
}
#if 0
#define FILTER_LEN 8 #define FILTER_LEN 8
#define SLIDING_WIN_LEN 3 #define SLIDING_WIN_LEN 3
static uint8_t motion_read[FILTER_LEN]={0}; static uint8_t motion_read[FILTER_LEN]={0};
static uint8_t idx_filter=0; static uint8_t idx_filter=0;
uint8_t STS_RSS_Filter(uint8_t pre_sts_rss_result) uint8_t STS_RSS_Filter(uint8_t pre_sts_rss_result)
{ {
uint8_t j=0; uint8_t j=0;
@ -1580,7 +1646,7 @@ uint8_t STS_RSS_Filter(uint8_t pre_sts_rss_result)
return ((sum_sliding_win>=3))? 1:0; return ((sum_sliding_win>=3))? 1:0;
} }
#endif
/* USER CODE BEGIN EF */ /* USER CODE BEGIN EF */

View File

@ -121,9 +121,9 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
0x09, //output time const 0x05=[5]*0.1=0.5 0.5--> 0.9 2025-03-26 TODO XXXXXX 0x09, //output time const 0x05=[5]*0.1=0.5 0.5--> 0.9 2025-03-26 TODO XXXXXX
0x02, //downsampling factor [2]=2 0x02, //downsampling factor [2]=2
0x03, //power saving mode ACTIVE [3] = 3U 0x03, //power saving mode ACTIVE [3] = 3U
0x00, //reserve --P[17] 0x01, //reserve --P[17] RSS CFG UPDATE FLAG 2025-04-14
0x00, //reserve --P[18] 0x00, //reserve --P[18] RESERVE1
0x00, //reserve --P[19] 0x00, //reserve --P[19] RESERVE2
}, // above 20 bytes }, // above 20 bytes
0x00, //reserve2 0x00, //reserve2
0x00, //reserve3 0x00, //reserve3

Binary file not shown.