improved result changed flag logic

This commit is contained in:
Yunhorn 2024-05-17 15:01:34 +08:00
parent 7a29a1f62f
commit 660176b7e3
4 changed files with 19 additions and 11 deletions

View File

@ -91,7 +91,7 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Pin = HALL1_Pin|HALL2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
#else
/*Configure GPIO pins : PAPin PAPin */

View File

@ -67,12 +67,14 @@ extern volatile uint8_t sts_reed_hall_1_result, sts_reed_hall_2_result;
extern volatile uint8_t sts_tof_result_changed_flag;
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_reed_hall_1_changed_flag, sts_reed_hall_2_changed_flag;
extern volatile uint8_t sts_rss_result_changed_flag, sts_hall_1_changed_flag, sts_hall_2_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;
#ifdef STS_M1
extern volatile uint8_t sts_water_leakage_changed_flag;
#endif
//extern volatile uint8_t last_sts_reed_hall_result = 2; //Initial state, not 0, not 1
volatile uint8_t last_lamp_bar_color=STS_GREEN;
extern volatile uint8_t sts_presence_fall_detection;
@ -410,11 +412,14 @@ void STS_Combined_Status_Processing(void)
STS_Lamp_Bar_Refresh();
#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_1_changed_flag)|| (sts_reed_hall_2_changed_flag) || (sts_tof_result_changed_flag) )
//|| (sts_water_leakage_changed_flag))
{
//sts_rss_result_changed_flag =0;
sts_reed_hall_changed_flag =0;
sts_rss_result_changed_flag =0;
sts_reed_hall_1_changed_flag =0;
sts_reed_hall_2_changed_flag =0;
sts_tof_result_changed_flag =0;
#ifdef STS_M1
sts_water_leakage_changed_flag=0;

View File

@ -75,6 +75,7 @@ SysTime_t mems_event_time;
extern volatile uint8_t sts_reed_hall_ext_int;
volatile uint8_t sts_occupancy_status;
volatile uint8_t sts_reed_hall_1_changed_flag=0, sts_reed_hall_2_changed_flag=0;
volatile uint8_t sts_hall1_changed_flag=0, sts_hall2_changed_flag=0, last_sts_hall1_result=0, last_sts_hall2_result=0;
volatile uint8_t sts_reed_hall_changed_flag = 0;
extern volatile uint8_t sts_reed_hall_result;
@ -218,11 +219,11 @@ void STS_YunhornSTSEventP1_Process(void)
{
sts_reed_hall_1_result = HALL1_STATE; //sts_hall1_read;
sts_reed_hall_1_changed =0;
sts_reed_hall_1_changed_flag =(sts_reed_hall_1_result == last_sts_reed_hall_1_result)? 0:1;
last_sts_reed_hall_1_result = sts_reed_hall_1_result;
sts_reed_hall_2_result = HALL2_STATE;// sts_hall2_read;
sts_reed_hall_2_changed =0;
sts_reed_hall_2_changed_flag =(sts_reed_hall_2_result == last_sts_reed_hall_2_result)? 0:1;
last_sts_reed_hall_2_result = sts_reed_hall_2_result;
STS_Combined_Status_Processing();

View File

@ -847,13 +847,15 @@ static void SendTxData(void)
AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.over_stay_duration>>8)&0xff; //13 occupancy over time or not
AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.over_stay_duration)&0xff; //13 occupancy over time or not
#endif
#if 1
#if 0
APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| Color | Mode |\r\n######| %6s | %5s|\r\n",(char *)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[AppData.Buffer[1]]);
#endif
#if 1
APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| S1-DoorOpen | S2-Motion | S3-No_Emergency| S4 | Distance(mm) | MotionScore|\r\n######| %6u | %6u | %6u | %6u | %4u | %4u |\r\n",
AppData.Buffer[2], AppData.Buffer[3],AppData.Buffer[4],AppData.Buffer[5],AppData.Buffer[6]<<8|AppData.Buffer[7],AppData.Buffer[8]<<8|AppData.Buffer[9]);
#endif
#if 0
APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| Unconcious | Fall state| Over_Stay state| OverStayduration|\r\n######| %1d | %1d | %1d | %4d |\r\n",
sts_o7_sensorData.unconcious_state, sts_o7_sensorData.fall_state, sts_o7_sensorData.over_stay_duration, sts_o7_sensorData.unconcious_duration );