combined sts_process
This commit is contained in:
parent
24e62b5c80
commit
6af9e82016
|
@ -94,14 +94,7 @@ void STS_Lamp_Bar_Scoller(uint8_t color, uint8_t luminance_level);
|
|||
void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t luminance_level);
|
||||
void STS_Lamp_Bar_Refresh(void);
|
||||
|
||||
void STS_YunhornSTSEventP1_Process(void);
|
||||
void STS_YunhornSTSEventP2_Process(void);
|
||||
void STS_YunhornSTSEventP3_Process(void);
|
||||
void STS_YunhornSTSEventP4_Process(void);
|
||||
void STS_YunhornSTSEventP5_Process(void);
|
||||
void STS_YunhornSTSEventP6_Process(void);
|
||||
void STS_YunhornSTSEventP7_Process(void);
|
||||
void STS_YunhornSTSEventP8_Process(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -580,6 +580,14 @@ void OnRestoreSTSCFGContextProcess(void);
|
|||
* @brief Read duty cycle level count from flash
|
||||
*/
|
||||
//uint8_t * read_duty_cycle_level_from_flash(uint8_t *flash_code_duty_cycle_level, uint32_t Save_Config_Flash_Addr);
|
||||
void STS_YunhornSTSEventP1_Process(void);
|
||||
void STS_YunhornSTSEventP2_Process(void);
|
||||
void STS_YunhornSTSEventP3_Process(void);
|
||||
void STS_YunhornSTSEventP4_Process(void);
|
||||
void STS_YunhornSTSEventP5_Process(void);
|
||||
void STS_YunhornSTSEventP6_Process(void);
|
||||
void STS_YunhornSTSEventP7_Process(void);
|
||||
void STS_YunhornSTSEventP8_Process(void);
|
||||
|
||||
void STS_SENSOR_Power_ON(uint8_t cnt);
|
||||
void STS_SENSOR_Power_OFF(uint8_t cnt);
|
||||
|
|
|
@ -53,26 +53,26 @@ volatile WS2812B_FrameTypeDef rgb_buf = {
|
|||
uint8_t color_rgb[8][3] = { //STS_COLOR R G B MAPPING TABLE
|
||||
{0,0,0},{0,1,0},{1,0,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,1,1}
|
||||
};
|
||||
volatile uint8_t sts_service_mask;
|
||||
volatile uint8_t sts_work_mode = STS_DUAL_MODE;
|
||||
extern volatile uint8_t sts_service_mask;
|
||||
extern volatile uint8_t sts_work_mode;
|
||||
volatile uint8_t sts_reed_hall_ext_int = 0;
|
||||
volatile uint8_t sts_status_color = STS_DARK;
|
||||
volatile uint8_t sts_lamp_bar_color = STS_GREEN; //puColor
|
||||
volatile uint8_t sts_cloud_netcolor = STS_GREEN; //netColor
|
||||
volatile uint8_t sts_occupancy_status;
|
||||
extern volatile uint8_t sts_occupancy_status;
|
||||
|
||||
volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close
|
||||
extern volatile uint8_t sts_reed_hall_result, sts_emergency_button_pushed; // inital 0 = close
|
||||
volatile uint8_t sts_hall1_read=0,sts_hall2_read=0; // Above hall1_read == reed_hall_result, hall2_read == emergency_button
|
||||
volatile uint8_t sts_tof_result_changed_flag = 0;
|
||||
volatile uint8_t sts_water_leakage_result=0;
|
||||
volatile uint8_t sts_water_leakage_changed_flag=0;
|
||||
extern volatile uint8_t sts_tof_result_changed_flag;
|
||||
|
||||
volatile uint8_t sts_rss_result_changed_flag = 0, sts_hall1_changed_flag=0, sts_hall2_changed_flag=0, sts_reed_hall_changed_flag = 0;
|
||||
volatile uint8_t sts_rss_result = STS_RESULT_NO_MOTION;
|
||||
volatile uint8_t sts_rss_2nd_result = STS_RESULT_NO_MOTION; //2nd RSS sensor status
|
||||
volatile uint8_t sts_tof_result = STS_RESULT_NO_MOTION;
|
||||
volatile uint8_t last_sts_rss_result, last_sts_hall1_result, last_sts_hall2_result;
|
||||
volatile uint8_t last_sts_reed_hall_result = 2; //Initial state, not 0, not 1
|
||||
|
||||
|
||||
extern volatile uint8_t sts_rss_result_changed_flag, sts_hall1_changed_flag, sts_hall2_changed_flag, sts_reed_hall_changed_flag;
|
||||
extern volatile uint8_t sts_rss_result;
|
||||
extern volatile uint8_t sts_rss_2nd_result; //2nd RSS sensor status
|
||||
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 float sts_presence_rss_distance;
|
||||
|
@ -81,187 +81,9 @@ extern SysTime_t mems_event_time;
|
|||
extern volatile uint32_t event_start_time, event_stop_time;
|
||||
uint8_t luminance_level = DEFAULT_LUMINANCE_LEVEL;
|
||||
|
||||
void STS_YunhornSTSEventP1_Process(void)
|
||||
{
|
||||
STS_Lamp_Bar_Refresh();
|
||||
if ((sts_work_mode == STS_WIRED_MODE) || (sts_work_mode == STS_REEDSWITCH_MODE) || (sts_work_mode == STS_DUAL_MODE))
|
||||
{
|
||||
STS_Reed_Hall_Presence_Detection();
|
||||
|
||||
if (sts_reed_hall_result == last_sts_reed_hall_result) {
|
||||
sts_reed_hall_changed_flag = 0;
|
||||
} else {
|
||||
sts_reed_hall_changed_flag = 1;
|
||||
STS_Combined_Status_Processing();
|
||||
}
|
||||
|
||||
last_sts_reed_hall_result = sts_reed_hall_result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void STS_YunhornSTSEventP2_Process(void)
|
||||
{
|
||||
STS_Lamp_Bar_Refresh(); //TODO XXX eliminate refresh every second.... try
|
||||
if ((sts_work_mode >= STS_RSS_MODE) && (sts_work_mode <= STS_TOF_RSS_MODE))
|
||||
{
|
||||
STS_RSS_Smart_Presence_Detection();
|
||||
STS_Reed_Hall_Presence_Detection();
|
||||
#if 0
|
||||
if (sts_rss_result == last_sts_rss_result) {
|
||||
sts_rss_result_changed_flag =0;
|
||||
} else {
|
||||
sts_rss_result_changed_flag =1;
|
||||
last_sts_rss_result = sts_rss_result;
|
||||
}
|
||||
#endif
|
||||
sts_rss_result_changed_flag = (sts_rss_result == last_sts_rss_result)? 0:1;
|
||||
last_sts_rss_result = sts_rss_result;
|
||||
#if 0
|
||||
if (sts_reed_hall_result == last_sts_reed_hall_result)
|
||||
{
|
||||
sts_reed_hall_changed_flag = 0;
|
||||
|
||||
} else
|
||||
{
|
||||
sts_reed_hall_changed_flag = 1;
|
||||
}
|
||||
#endif
|
||||
sts_hall1_changed_flag = (sts_hall1_read == last_sts_hall1_result)? 0:1;
|
||||
last_sts_hall1_result = sts_hall1_read;
|
||||
sts_hall2_changed_flag = (sts_hall2_read == last_sts_hall2_result)? 0:1;
|
||||
last_sts_hall2_result = sts_hall2_read;
|
||||
sts_reed_hall_changed_flag = sts_hall1_changed_flag|sts_hall2_changed_flag;
|
||||
sts_reed_hall_result = last_sts_hall2_result|last_sts_hall1_result;
|
||||
sts_reed_hall_changed_flag = (sts_reed_hall_result == last_sts_reed_hall_result)? 0:1;
|
||||
|
||||
if (sts_service_mask > 0 ) {
|
||||
sts_rss_result_changed_flag =0;
|
||||
sts_reed_hall_changed_flag = 0;
|
||||
}
|
||||
|
||||
STS_Combined_Status_Processing();
|
||||
|
||||
last_sts_rss_result = sts_rss_result;
|
||||
last_sts_reed_hall_result = sts_reed_hall_result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void STS_Reed_Hall_Presence_Detection(void)
|
||||
{
|
||||
// HAL_Delay(50); // BOUNCING ELIMIATION
|
||||
#if 0
|
||||
if (STS_Reed_Hall_State == STS_Status_Door_Open)
|
||||
{
|
||||
sts_reed_hall_result = STS_Status_Door_Open;
|
||||
|
||||
} else if (STS_Reed_Hall_State == STS_Status_Door_Close)
|
||||
{
|
||||
sts_reed_hall_result = STS_Status_Door_Close;
|
||||
|
||||
}
|
||||
#endif
|
||||
sts_reed_hall_result = (sts_hall1_read==0)?STS_Status_Door_Close:STS_Status_Door_Open;
|
||||
|
||||
sts_emergency_button_pushed = (sts_hall2_read==0)?STS_Status_Door_Close:STS_Status_Door_Open; //(STS_Emergency_Button_State==STS_Status_Door_Open)? 0:1;
|
||||
|
||||
//sts_reed_hall_result = ((STS_Reed_Hall_State)&STS_Status_Door_Open);
|
||||
|
||||
// HAL_Delay(20); // BOUNCING ELIMIATION
|
||||
|
||||
sts_reed_hall_changed_flag = 0;
|
||||
|
||||
sts_reed_hall_ext_int = 0;
|
||||
|
||||
}
|
||||
|
||||
void STS_RSS_Smart_Presence_Detection(void)
|
||||
{
|
||||
STS_Lamp_Bar_Refresh();
|
||||
|
||||
//sts_presence_rss_presence_detection();
|
||||
|
||||
sts_presence_rss_fall_rise_detection();
|
||||
|
||||
// if (sts_presence_fall_detection) {
|
||||
// STS_YunhornSTSFallDetection();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* STS P3 process, Lamp Bar Scoller
|
||||
*/
|
||||
void STS_YunhornSTSEventP3_Process(void)
|
||||
{
|
||||
STS_Lamp_Bar_Refresh();
|
||||
if (STS_Reed_Hall_State == STS_Status_Door_Open)
|
||||
{
|
||||
sts_lamp_bar_color =STS_GREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
sts_lamp_bar_color =STS_RED;
|
||||
}
|
||||
STS_Lamp_Bar_Scoller(sts_lamp_bar_color, luminance_level);
|
||||
}
|
||||
|
||||
/*
|
||||
* STS SOAP Level detection Process, STS_CAP_Sensor_Detection Process
|
||||
* STS_CAP_SWITCH(ON) Boost Voltage to 5V, then hold for 1000 ms
|
||||
* HAL_Delay(1000) (ms)
|
||||
* STS_CAP_Read_Data() Read STS_CAP_DATA state
|
||||
* STS_CAP_SWITCH(OFF) Switch Off Boosted Voltage
|
||||
*/
|
||||
void STS_YunhornSTSEventP4_Process(void)
|
||||
{
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n P4 Testing Process\r\n");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* STS P5 Process, Detection ToF distance (VL53L0X)
|
||||
*
|
||||
*/
|
||||
|
||||
void STS_YunhornSTSEventP5_Process(void)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n P5 Testing Process\r\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* STS P6 Process, Detection ToF IN-OUT PEOPLE COUNT (VL53L3X)
|
||||
*
|
||||
*/
|
||||
|
||||
void STS_YunhornSTSEventP6_Process(void)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n P6 Testing Process\r\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* STS P7 Process, Detection IAQ Sensors
|
||||
* air quality and odor level sensors
|
||||
*/
|
||||
|
||||
void STS_YunhornSTSEventP7_Process(void)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n P7 Testing Process\r\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* STS P8 Process, Detection xxx Sensors
|
||||
* xxx sensors
|
||||
*/
|
||||
|
||||
void STS_YunhornSTSEventP8_Process(void)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n P8 Testing Process\r\n");
|
||||
}
|
||||
|
||||
|
||||
void STS_Lamp_Bar_Set_Dark(void)
|
||||
|
@ -438,8 +260,10 @@ void STS_Combined_Status_Processing(void)
|
|||
break;
|
||||
case STS_WIRED_MODE: // NO LAMP BAR FOR THOSE WATER LEAKAGE SENSOR OR SOAP CAPACITY SENSORS
|
||||
sts_status_color = STS_DARK;
|
||||
#ifdef STS_M1
|
||||
sts_water_leakage_result = (sts_reed_hall_result == STS_Status_Door_Open )?STS_RESULT_WATER_LEAKAGE_YES:STS_RESULT_WATER_LEAKAGE_NO;
|
||||
sts_water_leakage_changed_flag = 1;
|
||||
#endif
|
||||
break;
|
||||
case STS_REEDSWITCH_MODE:
|
||||
|
||||
|
@ -560,14 +384,16 @@ void STS_Combined_Status_Processing(void)
|
|||
}
|
||||
}
|
||||
#if 1
|
||||
if ((sts_rss_result_changed_flag)|| (sts_reed_hall_changed_flag) || (sts_tof_result_changed_flag) || (sts_water_leakage_changed_flag))
|
||||
//if ((sts_rss_result_changed_flag)|| (sts_reed_hall_changed_flag) || (sts_tof_result_changed_flag) || (sts_water_leakage_changed_flag))
|
||||
{
|
||||
sensor_data_ready = 1;
|
||||
STS_PRESENCE_SENSOR_Prepare_Send_Data();
|
||||
sts_rss_result_changed_flag =0;
|
||||
sts_reed_hall_changed_flag =0;
|
||||
sts_tof_result_changed_flag =0;
|
||||
#ifdef STS_M1
|
||||
sts_water_leakage_changed_flag=0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -399,7 +399,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
}
|
||||
|
||||
acc_detector_presence_deactivate(handle);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"First Half Presence Detection, Motion Count = %u \r\n", (int)motion_count);
|
||||
APP_LOG(TS_OFF, VLEVEL_H,"First Half Presence Detection, Motion Count = %u \r\n", (int)motion_count);
|
||||
|
||||
// ******** Second Half detection of fall down and rise up
|
||||
|
||||
|
@ -457,7 +457,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // DEFAULT_UPDATE_RATE);
|
||||
}
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
|
||||
APP_LOG(TS_OFF, VLEVEL_H,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
|
||||
|
||||
sts_rss_result = (average_result > 3)? 1: 0;
|
||||
average_distance = (1000.0f*average_distance)/average_result; // in meters
|
||||
|
@ -466,7 +466,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
sts_presence_rss_score = average_score;
|
||||
if (sts_rss_result) //if (average_score !=0) //if (sts_rss_result)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"\r\n######## Motion: %u Distance=%u mm, Score=%u Average_result=%u out of %u \r\n",
|
||||
APP_LOG(TS_OFF, VLEVEL_H,"\r\n######## Motion: %u Distance=%u mm, Score=%u Average_result=%u out of %u \r\n",
|
||||
(uint8_t)sts_rss_result,(int) average_distance, (int)(average_score), (int)average_result, (int)iterations);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -51,7 +51,9 @@ volatile uint8_t sts_ac_code[YUNHORN_STS_AC_CODE_SIZE]={0x0};
|
|||
extern hmac_result_t hmac_result;
|
||||
extern volatile uint8_t sts_reed_hall_ext_int;
|
||||
extern volatile uint8_t sts_hall1_read, sts_hall2_read;
|
||||
volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close
|
||||
extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color;
|
||||
extern volatile uint8_t sts_rss_result_changed_flag, sts_hall1_changed_flag, sts_hall2_changed_flag, sts_reed_hall_changed_flag;
|
||||
volatile uint8_t sts_fall_detection_acc_threshold = 10, sts_fall_detection_depth_threshold=30, sts_occupancy_overtime_threshold=20;
|
||||
extern volatile uint32_t event_start_time, event_stop_time;
|
||||
extern volatile uint16_t sts_unconcious_threshold;
|
||||
|
@ -631,25 +633,30 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
#ifdef STS_O7
|
||||
case HALL1_Pin:
|
||||
//sts_reed_hall_ext_int = 1;
|
||||
HAL_Delay(50); //de-bouncing
|
||||
sts_hall1_read = HALL1_STATE;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n\n Door Contact Read = %02X \r\n", HALL1_STATE);
|
||||
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0);
|
||||
/* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
|
||||
// if (EventType == TX_ON_EVENT)
|
||||
{
|
||||
sensor_data_ready =1;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
}
|
||||
break;
|
||||
|
||||
case HALL2_Pin:
|
||||
HAL_Delay(50); //de-bouncing
|
||||
sts_hall2_read = HALL2_STATE;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n\n SOS Button Read = %02X \r\n", HALL2_STATE);
|
||||
sensor_data_ready =1;
|
||||
// UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0);
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
break;
|
||||
|
||||
#else
|
||||
case BUT1_Pin:
|
||||
HAL_Delay(20); //de-bouncing
|
||||
//sts_reed_hall_ext_int = 1;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0);
|
||||
//sts_reed_hall_ext_int = 0;
|
||||
|
|
|
@ -528,9 +528,9 @@
|
|||
<locationURI>copy_PARENT/Core/Src/yunhorn_sts_presence_rss_bring_up_test.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Application/User/Core/yunhorn_sts_presence_sensor.c</name>
|
||||
<name>Application/User/Core/yunhorn_sts_process.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>copy_PARENT/Core/Src/yunhorn_sts_presence_sensor.c</locationURI>
|
||||
<locationURI>copy_PARENT/Core/Src/yunhorn_sts_process.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo.c</name>
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue