RM2_1 #2

Merged
sundp merged 208 commits from RM2_1 into master 2024-09-13 09:16:14 +08:00
3 changed files with 30 additions and 7 deletions
Showing only changes of commit d77e2e47bc - Show all commits

View File

@ -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 //extern volatile uint8_t last_sts_reed_hall_result = 2; //Initial state, not 0, not 1
volatile uint8_t last_lamp_bar_color; volatile uint8_t last_lamp_bar_color;
extern volatile uint8_t sts_presence_fall_detection; 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 float sts_presence_rss_distance;
extern volatile uint8_t sensor_data_ready; extern volatile uint8_t sensor_data_ready;
extern SysTime_t mems_event_time; 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 )) } 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; 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 ) { if (sts_reed_hall_2_result == STS_Status_Door_Close ) {
sts_status_color = STS_RED_BLUE; sts_status_color = STS_RED_BLUE;
} }

View File

@ -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 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]; 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 = 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 uint8_t last_sts_fall_rising_detected_result= STS_PRESENCE_NONE;
volatile float last_average_presence_distance; volatile float last_average_presence_distance;
volatile uint16_t sts_fall_rising_pattern_factor1=0, sts_fall_rising_pattern_factor2=0; 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; last_average_presence_distance = average_presence_distance;
#if 0
if (sts_fall_rising_detected_result != STS_PRESENCE_NONE) if (sts_fall_rising_detected_result != STS_PRESENCE_NONE)
{ {
STS_FallDetection_LampBarProcess(); STS_FallDetection_LampBarProcess();
} }
#endif
} }

View File

@ -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_OO_RSS_SensorTuneDataTypeDef sts_presence_rss_config;
extern volatile sts_cfg_nvm_t sts_cfg_nvm; 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_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 uint8_t sts_unconcious_state;
extern volatile uint16_t sts_unconcious_threshold, sts_unconcious_duration; 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; 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; sts_rss_result_changed_flag = (sts_rss_result == last_sts_rss_result)? 0:1;
last_sts_rss_result = sts_rss_result; 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 ) { if (sts_service_mask > 0 ) {
sts_rss_result_changed_flag =0; sts_rss_result_changed_flag =0;
sts_reed_hall_changed_flag = 0; sts_reed_hall_changed_flag = 0;
sts_fall_rising_detected_result_changed_flag =0;
} }
STS_Combined_Status_Processing(); STS_Combined_Status_Processing();
@ -546,6 +552,7 @@ void STS_PRESENCE_SENSOR_After_Wake_Up()
void STS_FallDetection_LampBarProcess(void) void STS_FallDetection_LampBarProcess(void)
{ {
#if 0
char buf[32]={0x0}; char buf[32]={0x0};
uint8_t i=0; uint8_t i=0;
switch (sts_fall_rising_detected_result) switch (sts_fall_rising_detected_result)
@ -555,18 +562,18 @@ void STS_FallDetection_LampBarProcess(void)
sts_status_color = STS_YELLOW; sts_status_color = STS_YELLOW;
sts_rss_result = STS_RESULT_MOTION; sts_rss_result = STS_RESULT_MOTION;
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); 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_lamp_bar_color;
buf[i++] = (uint8_t)sts_work_mode; buf[i++] = (uint8_t)sts_work_mode;
buf[i++] = (uint8_t)sts_fall_rising_detected_result; buf[i++] = (uint8_t)sts_fall_rising_detected_result;
#endif
break; break;
case STS_PRESENCE_FALL: case STS_PRESENCE_FALL:
sts_lamp_bar_color = STS_BLUE; //STS_RED_BLUE; sts_lamp_bar_color = STS_BLUE; //STS_RED_BLUE;
sts_status_color = STS_BLUE; //STS_RED_BLUE; sts_status_color = STS_BLUE; //STS_RED_BLUE;
sts_rss_result = STS_RESULT_MOTION; sts_rss_result = STS_RESULT_MOTION;
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); 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_lamp_bar_color;
buf[i++] = (uint8_t)sts_work_mode; buf[i++] = (uint8_t)sts_work_mode;
buf[i++] = (uint8_t)sts_fall_rising_detected_result; 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_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;
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; break;
case STS_PRESENCE_RISING: case STS_PRESENCE_RISING:
@ -582,6 +590,7 @@ void STS_FallDetection_LampBarProcess(void)
sts_status_color = STS_RED; // normal occupancy status sts_status_color = STS_RED; // normal occupancy status
sts_rss_result = STS_RESULT_MOTION; sts_rss_result = STS_RESULT_MOTION;
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); 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_lamp_bar_color;
buf[i++] = (uint8_t)sts_work_mode; buf[i++] = (uint8_t)sts_work_mode;
buf[i++] = (uint8_t)sts_fall_rising_detected_result; 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_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;
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; break;
default: default:
break; break;
} }
#if 0
APP_LOG(TS_OFF, VLEVEL_L, "\r\n <<<<<<<<<<<<<< Fall Rise state=%25s, send buf size = %d \r\n", 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_presence_fall_detection_message[sts_fall_rising_detected_result], i )
STS_SENSOR_Upload_Message((LORAWAN_USER_APP_PORT+2), i, (char*)buf); STS_SENSOR_Upload_Message((LORAWAN_USER_APP_PORT+2), i, (char*)buf);
sts_fall_rising_detected_result = STS_PRESENCE_NONE; sts_fall_rising_detected_result = STS_PRESENCE_NONE;
#endif
#endif
} }
void STS_YunhornSTSFallDetection(void) void STS_YunhornSTSFallDetection(void)