revise door open close logic

This commit is contained in:
Yunhorn 2024-04-15 13:33:02 +08:00
parent 293547e1b3
commit b3b210bb53
5 changed files with 10 additions and 5 deletions

View File

@ -62,7 +62,8 @@ enum sts_oo_work_mode {
STS_OTHER_MODE // ? OTHER MODE
};
#ifdef STS_O7
#define STS_Reed_Hall_State HAL_GPIO_ReadPin(HALL1_GPIO_Port, HALL1_Pin)
#define STS_Reed_Hall_State HALL1_STATE
#define STS_Emergency_Button_State HALL2_STATE
#else
#define STS_Reed_Hall_State HAL_GPIO_ReadPin(BUT1_GPIO_Port, BUT1_Pin)
#endif

View File

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

View File

@ -61,7 +61,7 @@ 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;
volatile uint8_t sts_reed_hall_changed_flag = 1;
volatile uint8_t sts_reed_hall_result =0;
volatile uint8_t sts_reed_hall_result =1, sts_emergency_button_pushed=1; // inital 1 = open
volatile uint8_t sts_hall1_read=0,sts_hall2_read=0;
volatile uint8_t sts_tof_result_changed_flag = 0;
volatile uint8_t sts_water_leakage_result=0;
@ -139,7 +139,7 @@ void STS_YunhornSTSEventP2_Process(void)
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;
@ -149,6 +149,9 @@ void STS_Reed_Hall_Presence_Detection(void)
sts_reed_hall_result = STS_Status_Door_Close;
}
#endif
sts_reed_hall_result = (STS_Reed_Hall_State==STS_Status_Door_Open)? 1:0;
sts_emergency_button_pushed = (STS_Emergency_Button_State==STS_Status_Door_Open)? 1:0;
//sts_reed_hall_result = ((STS_Reed_Hall_State)&STS_Status_Door_Open);

View File

@ -880,7 +880,7 @@ static uint8_t PrepareSendTxData(void)
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor2_on_off); //04 Sensor head #2 status
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor3_on_off); //05 Sensor head #3 status
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor4_on_off); //06 Sensor head #4 status
if (o7_data.state_sensor2_on_off !=0)
//if (o7_data.state_sensor2_on_off != 0)
{
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_distance>>8); //07 MSB distance
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_distance); //08 LSB distance

Binary file not shown.