initial fall down simulation with yellow and red demo'ed out
This commit is contained in:
parent
92e9a22480
commit
b8fd205e3f
|
@ -581,7 +581,7 @@ void LoRaWAN_Init(void)
|
|||
#endif
|
||||
|
||||
#if defined(STS_P2)||defined(STS_T6)||defined(L8)
|
||||
UTIL_TIMER_Create(&YunhornSTSWakeUpScanTimer, STS_TOFScanPeriod_msec, UTIL_TIMER_PERIODIC, STS_YunhornSTSEventP5_Process, NULL);
|
||||
UTIL_TIMER_Create(&YunhornSTSWakeUpScanTimer, STS_TOFScanPeriod_msec, UTIL_TIMER_PERIODIC, (void*)STS_YunhornSTSEventP5_Process, NULL);
|
||||
UTIL_TIMER_Start(&YunhornSTSWakeUpScanTimer);
|
||||
#endif
|
||||
|
||||
|
@ -598,6 +598,7 @@ void LoRaWAN_Init(void)
|
|||
|
||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||
{
|
||||
static uint8_t prev_color =0;
|
||||
switch (GPIO_Pin)
|
||||
{
|
||||
case BUT1_Pin:
|
||||
|
@ -607,12 +608,23 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
|
||||
sts_hall1_read = HALL1_STATE;
|
||||
printf("\r\n HALL 1 state =%d \r\n", sts_hall1_read);
|
||||
if (sts_hall1_read == 0) sts_lamp_bar_color = STS_RED_DARK;
|
||||
|
||||
|
||||
if (sts_hall1_read == 0)
|
||||
{
|
||||
prev_color = sts_lamp_bar_color;
|
||||
sts_lamp_bar_color = STS_RED_DARK;
|
||||
} else {
|
||||
|
||||
sts_lamp_bar_color = prev_color;
|
||||
}
|
||||
printf("\r\n lamp bar color =0x%02x \r\n", sts_lamp_bar_color);
|
||||
|
||||
|
||||
//if (EventType == TX_ON_EVENT)
|
||||
if (sts_hall1_read == 0)
|
||||
{
|
||||
fhmos_occupancy = 1;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
}
|
||||
break;
|
||||
|
@ -627,8 +639,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
printf("\r\n HALL 2 state =%d \r\n", sts_hall2_read);
|
||||
if (sts_hall2_read == 0) sts_lamp_bar_color = STS_RED_BLUE;
|
||||
printf("\r\n lamp bar color =0x%02x \r\n", sts_lamp_bar_color);
|
||||
|
||||
if (sts_hall2_read ==0)
|
||||
{
|
||||
fhmos_sos_alarm = 1;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
}
|
||||
|
||||
|
@ -647,8 +660,14 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
|
||||
sts_pir_state = PIR_STATE;
|
||||
printf("\r\n PIR state =%d \r\n", sts_pir_state);
|
||||
if (sts_pir_state == 1) fhmos_human_movement = 1;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
if (sts_pir_state == 1) {
|
||||
fhmos_human_movement = 1;
|
||||
} else {
|
||||
fhmos_human_movement = 0;
|
||||
|
||||
}
|
||||
|
||||
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
break;
|
||||
#if (defined(VL53L0)||defined(VL53LX)||defined(L8))
|
||||
case TOF_INT_EXTI_PIN:
|
||||
|
|
Binary file not shown.
|
@ -38,7 +38,7 @@ extern "C" {
|
|||
#include "sts_lamp_bar.h"
|
||||
volatile uint8_t fhmos_fall=0, fhmos_human_movement=0, fhmos_occupancy=0, fhmos_sos_alarm=0;
|
||||
volatile uint32_t fhmos_fall_counter=0;
|
||||
volatile uint32_t sts_low_threshold=800, sts_high_threshold=2800, sts_occupancy_threshold=2000;
|
||||
volatile uint32_t sts_low_threshold=1500, sts_high_threshold=2800, sts_occupancy_threshold=2300;
|
||||
volatile sts_fhmos_sensor_data_t sts_fhmos_data;
|
||||
volatile sts_fhmos_sensor_config_t sts_fhmos_cfg;
|
||||
volatile sts_fhmos_sensor_ambient_height_t sts_fhmos_bg={0x0};
|
||||
|
@ -444,7 +444,7 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
|
|||
int8_t k;
|
||||
int8_t l;
|
||||
uint8_t zones_per_line;
|
||||
|
||||
static uint8_t prev_occupy_state=0;
|
||||
uint32_t center_range_distance=0;
|
||||
uint8_t center_roi[4] = {27,28,35,36};
|
||||
|
||||
|
@ -455,38 +455,51 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
|
|||
for (i=0; i<4; i++)
|
||||
{
|
||||
|
||||
center_range_distance =(uint32_t)(Result->ZoneResult[center_roi[i]].Distance[0]);
|
||||
center_range_distance +=(uint32_t)(Result->ZoneResult[center_roi[i]].Distance[0]);
|
||||
|
||||
}
|
||||
printf("\n\r Center Range =%4d mm\r\n",center_range_distance );
|
||||
//printf("\n\r Center Range =%4d mm\r\n",center_range_distance );
|
||||
|
||||
//int32_t roi_distance =(uint32_t)(Result->ZoneResult[j + k].Distance[l]);
|
||||
int32_t roi_distance =(uint32_t)center_range_distance;
|
||||
int32_t roi_distance =(uint32_t)center_range_distance/4;
|
||||
/* state tree */
|
||||
if ((roi_distance > sts_low_threshold)&&(roi_distance < sts_occupancy_threshold))
|
||||
{
|
||||
//fhmos_occupancy = 1;
|
||||
sts_fhmos_data.occupancy_state = 1;
|
||||
sts_lamp_bar_color = STS_GREEN;
|
||||
} else {
|
||||
sts_fhmos_data.occupancy_state = 0;
|
||||
sts_lamp_bar_color = STS_BLUE;
|
||||
|
||||
}
|
||||
if ((roi_distance < sts_high_threshold) && (roi_distance > (sts_high_threshold - sts_fhmos_cfg.sts_head_level_height_threshold_cm*10))) // TODO XXX
|
||||
{
|
||||
printf("\r\n roi_distance =%d -----[high=%4d Head Level =%d \r\n", roi_distance, sts_high_threshold, (sts_high_threshold- sts_fhmos_cfg.sts_head_level_height_threshold_cm*10));
|
||||
|
||||
sts_fhmos_data.fall_state = 1;
|
||||
sts_fhmos_data.human_movement_state = 1;
|
||||
|
||||
fhmos_fall = 1;
|
||||
fhmos_human_movement = 1;
|
||||
fhmos_fall_counter ++; // TODO XXX Timer for confirmation
|
||||
if (fhmos_fall_counter++>60)
|
||||
if ((fhmos_fall_counter >60)&& (fhmos_fall_counter < 200))
|
||||
{
|
||||
printf("\r\n Fall state --- Yellow \r\n");
|
||||
fhmos_fall =2;
|
||||
if (fhmos_fall_counter > 200)
|
||||
sts_lamp_bar_color = STS_YELLOW;
|
||||
} else if (fhmos_fall_counter >= 200)
|
||||
{
|
||||
printf("\r\n Fall state --- Red \r\n");
|
||||
fhmos_fall =3;
|
||||
sts_lamp_bar_color = STS_YELLOW;
|
||||
sts_lamp_bar_color = STS_RED;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((roi_distance > sts_low_threshold)&&(roi_distance < sts_occupancy_threshold))
|
||||
{
|
||||
printf("\r\n rio distance =%d, low =%d occupy=%d \r\n", roi_distance, sts_low_threshold, sts_occupancy_threshold);
|
||||
//fhmos_occupancy = 1;
|
||||
sts_fhmos_data.occupancy_state = 1;
|
||||
if (prev_occupy_state != sts_fhmos_data.occupancy_state)
|
||||
sts_lamp_bar_color = STS_GREEN;
|
||||
} else {
|
||||
sts_fhmos_data.occupancy_state = 0;
|
||||
if (prev_occupy_state != sts_fhmos_data.occupancy_state)
|
||||
sts_lamp_bar_color = STS_BLUE;
|
||||
}
|
||||
prev_occupy_state = sts_fhmos_data.occupancy_state;
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
@ -669,11 +682,10 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
|
|||
void STS_FHMOS_sensor_read(sts_fhmos_sensor_data_t *sts_data)
|
||||
{
|
||||
//uint8_t fhmos_fall=0, fhmos_human_movement=0, fhmos_occupancy=0, fhmos_sos_alarm=0;
|
||||
sts_data->occupancy_state = sts_fhmos_data.occupancy_state;
|
||||
sts_data->fall_state = sts_fhmos_data.fall_state;
|
||||
sts_data->human_movement_state =sts_fhmos_data.human_movement_state;
|
||||
sts_data->occupancy_state = sts_fhmos_data.occupancy_state;
|
||||
sts_data->sos_alarm_state = sts_fhmos_data.sos_alarm_state;
|
||||
sts_data->occupancy_state = sts_fhmos_data.occupancy_state|fhmos_occupancy;
|
||||
sts_data->fall_state = sts_fhmos_data.fall_state|fhmos_fall;
|
||||
sts_data->human_movement_state =sts_fhmos_data.human_movement_state|fhmos_human_movement;
|
||||
sts_data->sos_alarm_state = sts_fhmos_data.sos_alarm_state|fhmos_sos_alarm;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue