From d77e2e47bc6183014d6aad71993fcde8986db278 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Sun, 12 May 2024 18:43:48 +0800 Subject: [PATCH] remove unused code for fall_rising detection result process --- Core/Src/sts_lamp_bar.c | 11 +++++++++++ Core/Src/yunhorn_sts_presence_rss.c | 5 +++-- Core/Src/yunhorn_sts_process.c | 21 ++++++++++++++++----- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Core/Src/sts_lamp_bar.c b/Core/Src/sts_lamp_bar.c index 1cf2ebc..b633d32 100644 --- a/Core/Src/sts_lamp_bar.c +++ b/Core/Src/sts_lamp_bar.c @@ -76,6 +76,7 @@ extern volatile uint8_t sts_tof_result; //extern volatile uint8_t last_sts_reed_hall_result = 2; //Initial state, not 0, not 1 volatile uint8_t last_lamp_bar_color; extern volatile uint8_t sts_presence_fall_detection; +extern volatile uint8_t sts_fall_rising_detected_result; extern volatile float sts_presence_rss_distance; extern volatile uint8_t sensor_data_ready; extern SysTime_t mems_event_time; @@ -287,6 +288,16 @@ void STS_Combined_Status_Processing(void) } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_1_result == STS_Status_Door_Close )||(sts_reed_hall_2_result == STS_Status_Door_Close )) { sts_status_color = STS_RED; + if (sts_fall_rising_detected_result == STS_PRESENCE_LAYDOWN) { + sts_lamp_bar_color = STS_YELLOW; + sts_status_color = STS_YELLOW; + } else if (sts_fall_rising_detected_result == STS_PRESENCE_FALL){ //RED_BLUE FLASH + sts_lamp_bar_color = STS_RED_BLUE; + sts_status_color = STS_RED_BLUE; + } else if (sts_fall_rising_detected_result == STS_PRESENCE_RISING) { //NORMAL OCCUPANCY STATUS + sts_lamp_bar_color = STS_RED; + sts_status_color = STS_RED; + } if (sts_reed_hall_2_result == STS_Status_Door_Close ) { sts_status_color = STS_RED_BLUE; } diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index 8ce5d15..726b2fc 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -95,6 +95,7 @@ volatile uint16_t motion_count, motion_feature_count; static acc_detector_presence_result_t sts_motion_dataset[DEFAULT_MOTION_DATASET_LEN]; static STS_PRESENCE_Motion_Featuer_t sts_motion_feature[DEFAULT_MOTION_FEATURE_LEN]; volatile uint8_t sts_fall_rising_detected_result = STS_PRESENCE_NONE; +volatile uint8_t sts_fall_rising_detected_result_changed_flag =0; volatile uint8_t last_sts_fall_rising_detected_result= STS_PRESENCE_NONE; volatile float last_average_presence_distance; volatile uint16_t sts_fall_rising_pattern_factor1=0, sts_fall_rising_pattern_factor2=0; @@ -674,12 +675,12 @@ void STS_YunhornCheckStandardDeviation(void) } last_average_presence_distance = average_presence_distance; - +#if 0 if (sts_fall_rising_detected_result != STS_PRESENCE_NONE) { STS_FallDetection_LampBarProcess(); } - +#endif } diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index ae22236..e6e9312 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -60,6 +60,8 @@ extern volatile uint8_t sts_occupancy_overtime_state; extern volatile STS_OO_RSS_SensorTuneDataTypeDef sts_presence_rss_config; extern volatile sts_cfg_nvm_t sts_cfg_nvm; extern volatile uint8_t sts_fall_detection_acc_threshold, sts_fall_detection_depth_threshold, sts_occupancy_overtime_threshold; +extern volatile uint8_t sts_fall_rising_detected_result_changed_flag; +extern volatile uint8_t last_sts_fall_rising_detected_result; extern volatile uint8_t sts_unconcious_state; extern volatile uint16_t sts_unconcious_threshold, sts_unconcious_duration; extern volatile uint8_t sts_emergency_button_pushed, sts_rss_2nd_result,sts_tof_result, sts_status_color, sts_lamp_bar_color, sts_service_mask; @@ -240,9 +242,13 @@ void STS_YunhornSTSEventP2_Process(void) sts_rss_result_changed_flag = (sts_rss_result == last_sts_rss_result)? 0:1; 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; + last_sts_fall_rising_detected_result = sts_fall_rising_detected_result; + if (sts_service_mask > 0 ) { sts_rss_result_changed_flag =0; sts_reed_hall_changed_flag = 0; + sts_fall_rising_detected_result_changed_flag =0; } STS_Combined_Status_Processing(); @@ -546,6 +552,7 @@ void STS_PRESENCE_SENSOR_After_Wake_Up() void STS_FallDetection_LampBarProcess(void) { +#if 0 char buf[32]={0x0}; uint8_t i=0; switch (sts_fall_rising_detected_result) @@ -555,18 +562,18 @@ void STS_FallDetection_LampBarProcess(void) sts_status_color = STS_YELLOW; sts_rss_result = STS_RESULT_MOTION; STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); - +#if 0 buf[i++] = (uint8_t)sts_lamp_bar_color; buf[i++] = (uint8_t)sts_work_mode; buf[i++] = (uint8_t)sts_fall_rising_detected_result; - +#endif break; case STS_PRESENCE_FALL: sts_lamp_bar_color = STS_BLUE; //STS_RED_BLUE; sts_status_color = STS_BLUE; //STS_RED_BLUE; sts_rss_result = STS_RESULT_MOTION; STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); - +#if 0 buf[i++] = (uint8_t)sts_lamp_bar_color; buf[i++] = (uint8_t)sts_work_mode; buf[i++] = (uint8_t)sts_fall_rising_detected_result; @@ -575,6 +582,7 @@ void STS_FallDetection_LampBarProcess(void) buf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1%10 + 0x30)&0xFF; buf[i++] = (uint8_t)(sts_roc_acc_standard_variance/10 + 0x30)&0xFF; buf[i++] = (uint8_t)(sts_roc_acc_standard_variance%10 + 0x30)&0xFF; +#endif break; case STS_PRESENCE_RISING: @@ -582,6 +590,7 @@ void STS_FallDetection_LampBarProcess(void) sts_status_color = STS_RED; // normal occupancy status sts_rss_result = STS_RESULT_MOTION; STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); +#if 0 buf[i++] = (uint8_t)sts_lamp_bar_color; buf[i++] = (uint8_t)sts_work_mode; buf[i++] = (uint8_t)sts_fall_rising_detected_result; @@ -591,19 +600,21 @@ void STS_FallDetection_LampBarProcess(void) buf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1%10 + 0x30)&0xFF; buf[i++] = (uint8_t)(sts_roc_acc_standard_variance/10 + 0x30)&0xFF; buf[i++] = (uint8_t)(sts_roc_acc_standard_variance%10 + 0x30)&0xFF; +#endif break; default: break; } - +#if 0 APP_LOG(TS_OFF, VLEVEL_L, "\r\n <<<<<<<<<<<<<< Fall Rise state=%25s, send buf size = %d \r\n", sts_presence_fall_detection_message[sts_fall_rising_detected_result], i ) STS_SENSOR_Upload_Message((LORAWAN_USER_APP_PORT+2), i, (char*)buf); sts_fall_rising_detected_result = STS_PRESENCE_NONE; - +#endif +#endif } void STS_YunhornSTSFallDetection(void)