master #80
|
@ -38,7 +38,8 @@ extern "C" {
|
|||
#define STS_Status_Alarm_Mute_Release (1) //Normal Open NO:Close#
|
||||
#define STS_Status_Alarm_Reset_Pushdown (0) //Normal Open NO:Open
|
||||
#define STS_Status_Alarm_Reset_Release (1) //Normal Open NO:Close#
|
||||
|
||||
#define STS_Status_PIR_Motion_Detected (1) //
|
||||
#define STS_Status_PIR_Motion_Ended (0)
|
||||
enum sts_lamp_color {
|
||||
STS_DARK = 0, //灭:0, Code 0x00
|
||||
STS_GREEN, //绿:1 0 1 0 code 0x01 0b0000 0001
|
||||
|
@ -69,9 +70,16 @@ enum sts_lamp_color {
|
|||
#define STS_OCCUPY_COLOR STS_GREEN
|
||||
#define STS_SOS_COLOR STS_RED_BLUE
|
||||
|
||||
#define STS_FALL_NORMAL_COLOR STS_GREEN
|
||||
#define STS_FALL_SUSPICIOUS_COLOR STS_YELLOW
|
||||
#define STS_FALL_CONFIRMED_COLOR STS_RED
|
||||
#define STS_HUMAN_MOVEMENT_MOTIONLESS_COLOR STS_YELLOW
|
||||
|
||||
#define STS_HUMAN_MOVEMENT_MOTIONLESS_NORMAL STS_GREEN
|
||||
#define STS_HUMAN_MOVEMENT_MOTIONLESS_SHORT_COLOR STS_YELLOW
|
||||
#define STS_HUMAN_MOVEMENT_MOTIONLESS_LONG_COLOR STS_RED
|
||||
|
||||
#define STS_OCCUPANCY_NORMAL_COLOR STS_GREEN
|
||||
#define STS_OCCUPANCY_STAYLONGER_COLOR STS_YELLOW //NOT REALLY USED, JUST TO ALIGN FOR COLORS PATTERN
|
||||
#define STS_OCCUPANCY_OVERSTAY_COLOR STS_RED
|
||||
/*
|
||||
enum sts_oo_work_mode {
|
||||
|
|
|
@ -249,7 +249,8 @@ void STS_Lamp_Bar_Self_Test(void)
|
|||
STS_Lamp_Bar_Set_Dark();
|
||||
} else
|
||||
{
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color(STS_GREEN, lum_level);
|
||||
//STS_Lamp_Bar_Set_STS_RGB_Color(STS_GREEN, lum_level);
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color(STS_VACANT_COLOR, lum_level);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ extern volatile uint8_t sts_ac_code[20];
|
|||
extern volatile sts_cfg_nvm_t sts_cfg_nvm;
|
||||
extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color, luminance_level;
|
||||
volatile static bool r_b=true;
|
||||
extern volatile uint8_t sts_pir_state;
|
||||
extern volatile uint8_t sts_pir_read;
|
||||
extern volatile uint32_t rfac_timer;
|
||||
extern volatile uint32_t STS_TOFScanPeriod_msec, STS_TxPeriod_sec, STS_HeartBeatTimerPeriod_sec;
|
||||
volatile uint8_t sts_data_buf[LORAWAN_APP_DATA_BUFFER_MAX_SIZE]={0x0};
|
||||
|
@ -73,12 +73,18 @@ extern volatile sts_fhmos_sensor_ambient_height_t fhmos_bg;
|
|||
// volatile LmHandlerAppData_t sts_app_data={ 0, 0, sts_data_buf };
|
||||
extern volatile uint8_t sts_hall1_read, sts_hall2_read; // Above hall1_read == reed_hall_result, hall2_read == emergency_button
|
||||
extern volatile uint8_t sts_hall3_read, sts_hall4_read;
|
||||
extern volatile uint8_t sts_pir_state;
|
||||
//extern volatile uint8_t sts_pir_state, sts_pir_result;
|
||||
extern volatile uint8_t last_sts_hall1_read, last_sts_hall2_read, last_sts_hall3_read, last_sts_hall4_read;
|
||||
volatile uint8_t sts_PIR_read = 0;
|
||||
//volatile uint8_t sts_PIR_read = 0;
|
||||
volatile bool locklow = false;
|
||||
volatile uint32_t lowin=0;
|
||||
volatile bool takelowTime;
|
||||
uint32_t check_time=0;
|
||||
volatile bool motionDetected =false;
|
||||
uint32_t lastMotionTime =0;
|
||||
const uint32_t ledOnDuration = 10000;
|
||||
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
@ -497,7 +503,7 @@ void LoRaWAN_Init(void)
|
|||
UTIL_TIMER_Create(&RxLedTimer, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnRxTimerLedEvent, NULL);
|
||||
UTIL_TIMER_Create(&JoinLedTimer, LED_PERIOD_TIME, UTIL_TIMER_PERIODIC, OnJoinTimerLedEvent, NULL);
|
||||
UTIL_TIMER_Create(&STSLampBarColorTimer, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnYunhornSTSLampBarColorTimerEvent, NULL);
|
||||
UTIL_TIMER_Create(&STSDurationCheckTimer, 30*LED_PERIOD_TIME, UTIL_TIMER_PERIODIC, OnYunhornSTSDurationCheckTimerEvent, NULL);
|
||||
UTIL_TIMER_Create(&STSDurationCheckTimer, 1000, UTIL_TIMER_PERIODIC, OnYunhornSTSDurationCheckTimerEvent, NULL);
|
||||
|
||||
if (FLASH_IF_Init(NULL) != FLASH_IF_OK)
|
||||
{
|
||||
|
@ -589,7 +595,7 @@ void LoRaWAN_Init(void)
|
|||
#endif
|
||||
|
||||
UTIL_TIMER_Start(&STSLampBarColorTimer);
|
||||
|
||||
UTIL_TIMER_Start(&STSDurationCheckTimer);
|
||||
//UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL);
|
||||
// UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL);
|
||||
// UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
||||
|
@ -620,9 +626,12 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
// 2) change lamp bar color
|
||||
if (sts_hall1_read == STS_Status_Door_Close)
|
||||
{
|
||||
sts_lamp_bar_color = STS_OCCUPY_COLOR;
|
||||
sts_lamp_bar_color = STS_OCCUPANCY_NORMAL_COLOR;
|
||||
//prev_color = sts_lamp_bar_color;
|
||||
sts_status_color = STS_OCCUPY_COLOR;
|
||||
sts_status_color = STS_OCCUPANCY_NORMAL_COLOR;
|
||||
|
||||
printf("\r\n EXIT_CALLBACK, Door Open: sts status color =%d, lampbar_color=%d \r\n", sts_status_color, sts_lamp_bar_color);
|
||||
|
||||
//printf("\r\n Door Closed sts status color =%d", sts_status_color);
|
||||
|
||||
} else
|
||||
|
@ -631,21 +640,24 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
//sts_lamp_bar_color = prev_color;
|
||||
sts_status_color = STS_VACANT_COLOR;
|
||||
sts_lamp_bar_color = STS_VACANT_COLOR;
|
||||
//printf("\r\n Door Open: sts status color =%d", sts_status_color);
|
||||
printf("\r\n EXIT_CALLBACK, Door Open: sts status color =%d, lampbar_color=%d \r\n", sts_status_color, sts_lamp_bar_color);
|
||||
}
|
||||
|
||||
//printf("\r\n sts status color =0x%02x \r\n", sts_status_color);
|
||||
|
||||
// 3) combine states and colors
|
||||
STS_YunhornSTSEventP1_Process();
|
||||
//STS_YunhornSTSEventP1_Process();
|
||||
//STS_Combined_Status_Processing();
|
||||
|
||||
// 4) upload state change messages
|
||||
//if (EventType == TX_ON_EVENT)
|
||||
#if 0
|
||||
if (sts_hall1_read == STS_Status_Door_Close)
|
||||
{
|
||||
fhmos_occupancy = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
last_sts_hall1_read = sts_hall1_read;
|
||||
break;
|
||||
|
@ -668,27 +680,27 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
sts_status_color = STS_SOS_COLOR;
|
||||
fhmos_sos_alarm = 1;
|
||||
}
|
||||
//printf("\r\n lamp bar color =0x%02x \r\n", sts_lamp_bar_color);
|
||||
if (sts_hall2_read ==STS_Status_SOS_Release)
|
||||
else if (sts_hall2_read ==STS_Status_SOS_Release)
|
||||
{
|
||||
sts_lamp_bar_color = STS_VACANT_COLOR;
|
||||
sts_status_color = STS_VACANT_COLOR;
|
||||
fhmos_sos_alarm = 0;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
}
|
||||
last_sts_hall2_read = sts_hall2_read;
|
||||
// 3) combine states and colors
|
||||
|
||||
STS_YunhornSTSEventP1_Process();
|
||||
//STS_YunhornSTSEventP1_Process();
|
||||
|
||||
// 4) upload state change messages
|
||||
#if 0
|
||||
if (sts_hall2_read == STS_Status_SOS_Release)
|
||||
{
|
||||
fhmos_sos_alarm = 0;
|
||||
|
||||
}
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
last_sts_hall1_read = sts_hall1_read;
|
||||
#endif
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
last_sts_hall2_read = sts_hall2_read;
|
||||
|
||||
|
||||
break;
|
||||
|
@ -701,39 +713,48 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
#endif
|
||||
#if 1
|
||||
case PIR_Pin:
|
||||
sts_pir_state = PIR_STATE;
|
||||
printf("\r\n pir state =%u \r\n", sts_pir_state);
|
||||
sts_pir_read = PIR_STATE;
|
||||
|
||||
if (sts_pir_state)
|
||||
#if 0
|
||||
motionDetected = true;
|
||||
lastMotionTime = TIMER_IF_GetTimerValue();
|
||||
printf("\r\n pir state =%u \r\n", sts_pir_read);
|
||||
|
||||
|
||||
//sts_pir_read = PIR_STATE;
|
||||
|
||||
|
||||
if (sts_pir_read)
|
||||
{
|
||||
if (locklow) {
|
||||
sts_PIR_read = 1;
|
||||
sts_pir_read = 1;
|
||||
locklow = false;
|
||||
printf("\r\n Motion detected, PIR state =%d \r\n", sts_PIR_read);
|
||||
printf("\r\n Motion detected, PIR state =%d \r\n", sts_pir_read);
|
||||
HAL_Delay(50);
|
||||
}
|
||||
takelowTime=true;
|
||||
|
||||
}
|
||||
else if (!sts_pir_state)
|
||||
else if (!sts_pir_read)
|
||||
{
|
||||
//printf("\r\n pir state =%u \r\n", sts_pir_state);
|
||||
uint32_t check_time=TIMER_IF_GetTimerValue();
|
||||
check_time=TIMER_IF_GetTimerValue();
|
||||
if (takelowTime) {
|
||||
lowin = check_time;
|
||||
printf("\r\n lowin start at: %u \r\n", lowin);
|
||||
takelowTime = false;
|
||||
}
|
||||
//printf("\r\n low duration=%d \r\n", check_time-lowin);
|
||||
if ((!locklow && (check_time - lowin >= 50))) {
|
||||
else if ((!locklow && (check_time - lowin >= 5000))) {
|
||||
printf("\r\n low duration=%d \r\n", check_time-lowin);
|
||||
sts_PIR_read = 0;
|
||||
sts_pir_read = 0;
|
||||
locklow = true;
|
||||
printf("\r\n Motion End, PIR state =%d \r\n", sts_PIR_read);
|
||||
printf("\r\n Motion End, PIR state =%d \r\n", sts_pir_read);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
OnSensorPIR1StateChanged();
|
||||
#endif
|
||||
|
@ -1185,8 +1206,8 @@ static void SendTxData(void)
|
|||
AppData.Buffer[i++] = fhmos_data.state_human_movement;
|
||||
AppData.Buffer[i++] = fhmos_data.state_occupancy;
|
||||
AppData.Buffer[i++] = fhmos_data.state_sos_alarm;
|
||||
AppData.Buffer[i++] = fhmos_data.lamp_bar_color;
|
||||
|
||||
AppData.Buffer[i++] = fhmos_data.lamp_bar_color;
|
||||
AppData.Buffer[i++] = fhmos_data.state_hall_1;
|
||||
AppData.Buffer[i++] = fhmos_data.state_hall_2;
|
||||
AppData.Buffer[i++] = fhmos_data.state_PIR;
|
||||
|
@ -1195,7 +1216,7 @@ static void SendTxData(void)
|
|||
sts_data->lamp_bar_color = sts_lamp_bar_color;
|
||||
sts_data->state_hall_1 = sts_hall1_read;
|
||||
sts_data->state_hall_2 = sts_hall2_read;
|
||||
sts_data->state_PIR = sts_pir_result;;
|
||||
sts_data->state_PIR = sts_pir_read;;
|
||||
|
||||
AppData.Buffer[i++] = 8;
|
||||
AppData.Buffer[i++] = fhmos_data.state_fall;
|
||||
|
@ -1655,7 +1676,7 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
|
|||
*/
|
||||
static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
||||
{
|
||||
printf("\r\n----Duration check process ----");
|
||||
//printf("\r\n----Duration check process ----");
|
||||
YunhornSTSDurationCheckTimer();
|
||||
#ifdef STS_O6
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -269,6 +269,7 @@ enum {
|
|||
enum {
|
||||
STS_FHMOS_OCCUPANCY_NO_OCCUPY=0,
|
||||
STS_FHMOS_OCCUPANCY_NORMAL,
|
||||
STS_FHMOS_OCCUPANCY_LONGER, // NOT USED, JUST TO ALIGN RESULT OF 0/1/2/3 for BLUE/GREEN/YELLOW/RED
|
||||
STS_FHMOS_OCCUPANCY_OVERSTAY,
|
||||
};
|
||||
|
||||
|
@ -290,6 +291,11 @@ typedef struct sts_fhmos_sensor_data
|
|||
uint8_t state_occupancy; /* 0/blue: no occupy, 1/green:occupy yet normal, 3/red: over stay */
|
||||
uint8_t state_sos_alarm; /* 1/green, sos on-duty, 2/yellow, sos button pressed 3/red, alarm */
|
||||
|
||||
uint8_t color_fall; /* 0/blue: no occupy, 1/green:occupy yet normal, 2/yellow: suspicious state, 3/red: fall confirmed */
|
||||
uint8_t color_human_movement; /* 0/blue: no occupy, 1/green:occupy yet normal, 2/yellow: suspicious state, 3/red: fall confirmed */
|
||||
uint8_t color_occupancy; /* 0/blue: no occupy, 1/green:occupy yet normal, 3/red: over stay */
|
||||
uint8_t color_sos_alarm; /* 1/green, sos on-duty, 2/yellow, sos button pressed 3/red, alarm */
|
||||
|
||||
uint8_t state_hall_1;
|
||||
uint8_t state_hall_2;
|
||||
|
||||
|
@ -298,15 +304,6 @@ typedef struct sts_fhmos_sensor_data
|
|||
|
||||
uint8_t state_hall_4;
|
||||
|
||||
bool state_changed_fall;
|
||||
bool state_changed_human_movemen;
|
||||
bool state_changed_occupancy;
|
||||
bool state_changed_sos;
|
||||
bool state_changed_hall_1;
|
||||
bool state_changed_hall_2;
|
||||
bool state_changed_hall_3;
|
||||
bool state_changed_hall_4;
|
||||
bool state_changed_PIR;
|
||||
|
||||
uint8_t prev_fall;
|
||||
uint8_t prev_human_movement;
|
||||
|
@ -318,6 +315,16 @@ typedef struct sts_fhmos_sensor_data
|
|||
uint8_t prev_hall_3;
|
||||
uint8_t prev_hall_4;
|
||||
uint8_t prev_status_color;
|
||||
uint32_t head_low_level_duration;
|
||||
uint32_t head_low_level_start_time;
|
||||
uint32_t time_stamp_fall_confirmed;
|
||||
uint32_t time_stamp_fall_released;
|
||||
uint32_t time_stamp_motionless_confirmed;
|
||||
uint32_t time_stamp_motionless_released;
|
||||
uint32_t time_stamp_overstay_confirmed;
|
||||
uint32_t time_stamp_overstay_released;
|
||||
|
||||
|
||||
|
||||
} sts_fhmos_sensor_data_t;
|
||||
|
||||
|
@ -481,6 +488,11 @@ void OnSensorRSS3AStateChanged(void);
|
|||
void OnSensorRSS3BStateChanged(void);
|
||||
void OnSensorRSS3CStateChanged(void);
|
||||
|
||||
void OnSensorL8AStateChanged(void);
|
||||
void OnSensorL8BStateChanged(void);
|
||||
void OnSensorL8CStateChanged(void);
|
||||
void OnSensorL8DStateChanged(void);
|
||||
|
||||
void OnSensorPIR1StateChanged(void);
|
||||
|
||||
uint32_t STS_Get_Date_Time_Stamp(void);//uint32_t *time_stamp, uint8_t *datetimestamp);
|
||||
|
@ -505,6 +517,7 @@ void STS_PRESENCE_SENSOR_Distance_Measure_Process(void);
|
|||
|
||||
void STS_TOF_L8_Process(void);
|
||||
void STS_TOF_L8_Reconfig(void);
|
||||
void MX_53L8A1_ThresholdDetection_ConfigIT(uint32_t sts_low_threshold, uint32_t sts_high_threshold);
|
||||
void STS_LMZ_Ambient_Height_Scan_Process(void);
|
||||
void STS_FHMOS_sensor_read(sts_fhmos_sensor_data_t *sts_fhmos_data);
|
||||
void STS_FHMOS_sensor_config_init(void);
|
||||
|
|
|
@ -54,8 +54,9 @@ extern volatile uint8_t sts_tof_presence_state_changed;
|
|||
#include "sts_lamp_bar.h"
|
||||
volatile uint8_t sts_hall1_read=STS_Status_Door_Open,sts_hall2_read=STS_Status_SOS_Release; // Above hall1_read == reed_hall_result, hall2_read == emergency_button
|
||||
volatile uint8_t last_sts_hall1_read, last_sts_hall2_read, last_sts_hall3_read, last_sts_hall4_read;
|
||||
volatile uint8_t sts_pir_read=STS_Status_PIR_Motion_Ended;
|
||||
volatile uint8_t sts_hall3_read=STS_Status_Alarm_Mute_Release,sts_hall4_read=STS_Status_Alarm_Reset_Release;
|
||||
volatile uint8_t sts_pir_state=0;
|
||||
|
||||
volatile STS_OO_SensorStatusDataTypeDef sts_o7_sensorData;
|
||||
volatile uint8_t sts_fall_detection_acc_threshold = 30, //0.3g
|
||||
sts_fall_detection_depth_threshold=20,
|
||||
|
@ -72,6 +73,7 @@ extern volatile sts_fhmos_sensor_config_t fhmos_cfg;
|
|||
extern volatile uint8_t sts_status_color, sts_lamp_bar_color;//puColor
|
||||
extern uint8_t luminance_level;
|
||||
volatile uint8_t sts_fhmos_state_changed=0;
|
||||
volatile uint8_t sts_head_level_low =0;
|
||||
extern volatile uint8_t fhmos_gesture_bitmap[8];
|
||||
extern volatile sts_fhmos_sensor_data_t fhmos_data;
|
||||
extern volatile uint8_t sts_mask_bitmap[8];
|
||||
|
@ -127,19 +129,25 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
|
|||
/*
|
||||
uint8_t fhmos_fall=0, fhmos_human_movement=0, fhmos_occupancy=0, fhmos_sos_alarm=0;
|
||||
fhmos_cfg.th_head_level_height_cm = 70; // default 700mm
|
||||
|
||||
fhmos_cfg.th_fall_duration_potential_15sec = 4; // 4*15=60 sec, 1 min.
|
||||
fhmos_cfg.th_fall_duration_confirm_15sec = 8; // 8*15 = 120 sec, 2 min.
|
||||
fhmos_cfg.th_motionless_short_15sec = 4; // 4*15 = 60 sec , 1 min.
|
||||
fhmos_cfg.th_motionless_long_15sec = 16; // 20*15 = 300 sec, 5 min.
|
||||
|
||||
fhmos_cfg.th_motionless_short_15sec = 8; // 8*15 = 120 sec , 2 min.
|
||||
fhmos_cfg.th_motionless_long_15sec = 20; // 20*15 = 300 sec, 5 min.
|
||||
|
||||
fhmos_cfg.th_occupancy_overstay_15sec = 100; // 80*15 = 1200 sec, 20 min.
|
||||
fhmos_cfg.th_motion_power = 50;
|
||||
*/
|
||||
|
||||
0x46, // uint8_t fhmos_cfg_1; head level height cm
|
||||
0x04, // uint8_t fhmos_cfg_2; 04*15 = 60 sec, 1 min.
|
||||
0x08, // uint8_t fhmos_cfg_3; 08*15 = 120 sec, 2 min.
|
||||
0x04, // uint8_t fhmos_cfg_4; 04*15 = 60 sec, = 1 min.
|
||||
0x10, // uint8_t fhmos_cfg_5; 16*15 = 240 sec, = 4 min.
|
||||
0x46, // uint8_t fhmos_cfg_1; head level height cm
|
||||
|
||||
0x04, // uint8_t fhmos_cfg_2; 04*15 = 60 sec, 1 min. Fall potential
|
||||
0x08, // uint8_t fhmos_cfg_3; 08*15 = 120 sec, 2 min. Fall confirmed
|
||||
|
||||
0x08, // uint8_t fhmos_cfg_4; 08*15 = 120 sec, = 2 min. motionless short
|
||||
0x14, // uint8_t fhmos_cfg_5; 20*15 = 300 sec, = 5 min. motionless long
|
||||
|
||||
0x64, // uint8_t fhmos_cfg_6; 100*15=1500sec, =25min
|
||||
#elif
|
||||
0x03, //reserve8 occupancy over time threshold 3*10 = 30 minutes
|
||||
|
@ -166,10 +174,10 @@ volatile uint8_t sensor_data_ready=0;
|
|||
#if defined(STS_R1)||defined(STS_R5)||defined(STS_R4)||defined(STS_R1D)
|
||||
volatile uint32_t STS_TOFScanPeriod_msec=50, STS_TxPeriod_sec=30, STS_HeartBeatTimerPeriod_sec=3600;
|
||||
#elif defined(STS_L8)||defined(STS_P2)||defined(STS_O6T)||defined(STS_T6)||defined(O1L)
|
||||
volatile uint32_t STS_TOFScanPeriod_msec=500, STS_TxPeriod_sec=300, STS_HeartBeatTimerPeriod_sec=3600;
|
||||
volatile uint32_t STS_TOFScanPeriod_msec=1200, STS_TxPeriod_sec=300, STS_HeartBeatTimerPeriod_sec=3600;
|
||||
#endif
|
||||
volatile uint8_t sts_pir_result = 0;
|
||||
volatile uint8_t last_sts_pir_result=0;
|
||||
//volatile uint8_t sts_pir_state = 0, sts_pir_result=0;
|
||||
volatile uint8_t last_sts_pir_read=0;
|
||||
volatile uint32_t last_sts_pir_time_stamp;
|
||||
volatile uint8_t sts_rss_result_changed_flag = 0;
|
||||
volatile uint8_t sts_rss_result = STS_RESULT_NO_MOTION;
|
||||
|
@ -448,11 +456,11 @@ void STS_YunhornSTSEventP3_Process(void)
|
|||
#if (defined(STS_O6) ||defined(STS_O7)||defined(STS_T6)||defined(O1L))
|
||||
if (STS_Reed_Hall_State == STS_Status_Door_Open)
|
||||
{
|
||||
sts_lamp_bar_color =STS_BLUE;
|
||||
sts_lamp_bar_color =STS_VACANT_COLOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
sts_lamp_bar_color =STS_GREEN;
|
||||
sts_lamp_bar_color =STS_OCCUPY_COLOR;
|
||||
}
|
||||
STS_Lamp_Bar_Scoller(sts_lamp_bar_color, luminance_level);
|
||||
#endif
|
||||
|
@ -521,7 +529,7 @@ void STS_YunhornSTSEventP5_Process(void)
|
|||
{
|
||||
sts_fhmos_bitmap_pending = 0;
|
||||
|
||||
uint8_t tstbuf[128] ={0x0}; uint8_t i=0;
|
||||
uint8_t tstbuf[32] ={0x0}; uint8_t i=0;
|
||||
|
||||
tstbuf[i++] = (uint8_t) 'G';
|
||||
tstbuf[i++] = (uint8_t) sts_mtmcode1;
|
||||
|
@ -1880,10 +1888,13 @@ void STS_FHMOS_sensor_config_init(void)
|
|||
{
|
||||
//uint8_t fhmos_fall=0, fhmos_human_movement=0, fhmos_occupancy=0, fhmos_sos_alarm=0;
|
||||
fhmos_cfg.th_head_level_height_cm = 70; // default 700mm
|
||||
|
||||
fhmos_cfg.th_fall_duration_potential_15sec = 4; // 4*15=60 sec, 1 min.
|
||||
fhmos_cfg.th_fall_duration_confirm_15sec = 8; // 8*15 = 120 sec, 2 min.
|
||||
fhmos_cfg.th_motionless_short_15sec = 4; // 4*15 = 60 sec , 1 min.
|
||||
fhmos_cfg.th_motionless_long_15sec = 16; // 20*15 = 300 sec, 5 min.
|
||||
|
||||
fhmos_cfg.th_motionless_short_15sec = 8; // 4*15 = 60 sec , 1 min.
|
||||
fhmos_cfg.th_motionless_long_15sec = 20; // 20*15 = 300 sec, 5 min.
|
||||
|
||||
fhmos_cfg.th_occupancy_overstay_15sec = 100; // 80*15 = 1200 sec, 20 min.
|
||||
fhmos_cfg.th_motion_power_level = 50; // motion power level average
|
||||
fhmos_cfg.th_fhmos_cfg_reserve1=0;
|
||||
|
@ -2186,7 +2197,10 @@ void OnYunhornSTSSamplingPeriodicityChanged(uint32_t periodicity)
|
|||
|
||||
void YunhornSTSDurationCheckTimer(void)
|
||||
{
|
||||
static bool over_threshold = FALSE;
|
||||
static uint8_t over_threshold = 0;
|
||||
static uint8_t last_sensor1_state=0, last_sensor2_state=0, last_sensor3_state=0, last_sensor4_state=0;
|
||||
static uint8_t sts_sensor1_changed=0, sts_sensor2_changed=0, sts_sensor3_changed=0, sts_sensor4_changed=0;
|
||||
static uint8_t sts_cmb_result =0, last_sts_cmb_result=0;
|
||||
SysTime_t current_time = SysTimeGetMcuTime();
|
||||
|
||||
|
||||
|
@ -2194,31 +2208,39 @@ void YunhornSTSDurationCheckTimer(void)
|
|||
{
|
||||
sts_o7_sensorData.event_sensor1_duration = current_time.Seconds - sts_o7_sensorData.event_sensor1_start_time;
|
||||
|
||||
//if (sts_o7_sensorData.event_sensor1_duration > sts_occupancy_overtime_threshold_in_10min*600)
|
||||
//if (sts_o7_sensorData.event_sensor1_duration > (sts_occupancy_overtime_threshold_in_10min*60)) //for debug
|
||||
if (sts_o7_sensorData.event_sensor1_duration > fhmos_cfg.th_occupancy_overstay_15sec*15)
|
||||
{
|
||||
fhmos_data.state_occupancy = STS_FHMOS_OCCUPANCY_OVERSTAY;
|
||||
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",
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\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;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor1 overstay set color to %d \r\n",sts_lamp_bar_color);
|
||||
over_threshold |= 1<<1;
|
||||
}
|
||||
|
||||
} else {
|
||||
sts_o7_sensorData.event_sensor1_duration =0;
|
||||
|
||||
} else {
|
||||
fhmos_data.state_occupancy = STS_FHMOS_OCCUPANCY_NO_OCCUPY;
|
||||
|
||||
sts_o7_sensorData.event_sensor1_duration =0;
|
||||
over_threshold &= 1<<1;
|
||||
sts_o7_sensorData.over_stay_state = 0;
|
||||
fhmos_data.state_occupancy = STS_FHMOS_OCCUPANCY_NO_OCCUPY;
|
||||
sts_lamp_bar_color = STS_VACANT_COLOR;
|
||||
//APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor1 set VACANT color to %d \r\n",sts_lamp_bar_color);
|
||||
}
|
||||
|
||||
if (last_sensor1_state != fhmos_data.state_occupancy)
|
||||
{
|
||||
sts_sensor1_changed = TRUE;
|
||||
last_sensor1_state = fhmos_data.state_occupancy;
|
||||
}
|
||||
|
||||
// to be defined later for SOS threshold TODO XXXX
|
||||
|
@ -2228,71 +2250,122 @@ void YunhornSTSDurationCheckTimer(void)
|
|||
//if (sts_o7_sensorData.event_sensor2_duration > sts_occupancy_overtime_threshold_in_10min*60) //for debug
|
||||
if (sts_o7_sensorData.event_sensor2_duration > fhmos_cfg.th_occupancy_overstay_15sec*15)
|
||||
{
|
||||
|
||||
sts_o7_sensorData.over_stay_state = 1;
|
||||
fhmos_data.state_sos_alarm = STS_FHMOS_SOS_ALARM_BUTTON_PUSHED;
|
||||
// 2024-07-15 update, no overwrite sensor1 duration value
|
||||
//sts_o7_sensorData.over_stay_duration = sts_o7_sensorData.event_sensor2_duration;
|
||||
//
|
||||
over_threshold = TRUE;
|
||||
}
|
||||
over_threshold |= 1<<2;
|
||||
// to be defiend later for SOS threshold TODO XXXX
|
||||
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
sts_o7_sensorData.event_sensor2_duration =0;
|
||||
fhmos_data.state_sos_alarm = STS_FHMOS_SOS_ALARM_BUTTON_RESET; // OR NORMAL TODO XXX
|
||||
//sts_o7_sensorData.over_stay_state = 0;
|
||||
fhmos_data.state_sos_alarm = STS_FHMOS_SOS_ALARM_BUTTON_NORMAL; // OR NORMAL TODO XXX
|
||||
|
||||
//sts_o7_sensorData.over_stay_state = 0;
|
||||
over_threshold &= 1<<2;
|
||||
}
|
||||
}
|
||||
|
||||
if (STS_FHMOS_FALL_STATE_POTENTIAL == fhmos_data.state_fall)
|
||||
if (last_sensor2_state != fhmos_data.state_sos_alarm )
|
||||
{
|
||||
fhmos_data.head_low_level_duration = current_time.Seconds - fhmos_data.head_low_level_start_time;
|
||||
sts_sensor2_changed = TRUE;
|
||||
last_sensor2_state = fhmos_data.state_sos_alarm;
|
||||
}
|
||||
|
||||
if (fhmos_data.head_low_level_duration > fhmos_cfg.th_motionless_long_15sec*15)
|
||||
|
||||
if ((STS_Status_PIR_Motion_Ended == sts_pir_read)&&(sts_hall1_read ==STS_Status_Door_Close ))
|
||||
{
|
||||
sts_o7_sensorData.event_sensor3_no_movement_duration = current_time.Seconds - sts_o7_sensorData.event_sensor3_no_movement_start_time;
|
||||
|
||||
//if (sts_o7_sensorData.event_sensor1_duration > sts_occupancy_overtime_threshold_in_10min*600)
|
||||
//if (sts_o7_sensorData.event_sensor1_duration > (sts_occupancy_overtime_threshold_in_10min*60)) //for debug
|
||||
if (sts_o7_sensorData.event_sensor3_no_movement_duration > fhmos_cfg.th_motionless_long_15sec*15) // th_occupancy_overstay_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;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor 3 Human Movement =%d, Duration= %d Sec, Threshold =%u \r\n",
|
||||
fhmos_data.state_human_movement,
|
||||
sts_o7_sensorData.event_sensor3_no_movement_duration,
|
||||
(fhmos_cfg.th_motionless_long_15sec*15));
|
||||
|
||||
|
||||
sts_lamp_bar_color = STS_HUMAN_MOVEMENT_MOTIONLESS_LONG_COLOR;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor PIR set MOTIONLESS LONG color to %d \r\n",sts_lamp_bar_color);
|
||||
over_threshold |= 1<<3;
|
||||
if (last_sensor3_state != fhmos_data.state_human_movement)
|
||||
{
|
||||
sts_sensor3_changed = TRUE;
|
||||
last_sensor3_state = fhmos_data.state_human_movement;
|
||||
}
|
||||
|
||||
} else if ((sts_o7_sensorData.event_sensor3_no_movement_duration >= fhmos_cfg.th_motionless_short_15sec*15) &&
|
||||
(sts_o7_sensorData.event_sensor3_no_movement_duration < fhmos_cfg.th_motionless_long_15sec*15))
|
||||
{
|
||||
fhmos_data.state_human_movement = STS_FHMOS_HUMAN_MOVEMENT_MOTIONLESS_SHORT;
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor 3 Human Movement =%d, Duration= %d Sec, Threshold =%u \r\n",
|
||||
fhmos_data.state_human_movement,
|
||||
sts_o7_sensorData.event_sensor3_no_movement_duration,
|
||||
(fhmos_cfg.th_motionless_short_15sec*15));
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor PIR set MOTIONLESS SHORT color to %d \r\n",sts_lamp_bar_color);
|
||||
sts_lamp_bar_color = STS_HUMAN_MOVEMENT_MOTIONLESS_SHORT_COLOR;
|
||||
over_threshold |= 1<<4;
|
||||
}
|
||||
|
||||
} else {
|
||||
//sts_o7_sensorData.event_sensor1_duration =0;
|
||||
|
||||
sts_o7_sensorData.event_sensor3_no_movement_duration = 0;
|
||||
fhmos_data.state_human_movement = STS_FHMOS_HUMAN_MOVEMENT_NORMAL;
|
||||
fhmos_data.color_human_movement =STS_HUMAN_MOVEMENT_MOTIONLESS_NORMAL;
|
||||
//sts_lamp_bar_color = STS_HUMAN_MOVEMENT_MOTIONLESS_NORMAL;
|
||||
over_threshold &= 1<<3;
|
||||
over_threshold &= 1<<4;
|
||||
}
|
||||
else if (sts_o7_sensorData.event_sensor3_duration > fhmos_cfg.th_motionless_short_15sec*15)
|
||||
|
||||
if (last_sensor3_state != fhmos_data.state_human_movement)
|
||||
{
|
||||
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;
|
||||
|
||||
sts_sensor3_changed = TRUE;
|
||||
last_sensor3_state = fhmos_data.state_human_movement;
|
||||
}
|
||||
|
||||
if ((fhmos_fall == STS_FHMOS_FALL_STATE_POTENTIAL)||(fhmos_fall == STS_FHMOS_FALL_STATE_CONFIRMED))
|
||||
{
|
||||
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_POTENTIAL;
|
||||
|
||||
//if (fhmos_data.state_fall > STS_FHMOS_FALL_STATE_NORMAL) // either STS_FHMOS_FALL_STATE_POTENTIAL or STS_FHMOS_FALL_STATE_CONFIRMED
|
||||
if (sts_head_level_low)
|
||||
{ // counter start
|
||||
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)
|
||||
{
|
||||
uint32_t time_stamp=STS_Get_Date_Time_Stamp(); //uint8_t datetimestamp[8]={0};
|
||||
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_CONFIRMED;
|
||||
fhmos_data.time_stamp_fall_confirmed = time_stamp;
|
||||
sts_lamp_bar_color = STS_FALL_CONFIRMED_COLOR;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor L8 set FALL CONFIRM color to %d \r\n",sts_lamp_bar_color);
|
||||
over_threshold |= 1<<5;
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nGenerate Fall Gesture Map\r\n");
|
||||
sts_generate_fall_gesture_map();
|
||||
|
||||
} else if ((fhmos_data.head_low_level_duration >= fhmos_cfg.th_motionless_short_15sec*15) &&
|
||||
(fhmos_data.head_low_level_duration < fhmos_cfg.th_motionless_long_15sec*15))
|
||||
{
|
||||
// stay this state until > long threshold
|
||||
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_POTENTIAL;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor L8 set FALL POTENTIAL color to %d \r\n",sts_lamp_bar_color);
|
||||
sts_lamp_bar_color = STS_FALL_SUSPICIOUS_COLOR;
|
||||
over_threshold |= 1<<6;
|
||||
}
|
||||
|
||||
} else {
|
||||
over_threshold &= 1<<5;
|
||||
over_threshold &= 1<<6;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef RSS_MOTION
|
||||
if (sts_rss_result==STS_RESULT_MOTION)
|
||||
{
|
||||
|
@ -2317,7 +2390,7 @@ void YunhornSTSDurationCheckTimer(void)
|
|||
STS_PRESENCE_UNCONSCIOUS,
|
||||
STS_PRESENCE_STAYSTILL
|
||||
*/
|
||||
uint32_t time_stamp=STS_Get_Date_Time_Stamp(); //uint8_t datetimestamp[8]={0};
|
||||
//uint32_t time_stamp=STS_Get_Date_Time_Stamp(); //uint8_t datetimestamp[8]={0};
|
||||
//(&time_stamp, datetimestamp);
|
||||
#ifdef RSS_MOTION
|
||||
switch (sts_fall_rising_detected_result){
|
||||
|
@ -2338,6 +2411,7 @@ void YunhornSTSDurationCheckTimer(void)
|
|||
sts_o7_sensorData.fall_state = sts_fall_rising_detected_result;
|
||||
sts_o7_sensorData.fall_laydown_duration =sts_o7_sensorData.event_sensor3_fall_duration;
|
||||
over_threshold = TRUE;
|
||||
|
||||
} else { // still laydown, but not over fall down confirmation threshold
|
||||
sts_o7_sensorData.fall_state = STS_PRESENCE_LAYDOWN;
|
||||
sts_o7_sensorData.fall_laydown_duration =sts_o7_sensorData.event_sensor3_fall_duration;
|
||||
|
@ -2377,24 +2451,20 @@ void YunhornSTSDurationCheckTimer(void)
|
|||
sts_o7_sensorData.event_sensor3_event_duration = sensor_event_time.Seconds - sts_o7_sensorData.event_sensor4_start_time;
|
||||
#endif
|
||||
|
||||
if (over_threshold == TRUE)
|
||||
//fhmos_data.state_occupancy = STS_FHMOS_OCCUPANCY_OVERSTAY;
|
||||
|
||||
|
||||
|
||||
sts_cmb_result = sts_sensor1_changed ||sts_sensor2_changed||sts_sensor3_changed||sts_sensor4_changed;
|
||||
|
||||
if ((over_threshold) && (last_sts_cmb_result != sts_cmb_result))
|
||||
{
|
||||
|
||||
if (sts_o7_sensorData.fall_state == STS_PRESENCE_LAYDOWN)
|
||||
{
|
||||
sts_status_color = sts_lamp_bar_flashing_color; //STS_RED_BLUE;
|
||||
sts_lamp_bar_color = sts_lamp_bar_flashing_color; //STS_RED_BLUE;
|
||||
} else {
|
||||
sts_status_color = STS_RED_DARK;
|
||||
sts_lamp_bar_color = STS_RED_DARK; //sts_lamp_bar_flashing_color;
|
||||
}
|
||||
|
||||
fhmos_data.state_occupancy = STS_FHMOS_OCCUPANCY_OVERSTAY;
|
||||
|
||||
sensor_data_ready = 1;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Over Threshold =%02x \r\n", over_threshold);
|
||||
last_sts_cmb_result = sts_cmb_result;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
over_threshold = FALSE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void OnSensorRange1StateChanged(void)
|
||||
|
@ -2421,6 +2491,8 @@ void OnSensor1StateChanged(void)
|
|||
SysTime_t sensor_event_time = SysTimeGetMcuTime();
|
||||
if (sts_hall1_read == STS_Status_Door_Close)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Door Closed \r\n");
|
||||
|
||||
sts_o7_sensorData.event_sensor1_start_time = sensor_event_time.Seconds;
|
||||
sts_o7_sensorData.event_sensor1_duration = 0;
|
||||
//APP_LOG(TS_OFF, VLEVEL_M, "Door Closed ---Timer start: %u\r\n",sts_o7_sensorData.event_sensor1_start_time );
|
||||
|
@ -2429,8 +2501,14 @@ void OnSensor1StateChanged(void)
|
|||
fhmos_data.state_human_movement = STS_FHMOS_HUMAN_MOVEMENT_NORMAL;
|
||||
} else if (sts_hall1_read==STS_Status_Door_Open)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Door Opened \r\n");
|
||||
sts_o7_sensorData.event_sensor1_start_time = 0;
|
||||
sts_o7_sensorData.event_sensor1_stop_time = sensor_event_time.Seconds;
|
||||
|
||||
sts_o7_sensorData.event_sensor3_motion_start_time = 0;
|
||||
sts_o7_sensorData.event_sensor3_motion_stop_time =0;
|
||||
sts_o7_sensorData.event_sensor3_no_movement_start_time =0;
|
||||
|
||||
//sts_o7_sensorData.event_sensor1_duration = 0;
|
||||
sts_o7_sensorData.over_stay_state = 0;
|
||||
fhmos_data.state_occupancy = STS_FHMOS_OCCUPANCY_NO_OCCUPY;
|
||||
|
@ -2449,6 +2527,7 @@ void OnSensor2StateChanged(void)
|
|||
|
||||
if (sts_hall2_read==STS_Status_SOS_Pushdown)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n SOS Button Pushed Down \r\n");
|
||||
sts_o7_sensorData.event_sensor2_start_time = sensor_event_time.Seconds;
|
||||
sts_o7_sensorData.event_sensor2_start_timestamp = time_stamp;
|
||||
sts_o7_sensorData.event_sensor2_stop_time = 0;
|
||||
|
@ -2459,6 +2538,7 @@ void OnSensor2StateChanged(void)
|
|||
|
||||
}else if (sts_hall2_read==STS_Status_SOS_Release)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n SOS Button Released \r\n");
|
||||
sts_o7_sensorData.event_sensor2_start_time = 0;
|
||||
sts_o7_sensorData.event_sensor2_start_timestamp = 0;
|
||||
sts_o7_sensorData.event_sensor2_stop_time = sensor_event_time.Seconds;
|
||||
|
@ -2621,16 +2701,19 @@ void OnSensorPIR1StateChanged(void)
|
|||
|
||||
}
|
||||
#endif
|
||||
if (sts_pir_result == STS_RESULT_MOTION)
|
||||
if (sts_pir_read == STS_RESULT_MOTION)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Motion Human Movement Detected\r\n");
|
||||
sts_o7_sensorData.event_sensor3_motion_start_time = sensor_event_time.Seconds;
|
||||
sts_o7_sensorData.event_sensor3_motion_duration = 0;
|
||||
fhmos_data.state_PIR = STS_FHMOS_HUMAN_MOVEMENT_NORMAL;
|
||||
} else if (sts_pir_result == STS_RESULT_NO_MOTION)
|
||||
//fhmos_data.state_PIR = STS_FHMOS_HUMAN_MOVEMENT_NORMAL;
|
||||
} else if (sts_pir_read == STS_RESULT_NO_MOTION)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Motionless, Human Movement Ended\r\n");
|
||||
sts_o7_sensorData.event_sensor3_motion_stop_time = sensor_event_time.Seconds;
|
||||
sts_o7_sensorData.event_sensor3_no_movement_start_time = sensor_event_time.Seconds;
|
||||
//sts_o7_sensorData.event_sensor3_motion_duration = 0;
|
||||
fhmos_data.state_PIR = STS_FHMOS_HUMAN_MOVEMENT_MOTIONLESS_SHORT;
|
||||
//fhmos_data.state_PIR = STS_FHMOS_HUMAN_MOVEMENT_MOTIONLESS_SHORT;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2705,10 +2788,31 @@ void OnSensor4StateChanged(void)
|
|||
|
||||
void OnSensorL8AStateChanged(void)
|
||||
{
|
||||
sensor_event_time = SysTimeGetMcuTime();
|
||||
//sensor_event_time = SysTimeGetMcuTime();
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n L8A \r\n");
|
||||
|
||||
}
|
||||
|
||||
void OnSensorL8BStateChanged(void)
|
||||
{
|
||||
//sensor_event_time = SysTimeGetMcuTime();
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n L8B \r\n");
|
||||
printf("\r\n L8B \r\n");
|
||||
}
|
||||
|
||||
|
||||
void OnSensorL8CStateChanged(void)
|
||||
{
|
||||
//sensor_event_time = SysTimeGetMcuTime();
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n L8C \r\n");
|
||||
}
|
||||
|
||||
void OnSensorL8DStateChanged(void)
|
||||
{
|
||||
//sensor_event_time = SysTimeGetMcuTime();
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n L8D \r\n");
|
||||
}
|
||||
|
||||
void STS_Combined_Status_Processing(void)
|
||||
{
|
||||
//printf("\r\n ********* combined process %d \r\n", sts_work_mode);
|
||||
|
@ -2826,22 +2930,35 @@ void STS_Combined_Status_Processing(void)
|
|||
|
||||
break;
|
||||
case STS_TOF_LMZ_RSS_MODE: // FOR STS-L8
|
||||
if ((sts_reed_hall_1_result == STS_Status_Door_Open )&& (sts_reed_hall_2_result == STS_Status_SOS_Release )
|
||||
&& (sts_fhmos_result == STS_FHMOS_FALL_STATE_NO_OCCUPY))
|
||||
//if ((sts_reed_hall_1_result == STS_Status_Door_Open )&& (sts_reed_hall_2_result == STS_Status_SOS_Release ))
|
||||
if ((sts_hall1_read == STS_Status_Door_Open) && (sts_hall2_read == STS_Status_SOS_Release))
|
||||
{
|
||||
sts_status_color = STS_VACANT_COLOR;
|
||||
//printf("\r\n ********* combined process Vacant color = %d \r\n", sts_status_color);
|
||||
printf("\r\n ********* --1--- combined process Vacant color = 0x%02x \r\n", sts_status_color);
|
||||
|
||||
} else if ((sts_reed_hall_1_result == STS_Status_Door_Close )|| (sts_reed_hall_2_result == STS_Status_SOS_Pushdown ))
|
||||
//} else if ((sts_reed_hall_1_result == STS_Status_Door_Close )|| (sts_reed_hall_2_result == STS_Status_SOS_Pushdown ))
|
||||
//|| (sts_fhmos_result != STS_FHMOS_FALL_STATE_NO_OCCUPY))
|
||||
} else if ((sts_hall1_read == STS_Status_Door_Close )|| (sts_hall2_read == STS_Status_SOS_Pushdown ))
|
||||
{
|
||||
sts_status_color = STS_OCCUPY_COLOR;
|
||||
//printf("\r\n ********* combined process Occupy color = %d \r\n", sts_status_color);
|
||||
//printf("\r\n ********* --2-- combined Occupy color = %d \r\n", sts_status_color);
|
||||
|
||||
if (sts_reed_hall_2_result == STS_Status_SOS_Pushdown )
|
||||
if (sts_hall2_read == STS_Status_SOS_Pushdown )
|
||||
{
|
||||
sts_status_color = STS_RED_BLUE;
|
||||
}
|
||||
if (fhmos_data.state_occupancy == STS_FHMOS_OCCUPANCY_OVERSTAY)
|
||||
{
|
||||
sts_status_color = STS_OCCUPANCY_OVERSTAY_COLOR;
|
||||
}
|
||||
#if 0
|
||||
if (fhmos_data.color_fall > STS_OCCUPY_COLOR)
|
||||
{
|
||||
//printf("\r\n fhmos-data-color-fall =%d \r\n", fhmos_data.color_fall);
|
||||
sts_status_color = fhmos_data.color_fall;
|
||||
printf("\r\n FHMOS DATA sts-status-color =%d \r\n", sts_status_color);
|
||||
}
|
||||
|
||||
if ((sts_fhmos_result == STS_FHMOS_FALL_STATE_POTENTIAL) || (sts_fhmos_result == STS_FHMOS_HUMAN_MOVEMENT_MOTIONLESS_SHORT))
|
||||
{
|
||||
sts_status_color = STS_YELLOW;
|
||||
|
@ -2850,8 +2967,10 @@ void STS_Combined_Status_Processing(void)
|
|||
{
|
||||
sts_status_color = STS_RED;
|
||||
}
|
||||
#endif
|
||||
//printf("\r\n ********* combined process finished status color = %d \r\n", sts_status_color);
|
||||
sts_lamp_bar_color = sts_status_color;
|
||||
printf("\r\n COMBINED: sts-lamp_bar-color =0x%02x \r\n", sts_lamp_bar_color);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ extern "C" {
|
|||
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=1500, sts_high_threshold=2800, sts_occupancy_threshold=2300;
|
||||
|
||||
extern volatile uint8_t sts_head_level_low;
|
||||
volatile sts_fhmos_sensor_data_t fhmos={0x0};
|
||||
volatile sts_fhmos_sensor_config_t fhmos_cfg;
|
||||
volatile sts_fhmos_sensor_config_t fhmos_cfg={70,4,8,8,20,100,50,0};
|
||||
volatile sts_fhmos_sensor_ambient_height_t fhmos_bg={0x0}, fhmos_gesture={0x0};
|
||||
volatile sts_fhmos_sensor_data_t fhmos_data;
|
||||
extern volatile uint8_t sts_fhmos_result;
|
||||
|
@ -50,7 +50,7 @@ extern volatile uint16_t sts_sensor_install_height; //in mm
|
|||
extern volatile uint8_t sts_lamp_bar_color;
|
||||
extern volatile uint8_t sts_status_color;
|
||||
extern volatile uint8_t sts_hall1_read,sts_hall2_read; // Above hall1_read == reed_hall_result, hall2_read == emergency_button
|
||||
extern volatile uint8_t sts_pir_result;
|
||||
extern volatile uint8_t sts_pir_read;
|
||||
extern volatile uint8_t sts_fhmos_state_changed;
|
||||
extern volatile uint8_t sts_fhmos_bitmap_pending;
|
||||
#endif
|
||||
|
@ -213,7 +213,7 @@ void STS_LMZ_Ambient_Height_Scan_Process(void)
|
|||
}
|
||||
sts_mask_bitmap[(uint8_t)(i/8)] |= (fhmos_bg.maskoff[i])<<(7-i%8);
|
||||
if (i%8==0) printf("\r\n");
|
||||
printf("|%4d %4d ", range_distance, fhmos_bg.h2cm[i]);
|
||||
printf("|%4ld %4d ", range_distance, fhmos_bg.h2cm[i]);
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -267,7 +267,7 @@ void sts_generate_fall_gesture_map(void)
|
|||
|
||||
// debug
|
||||
if (i%8==0) printf("\r\n");
|
||||
printf("|%4d %4d ", range_distance, fhmos_gesture.h2cm[i]);
|
||||
printf("|%4ld %4d ", range_distance, fhmos_gesture.h2cm[i]);
|
||||
}
|
||||
else {
|
||||
fhmos_gesture.h2cm[i] += 0;
|
||||
|
@ -286,6 +286,8 @@ void sts_generate_fall_gesture_map(void)
|
|||
printf("%02X\r\n",fhmos_gesture_bitmap[i]);
|
||||
#endif
|
||||
|
||||
sts_fhmos_bitmap_pending = 1;
|
||||
printf("\r\n Fall Gesture bitmap Generated\r\n");
|
||||
}
|
||||
uint16_t MX_TOF_Ranging_Process(void)
|
||||
{
|
||||
|
@ -374,15 +376,19 @@ void STS_TOF_L8_Process(void)
|
|||
if (ToF_EventDetected != 0)
|
||||
{
|
||||
ToF_EventDetected = 0;
|
||||
|
||||
status = VL53L8A1_RANGING_SENSOR_GetDistance(VL53L8A1_DEV_CENTER, &Result);
|
||||
//printf("\r\n status =%d \r\n", status);
|
||||
if (status == BSP_ERROR_NONE)
|
||||
#if 1
|
||||
if (sts_hall1_read != STS_Status_Door_Open)
|
||||
{
|
||||
print_result(&Result);
|
||||
} else {
|
||||
printf("\r\n x \r\n");
|
||||
status = VL53L8A1_RANGING_SENSOR_GetDistance(VL53L8A1_DEV_CENTER, &Result);
|
||||
//printf("\r\n status =%d \r\n", status);
|
||||
if (status == BSP_ERROR_NONE)
|
||||
{
|
||||
print_result(&Result);
|
||||
} else {
|
||||
printf("\r\n x \r\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -508,18 +514,18 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
|
|||
{
|
||||
int8_t i;
|
||||
int8_t j;
|
||||
int8_t k;
|
||||
int8_t l;
|
||||
uint8_t zones_per_line;
|
||||
static uint8_t prev_occupy_state=0;
|
||||
//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};
|
||||
static uint32_t prev_distance[64]={0};
|
||||
uint32_t motion_diff=0, motion_power=0;
|
||||
uint32_t motion_power_threshold = 3200; // 64*50mm
|
||||
//uint32_t motion_power_threshold = 3200; // 64*50mm
|
||||
|
||||
SysTime_t sensor_event_time = SysTimeGetMcuTime();
|
||||
uint32_t time_stamp=STS_Get_Date_Time_Stamp();
|
||||
//SysTime_t sensor_event_time = SysTimeGetMcuTime();
|
||||
// uint32_t time_stamp=STS_Get_Date_Time_Stamp();
|
||||
|
||||
|
||||
//printf("\r\n Motion level Calculation \r\n");
|
||||
|
@ -543,9 +549,10 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
|
|||
#if 0
|
||||
printf("\r\n Motion Power =%d Average=%d Human Movement =%d, th=%d \r\n", motion_power*64, motion_power, fhmos_human_movement, fhmos_cfg.th_motion_power_level);
|
||||
#endif
|
||||
#if 0
|
||||
zones_per_line = ((Profile.RangingProfile == RS_PROFILE_8x8_AUTONOMOUS) ||
|
||||
(Profile.RangingProfile == RS_PROFILE_8x8_CONTINUOUS)) ? 8 : 4;
|
||||
|
||||
#endif
|
||||
//printf("%c[2H", 27); /* clear screen */
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
|
@ -557,255 +564,41 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
|
|||
|
||||
//int32_t roi_distance =(uint32_t)(Result->ZoneResult[j + k].Distance[l]);
|
||||
int32_t roi_distance =(uint32_t)center_range_distance/4;
|
||||
|
||||
uint32_t factor1 = sts_sensor_install_height;
|
||||
uint32_t factor2 = (sts_high_threshold - 10*fhmos_cfg.th_head_level_height_cm);
|
||||
/* state tree */
|
||||
//printf("\r\n th_head_level_cm=%d, factor2=high_th:%d - mm:%d\r\n", fhmos_cfg.th_head_level_height_cm, sts_high_threshold, factor2);
|
||||
//printf("\r\n roi_D < Facot1 =%d , D<Factor2 =%d", factor1, factor2);
|
||||
|
||||
if ((roi_distance < sts_high_threshold) && (roi_distance > (sts_high_threshold - fhmos_cfg.th_head_level_height_cm*10))) // TODO XXX
|
||||
//if ((roi_distance < sts_sensor_install_height)&&(roi_distance < (sts_high_threshold - fhmos_cfg.th_head_level_height_cm*10))) // TODO XXX
|
||||
if ((roi_distance < factor1)&& (roi_distance > factor2))
|
||||
{
|
||||
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 YELLOW OR RED Distance=%d \r\n", roi_distance);
|
||||
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_NORMAL;
|
||||
fhmos_data.state_human_movement = STS_FHMOS_HUMAN_MOVEMENT_NORMAL;
|
||||
fhmos_data.status_color = STS_OCCUPY_COLOR; // HOLD THIS COLOR BEFORE ENTER YELLOW STATUS
|
||||
|
||||
//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 YELLOW OR RED Distance=%ld \r\n", roi_distance);
|
||||
sts_head_level_low = TRUE;
|
||||
#if 0
|
||||
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_POTENTIAL;
|
||||
fhmos_data.color_fall = STS_FALL_SUSPICIOUS_COLOR;
|
||||
printf("\r\n State Fall =%d \r\n", fhmos_data.state_fall);
|
||||
#endif
|
||||
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))
|
||||
{
|
||||
#if 0
|
||||
printf("\r\n [YELLOW **] Suspicious Fall: distance=%d [high - head level=[%d]] <= distance <= [high-100 =%d] \r\n",
|
||||
roi_distance, (sts_high_threshold - 10*fhmos_cfg.th_head_level_height_cm), (sts_high_threshold - 100));
|
||||
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
|
||||
sts_fhmos_state_changed |=1;
|
||||
|
||||
} else if ((roi_distance < factor2)) // TODO XXX
|
||||
{
|
||||
|
||||
OnSensorL8BStateChanged();
|
||||
|
||||
fhmos_fall =2;
|
||||
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_POTENTIAL;
|
||||
fhmos_data.status_color = STS_FALL_SUSPICIOUS_COLOR;
|
||||
fhmos_data.state_changed_fall = true;
|
||||
|
||||
sts_fhmos_state_changed |=1;
|
||||
|
||||
} else if (fhmos_fall_counter >= 30*fhmos_cfg.th_fall_duration_confirm_15sec)
|
||||
{
|
||||
#if 0
|
||||
printf("\r\n [RED **] Configmed Fall: distance=%d [high - head level=[%d]] <= distance <= [high-100 =%d] \r\n",
|
||||
roi_distance, (sts_high_threshold - 10*fhmos_cfg.th_head_level_height_cm), (sts_high_threshold - 100));
|
||||
printf("\r\n duration =%d sec, threshold=%d sec\r\n", fhmos_fall_counter, 15*fhmos_cfg.th_fall_duration_confirm_15sec);
|
||||
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;
|
||||
fhmos_data.state_changed_fall = true;
|
||||
sts_fhmos_state_changed |=1;
|
||||
sts_generate_fall_gesture_map();
|
||||
sts_fhmos_bitmap_pending = 1;
|
||||
}
|
||||
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_NORMAL;
|
||||
//fhmos_data.color_fall = STS_FALL_NORMAL_COLOR; // HOLD THIS COLOR BEFORE ENTER YELLOW STATUS
|
||||
printf("\r\n NORMAL NO FALL Distance=%4d COLOR =%d \r\n", roi_distance, fhmos_data.color_fall);
|
||||
OnSensorL8BStateChanged();
|
||||
|
||||
}
|
||||
else if ((roi_distance > sts_low_threshold)&&(roi_distance < sts_occupancy_threshold))
|
||||
{
|
||||
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);
|
||||
#endif
|
||||
//fhmos_occupancy = STS_FHMOS_OCCUPANCY_NORMAL;
|
||||
fhmos_data.state_occupancy = STS_FHMOS_OCCUPANCY_NORMAL;
|
||||
fhmos_data.state_human_movement = STS_FHMOS_HUMAN_MOVEMENT_NORMAL;
|
||||
fhmos_data.state_changed_human_movemen = true;
|
||||
if (fhmos_data.prev_occupancy != fhmos_data.state_occupancy)
|
||||
{
|
||||
fhmos_data.status_color = STS_OCCUPY_COLOR;
|
||||
sts_fhmos_state_changed |=1;
|
||||
//sts_fhmos_result = 1;
|
||||
|
||||
}
|
||||
|
||||
}else
|
||||
{
|
||||
#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 [BLUE *] No occupy status , distance=%d \r\n", roi_distance);
|
||||
#endif
|
||||
fhmos_data.state_occupancy = STS_FHMOS_OCCUPANCY_NO_OCCUPY;
|
||||
fhmos_fall_counter =0;
|
||||
fhmos_data.state_human_movement = fhmos_human_movement | STS_FHMOS_HUMAN_MOVEMENT_NO_OCCUPY;
|
||||
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_NO_OCCUPY;
|
||||
|
||||
if (fhmos_data.prev_occupancy != fhmos_data.state_occupancy)
|
||||
{
|
||||
fhmos_data.status_color = STS_VACANT_COLOR;
|
||||
sts_fhmos_state_changed |=1;
|
||||
}
|
||||
}
|
||||
|
||||
fhmos_data.prev_occupancy = fhmos_data.state_occupancy;
|
||||
//STS_Combined_Status_Processing();
|
||||
|
||||
|
||||
sts_fhmos_result = fhmos_data.state_changed_fall||fhmos_data.state_changed_human_movemen||fhmos_data.state_changed_occupancy;
|
||||
|
||||
if (fhmos_data.status_color != fhmos_data.prev_status_color)
|
||||
{
|
||||
fhmos_data.prev_status_color = fhmos_data.status_color;
|
||||
sts_lamp_bar_color = fhmos_data.status_color;
|
||||
sts_status_color = sts_lamp_bar_color;
|
||||
sts_fhmos_result = 1;
|
||||
STS_Combined_Status_Processing();
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf("53L8A1 Threshold Detection demo application\n\r");
|
||||
printf("-------------------------------------------\n\r");
|
||||
printf("-------- Low= %4d High= %4d ------------\n\r", LOW_THRESHOLD, HIGH_THRESHOLD);
|
||||
printf("Cell Format :");
|
||||
#endif
|
||||
//printf(" \033[38;5;10m%20s\033[0m : %20s\n", "Distance [mm]", "Status\r");
|
||||
#if 0
|
||||
for (l = 0; l < RANGING_SENSOR_NB_TARGET_PER_ZONE; l++)
|
||||
{
|
||||
if ((Profile.EnableAmbient != 0) || (Profile.EnableSignal != 0))
|
||||
{
|
||||
printf(" %20s : %20s\n", "Signal [kcps/spad]", "Ambient [kcps/spad]\r");
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\n");
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
for (j = 0; j < Result->NumberOfZones; j += zones_per_line)
|
||||
{
|
||||
#if 0
|
||||
for (i = 0; i < zones_per_line; i++) /* number of zones per line */
|
||||
{
|
||||
printf(" -----------------");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
for (i = 0; i < zones_per_line; i++)
|
||||
{
|
||||
printf("| ");
|
||||
}
|
||||
printf("|\n");
|
||||
#endif
|
||||
for (l = 0; l < RANGING_SENSOR_NB_TARGET_PER_ZONE; l++)
|
||||
{
|
||||
#if 0
|
||||
/* Print distance and status */
|
||||
for (k = (zones_per_line - 1); k >= 0; k--)
|
||||
{
|
||||
if (Result->ZoneResult[j + k].NumberOfTargets > 0)
|
||||
{ uint16_t distance_i = (long)Result->ZoneResult[j + k].Distance[l];
|
||||
if ((distance_i >sts_low_threshold)&&(distance_i <sts_high_threshold))
|
||||
printf("| \033[38;5;10m%5ld\033[0m :%2d%5ld ", distance_i, (j+k),(long)Result->ZoneResult[j + k].Status[l]);
|
||||
else printf("| %5s : %5s ", " ", " ");
|
||||
}
|
||||
else
|
||||
printf("| %5s : %5s ", " ", " ");
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
/* ---- origin
|
||||
printf("| \033[38;5;10m%5ld\033[0m :%2d%5ld ",
|
||||
(long)Result->ZoneResult[j + k].Distance[l],(j+k),
|
||||
(long)Result->ZoneResult[j + k].Status[l]);
|
||||
*/
|
||||
int32_t roi_distance =(uint32_t)(Result->ZoneResult[j + k].Distance[l]);
|
||||
/* 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_RED;
|
||||
} else {
|
||||
sts_fhmos_data.occupancy_state = 0;
|
||||
sts_lamp_bar_color = STS_GREEN;
|
||||
|
||||
}
|
||||
if ((roi_distance < sts_high_threshold) && (roi_distance > (sts_high_threshold - sts_fhmos_cfg.sts_head_level_height_threshold_cm*10))) // TODO XXX
|
||||
{
|
||||
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)
|
||||
fhmos_fall =2;
|
||||
if (fhmos_fall_counter > 200)
|
||||
fhmos_fall =3;
|
||||
sts_lamp_bar_color = STS_YELLOW;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
int16_t roi_low = (roi_distance - sts_low_threshold)/10;
|
||||
int16_t roi_high = (sts_high_threshold - roi_distance)/10;
|
||||
|
||||
if ((roi_low> 0)&&(roi_high>0))
|
||||
{
|
||||
//printf("| \033[38;5;10m%5ld\033[0m :%2d%5ld ", (uint32_t)(roi_distance-LOW_THRESHOLD), (j+k), (uint32_t)Result->ZoneResult[j + k].Status[l]);
|
||||
printf("| \033[38;5;10m%5d\033[0m : ", (uint16_t)roi_low);
|
||||
}
|
||||
else if ((roi_low< 0)|| (roi_high<0))
|
||||
{
|
||||
//printf("| \033[38;5;10m%5s\033[0m :%2d%5ld ", ".",(j+k), (uint32_t)Result->ZoneResult[j + k].Status[l]);
|
||||
printf("| \033[38;5;10m%5s\033[0m : ", ".");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if ((Profile.EnableAmbient != 0) || (Profile.EnableSignal != 0))
|
||||
{
|
||||
/* Print Signal and Ambient */
|
||||
for (k = (zones_per_line - 1); k >= 0; k--)
|
||||
{
|
||||
if (Result->ZoneResult[j + k].NumberOfTargets > 0)
|
||||
{
|
||||
if (Profile.EnableSignal != 0)
|
||||
{
|
||||
printf("| %5ld : ", (long)Result->ZoneResult[j + k].Signal[l]);
|
||||
}
|
||||
else
|
||||
printf("| %5s : ", "X");
|
||||
|
||||
if (Profile.EnableAmbient != 0)
|
||||
{
|
||||
printf("%5ld ", (long)Result->ZoneResult[j + k].Ambient[l]);
|
||||
}
|
||||
else
|
||||
printf("%5s ", "X");
|
||||
}
|
||||
else
|
||||
printf("| %5s : %5s ", "X", "X");
|
||||
}
|
||||
printf("|\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
for (i = 0; i < zones_per_line; i++)
|
||||
{
|
||||
printf(" -----------------");
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -853,7 +646,8 @@ void STS_FHMOS_sensor_read(sts_fhmos_sensor_data_t *sts_data)
|
|||
sts_data->lamp_bar_color = sts_lamp_bar_color;
|
||||
sts_data->state_hall_1 = sts_hall1_read;
|
||||
sts_data->state_hall_2 = sts_hall2_read;
|
||||
sts_data->state_PIR = sts_pir_result;;
|
||||
sts_data->state_PIR = sts_pir_read;;
|
||||
//sts_data->state_PIR = fhmos_data.state_PIR;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue