Compare commits

..

2 Commits

Author SHA1 Message Date
Yunhorn aeee635eeb door open/close logic 2024-04-15 18:32:51 +08:00
Yunhorn 00958c56eb revise GPIO pull up instead of nopull 2024-04-15 16:39:29 +08:00
4 changed files with 16 additions and 19 deletions

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, sts_emergency_button_result=0; // inital 1 = closed
volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close
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;
@ -150,9 +150,9 @@ void STS_Reed_Hall_Presence_Detection(void)
}
#endif
sts_reed_hall_result = (sts_hall1_read==STS_Status_Door_Open)? 0:1;
sts_reed_hall_result = (sts_hall1_read==0)?STS_Status_Door_Close:STS_Status_Door_Open;
sts_emergency_button_result = (sts_hall2_read==STS_Status_Door_Open)? 0:1;
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);

View File

@ -49,7 +49,7 @@ volatile uint32_t event_start_time, event_stop_time, sensor_data_ready;
extern volatile STS_OO_RSS_SensorTuneDataTypeDef sts_presence_rss_config;
extern volatile sts_cfg_nvm_t sts_cfg_nvm;
extern volatile uint8_t sts_fall_detection_acc_threshold, sts_fall_detection_depth_threshold, sts_occupancy_overtime_threshold;
extern volatile uint8_t sts_reed_hall_result, sts_emergency_button_result, sts_rss_result, sts_rss_2nd_result,sts_tof_result, sts_status_color, sts_lamp_bar_color, sts_work_mode, sts_service_mask;
extern volatile uint8_t sts_reed_hall_result, sts_emergency_button_pushed, sts_rss_result, sts_rss_2nd_result,sts_tof_result, sts_status_color, sts_lamp_bar_color, sts_work_mode, sts_service_mask;
extern volatile distance_measure_cfg_t distance_cfg;
extern uint8_t sts_fall_rising_detected_result;
extern volatile uint16_t sts_fall_rising_pattern_factor1;
@ -273,7 +273,7 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(void)
sts_o7_sensorData.workmode = sts_work_mode;
sts_o7_sensorData.state_sensor1_on_off = sts_reed_hall_result;
sts_o7_sensorData.state_sensor2_on_off = sts_rss_result;
sts_o7_sensorData.state_sensor3_on_off = sts_emergency_button_result;
sts_o7_sensorData.state_sensor3_on_off = sts_emergency_button_pushed;
sts_o7_sensorData.state_sensor4_on_off = sts_rss_2nd_result;
if (sts_rss_result == STS_RESULT_MOTION)
{

View File

@ -592,10 +592,7 @@ void LoRaWAN_Init(void)
STS_REBOOT_CONFIG_Init();
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventRFAC), UTIL_SEQ_RFU, STS_YunhornSTSEventRFAC_Process);
#ifdef STS_O7
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), UTIL_SEQ_RFU, STS_YunhornSTSEventP1_Process);
#endif
#if 0
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP2), UTIL_SEQ_RFU, STS_YunhornSTSEventP2_Process);
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP3), UTIL_SEQ_RFU, STS_YunhornSTSEventP3_Process);
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP4), UTIL_SEQ_RFU, STS_YunhornSTSEventP4_Process);
@ -603,7 +600,7 @@ void LoRaWAN_Init(void)
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP6), UTIL_SEQ_RFU, STS_YunhornSTSEventP6_Process);
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP7), UTIL_SEQ_RFU, STS_YunhornSTSEventP7_Process);
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP8), UTIL_SEQ_RFU, STS_YunhornSTSEventP8_Process);
#endif
#ifdef YUNHORN_STS_O7_ENABLED
UTIL_TIMER_Create(&YunhornSTSRSSWakeUpTimer,
YUNHORN_STS_RSS_WAKEUP_CHECK_TIME,
@ -645,7 +642,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
case HALL2_Pin:
sts_hall2_read = HALL2_STATE;
// UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0);
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;
@ -785,7 +782,7 @@ static uint8_t PrepareSendTxData(void)
uint16_t batteryLevelmV = SYS_GetBatteryLevel();
SysTime_t occupy_check_time = SysTimeGetMcuTime();
//sensor_t sensor_data;
STS_OO_SensorStatusDataTypeDef o7_data;
//STS_OO_SensorStatusDataTypeDef o7_data;
STS_PRESENCE_SENSOR_Prepare_Send_Data();
//STS_PRESENCE_SENSOR_Read(&o7_data);
@ -823,7 +820,7 @@ static uint8_t PrepareSendTxData(void)
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.battery_Pct); //02 Battery Level %
AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV >>8); //03 Battery mV MSB
AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV ); //04 Battery mV LSB
APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| Mode S1 BAT % BAT mV |"
APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| Mode S1-Open BAT % BAT mV |"
"\r\n######| %1d | %1d | %2d% | %4d mV|\r\n",
(char*)sts_work_mode_code[(uint8_t)sts_work_mode], AppData.Buffer[2], AppData.Buffer[3], batteryLevelmV);
@ -838,7 +835,7 @@ static uint8_t PrepareSendTxData(void)
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
APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| Color | Mode | S1 | S2 | S3 | S4 |"
"\r\n######| Color | Mode | S1-Open | S2-Motion | S3-Open | S4 |"
"\r\n######|%10s | %15s | %1d | %1d | %1d | %1d |\r\n",
(char*)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[(uint8_t)AppData.Buffer[1]], AppData.Buffer[2],AppData.Buffer[3], AppData.Buffer[4],AppData.Buffer[5]);
break;
@ -852,8 +849,8 @@ static uint8_t PrepareSendTxData(void)
AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV >>8); //03 Battery mV MSB
AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV ); //04 Battery mV LSB
APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| Color | Mode | S1 | VBAT in mV|"
"\r\n######|%10s | %15s | %1d | %2d% | %4d mV|\r\n",
"\r\n######| Color | Mode | S1-Open | VBAT in mV|"
"\r\n######|%10s | %15s | %1d | %2d% | %4d mV|\r\n",
(char*)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[(uint8_t)AppData.Buffer[1]], AppData.Buffer[2],AppData.Buffer[3], batteryLevelmV);
break;
@ -870,8 +867,8 @@ static uint8_t PrepareSendTxData(void)
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_score); //07 LSB score
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_occupancy_overtime_state); //08 occupancy over time or not
APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| Color | Mode | S2 | |Distance(mm) | MotionScore|"
"\r\n######|%10s | %15s | %1d | %04d | %04d |\r\n",
"\r\n######| Color | Mode | S2-Motion | |Distance(mm) | MotionScore|"
"\r\n######|%10s | %15s | %1d | %04d | %04d |\r\n",
(char*)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[(uint8_t)AppData.Buffer[1]], AppData.Buffer[2], (uint16_t)sts_o7_sensorData.rss_presence_distance,(uint16_t)sts_o7_sensorData.rss_presence_score);
@ -893,8 +890,8 @@ static uint8_t PrepareSendTxData(void)
}
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_occupancy_overtime_state); //11 occupancy over time or not
APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| Color | Mode | S1 | S2 | S3 | S4 |Distance(mm) | MotionScore|"
"\r\n######|%10s | %15s | %1d | %1d | %1d | %1d | %04d | %04d |\r\n",
"\r\n######| Color | Mode | S1-Open | S2-Motion | S3-Open | S4 |Distance(mm) | MotionScore|"
"\r\n######|%10s | %15s | %1d | %1d | %1d | %1d | %04d | %04d |\r\n",
(char *)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[AppData.Buffer[1]],AppData.Buffer[2], AppData.Buffer[3],AppData.Buffer[4], AppData.Buffer[5], (uint16_t)sts_o7_sensorData.rss_presence_distance,(uint16_t)sts_o7_sensorData.rss_presence_score);
default:
break;

Binary file not shown.