diff --git a/Core/Inc/yunhorn_sts_sensors.h b/Core/Inc/yunhorn_sts_sensors.h index 8a69fe3..a5f1aee 100644 --- a/Core/Inc/yunhorn_sts_sensors.h +++ b/Core/Inc/yunhorn_sts_sensors.h @@ -655,6 +655,7 @@ void OnSensor2StateChanged(void); void OnSensor3StateChanged(void); void OnSensor3AStateChanged(void); void OnSensor3BStateChanged(void); +void OnSensor3CStateChanged(void); void OnSensor4StateChanged(void); void STS_SENSOR_Power_ON(uint8_t cnt); diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index cd91901..4366f06 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -415,7 +415,7 @@ int sts_presence_rss_fall_rise_detection(void) } print_result(result); - //if (!result.data_saturated) + if (!result.data_saturated) { if (result.presence_detected) { @@ -425,10 +425,11 @@ int sts_presence_rss_fall_rise_detection(void) detected_zone = (uint16_t)((float)(result.presence_distance - DEFAULT_START_M) / (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); - + //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 = 6 - detected_zone; motion_in_hs_zone[detected_hs_zone][(motion_detected_count)]++; } @@ -497,9 +498,12 @@ int sts_presence_rss_fall_rise_detection(void) detected_zone = (uint16_t)((float)(result.presence_distance - DEFAULT_START_M) / (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); + //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 = 6 - detected_zone; motion_in_hs_zone[detected_hs_zone][(motion_detected_count)]++; } @@ -559,7 +563,7 @@ int sts_presence_rss_fall_rise_detection(void) -#ifndef LOG_RSS +#ifdef LOG_RSS APP_LOG(TS_OFF, VLEVEL_L,"\r\nSensor at Ceiling Height: %4u mm\r\n",(int)sts_sensor_install_height); for (uint8_t k=0; k<12; k++) { diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 0c626e6..7294abe 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -89,6 +89,10 @@ volatile STS_R0_SensorDataTypeDef r4_data; #endif #if defined(STS_O7)||defined(STS_O6) +extern volatile uint8_t motion_detected_count; +extern volatile uint8_t motion_in_hs_zone[12][10]; //0.4*12=4.8meter high, past 10 measures +extern volatile uint8_t detected_hs_zone; + extern volatile STS_OO_RSS_SensorTuneDataTypeDef sts_presence_rss_config; volatile uint32_t cnt=0; extern volatile distance_measure_cfg_t distance_cfg; @@ -973,6 +977,31 @@ void OnSensor3BStateChanged(void) } +/* motion sensor RSS ON-OFF */ +void OnSensor3CStateChanged(void) +{ + SysTime_t sensor_event_time = SysTimeGetMcuTime(); +#if 0 + if ((sensor_event_time.Seconds - last_sts_rss_time_stamp) < 3 ) //less than 3 seconds ... return for flipping filter + { + return ; + } +#endif + if (sts_rss_result == STS_RESULT_MOTION) + { + sts_o7_sensorData.event_sensor3_motion_start_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor3_motion_duration = 0; + } else if (sts_rss_result == STS_RESULT_NO_MOTION) + { + sts_o7_sensorData.event_sensor3_motion_stop_time = sensor_event_time.Seconds; + //sts_o7_sensorData.event_sensor3_motion_duration = 0; + } + + + last_sts_rss_time_stamp = sensor_event_time.Seconds; + +} + void OnSensor4StateChanged(void) {