diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c index ecb8e27..851d81b 100644 --- a/STS/Core/Src/yunhorn_sts_process.c +++ b/STS/Core/Src/yunhorn_sts_process.c @@ -2243,6 +2243,56 @@ void YunhornSTSDurationCheckTimer(void) //sts_o7_sensorData.over_stay_state = 0; } + + if (STS_FHMOS_FALL_STATE_POTENTIAL == fhmos_data.state_fall) + { + fhmos_data.head_low_level_duration = current_time.Seconds - fhmos_data.head_low_level_start_time; + + if (fhmos_data.head_low_level_duration > fhmos_cfg.th_motionless_long_15sec*15) + { + fhmos_data.state_human_movement = STS_FHMOS_HUMAN_MOVEMENT_MOTIONLESS_LONG; + sts_o7_sensorData.over_stay_state = 1; + sts_o7_sensorData.over_stay_duration = sts_o7_sensorData.event_sensor1_duration; + over_threshold = TRUE; + APP_LOG(TS_OFF, VLEVEL_L, "\r\nSensor 1 Over Stay State=%d, Duration= %d Sec, Threshold =%u \r\n", + sts_o7_sensorData.over_stay_state, + (sts_o7_sensorData.over_stay_duration), + (fhmos_cfg.th_occupancy_overstay_15sec*15)); + + //(sts_occupancy_overtime_threshold_in_10min*60) ); + sts_lamp_bar_color = STS_OCCUPANCY_OVERSTAY_COLOR; + //sts_lamp_bar_flashing_color = 0x20; + //volatile uint8_t sts_lamp_bar_color = STS_GREEN; //puColor + //volatile uint8_t sts_lamp_bar_flashing_color = 0x23; // RED_BLUE; + } + else if (sts_o7_sensorData.event_sensor3_duration > fhmos_cfg.th_motionless_short_15sec*15) + { + fhmos_data.state_human_movement = STS_FHMOS_HUMAN_MOVEMENT_MOTIONLESS_SHORT; + sts_o7_sensorData.over_stay_state = 1; + sts_o7_sensorData.over_stay_duration = sts_o7_sensorData.event_sensor1_duration; + over_threshold = TRUE; + APP_LOG(TS_OFF, VLEVEL_L, "\r\nSensor 1 Over Stay State=%d, Duration= %d Sec, Threshold =%u \r\n", + sts_o7_sensorData.over_stay_state, + (sts_o7_sensorData.over_stay_duration), + (fhmos_cfg.th_occupancy_overstay_15sec*15)); + + //(sts_occupancy_overtime_threshold_in_10min*60) ); + sts_lamp_bar_color = STS_OCCUPANCY_OVERSTAY_COLOR; + + } + + if ((fhmos_fall == STS_FHMOS_FALL_STATE_POTENTIAL)||(fhmos_fall == STS_FHMOS_FALL_STATE_CONFIRMED)) + { + fhmos_data.state_fall = STS_FHMOS_FALL_STATE_POTENTIAL; + + + + + + } + + + #ifdef RSS_MOTION if (sts_rss_result==STS_RESULT_MOTION) { @@ -2653,6 +2703,11 @@ void OnSensor4StateChanged(void) } } +void OnSensorL8AStateChanged(void) +{ + sensor_event_time = SysTimeGetMcuTime(); + +} void STS_Combined_Status_Processing(void) { diff --git a/STS/TOF/App/app_tof.c b/STS/TOF/App/app_tof.c index 6a121de..d416ee9 100644 --- a/STS/TOF/App/app_tof.c +++ b/STS/TOF/App/app_tof.c @@ -518,6 +518,10 @@ static void print_result(RANGING_SENSOR_Result_t *Result) uint32_t motion_diff=0, motion_power=0; uint32_t motion_power_threshold = 3200; // 64*50mm + SysTime_t sensor_event_time = SysTimeGetMcuTime(); + uint32_t time_stamp=STS_Get_Date_Time_Stamp(); + + //printf("\r\n Motion level Calculation \r\n"); for (j=0; j<64; j++) @@ -564,8 +568,7 @@ static void print_result(RANGING_SENSOR_Result_t *Result) fhmos_data.state_human_movement = STS_FHMOS_HUMAN_MOVEMENT_NORMAL; fhmos_data.status_color = STS_OCCUPY_COLOR; // HOLD THIS COLOR BEFORE ENTER YELLOW STATUS - //OnSensorRange1StateChanged(); - + OnSensorL8AStateChanged(); fhmos_fall_counter ++; // TODO XXX Timer for confirmation if ((fhmos_fall_counter >= 30*fhmos_cfg.th_fall_duration_potential_15sec)&& (fhmos_fall_counter < 30*fhmos_cfg.th_fall_duration_confirm_15sec)) @@ -576,6 +579,10 @@ static void print_result(RANGING_SENSOR_Result_t *Result) printf("\r\n duration =%d sec, threshold=%d sec\r\n", fhmos_fall_counter, 15*fhmos_cfg.th_fall_duration_potential_15sec); printf("\r\n Fall state --- Yellow \r\n"); #endif + + + OnSensorL8BStateChanged(); + fhmos_fall =2; fhmos_data.state_fall = STS_FHMOS_FALL_STATE_POTENTIAL; fhmos_data.status_color = STS_FALL_SUSPICIOUS_COLOR; @@ -592,6 +599,9 @@ static void print_result(RANGING_SENSOR_Result_t *Result) printf("\r\n Fall state --- Red \r\n"); printf("\r\n [RED ***] Confirmed Fall state: roi_distance =%d -----[high=%4d mm Head Level =%d mm\r\n", roi_distance, sts_high_threshold, 10*fhmos_cfg.th_head_level_height_cm); #endif + + OnSensorL8CStateChanged(); + fhmos_fall =3; fhmos_data.state_fall = STS_FHMOS_FALL_STATE_CONFIRMED; fhmos_data.status_color = STS_FALL_CONFIRMED_COLOR; @@ -607,6 +617,7 @@ static void print_result(RANGING_SENSOR_Result_t *Result) fhmos_fall_counter = 0; fhmos_fall = 0; fhmos_human_movement = 1; + OnSensorL8DStateChanged(); #if 0 printf("\r\nThreshold: low =%d occupy=%d head level=%d high=%d\r\n", sts_low_threshold, sts_occupancy_threshold, fhmos_cfg.th_head_level_height_cm*10, sts_high_threshold); printf("\r\n [GREEN ** ]Normal Occupy state: rio distance =%d, low =%d occupy=%d head level=%d high=%d\r\n", roi_distance, sts_low_threshold, sts_occupancy_threshold, fhmos_cfg.th_head_level_height_cm*10, sts_high_threshold);