fix bug of EXTI_CB, BUT1_PIN HAL_DELAY(50)-150ms

This commit is contained in:
Yunhorn 2024-12-10 12:06:42 +08:00
parent f7d01c83fd
commit d94db6dff2
5 changed files with 16 additions and 13 deletions

View File

@ -614,7 +614,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
/* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
HAL_Delay(50);
HAL_Delay(150);
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
sts_hall1_read = HALL1_STATE;

View File

@ -172,6 +172,7 @@ volatile uint8_t sts_service_mask=STS_SERVICE_MASK_L0;
volatile uint8_t sts_work_mode=STS_TOF_LMZ_RSS_MODE;
volatile uint32_t rfac_timer=0;
volatile uint16_t sts_sensor_install_height=3000;
volatile uint8_t sts_gesture_mask_off_height_cm=10;
volatile uint8_t sensor_data_ready=0;
#if defined(STS_R1)||defined(STS_R5)||defined(STS_R4)||defined(STS_R1D)
@ -571,7 +572,7 @@ void STS_YunhornSTSEventP5_Process(void)
tstbuf[i++] = (uint8_t) (fhmos_gesture_bitmap[6]);
tstbuf[i++] = (uint8_t) (fhmos_gesture_bitmap[7]);
STS_SENSOR_Upload_Message(YUNHORN_STS_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)tstbuf);
STS_SENSOR_Upload_Message(YUNHORN_STS_L8_LORA_APP_DATA_PORT, i, (uint8_t *)tstbuf);
sts_fhmos_bitmap_pending = 2;
}
@ -2438,7 +2439,7 @@ void YunhornSTSDurationCheckTimer(void)
//fhmos_data.head_low_level_start_time = 0;
sts_o7_sensorData.event_sensor3_fall_duration = 0;
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_NORMAL;
sts_fhmos_bitmap_pending == 0;
sts_fhmos_bitmap_pending = 0;
over_threshold &= ~0x20;
over_threshold &= ~0x40;
@ -2608,6 +2609,7 @@ void OnSensor1StateChanged(void)
//sts_o7_sensorData.event_sensor1_duration = 0;
sts_o7_sensorData.over_stay_state = 0;
fhmos_data.state_occupancy = STS_FHMOS_OCCUPANCY_NO_OCCUPY;
fhmos_data.state_fall = STS_FHMOS_FALL_STATE_NO_OCCUPY;
fhmos_data.state_human_movement = STS_FHMOS_HUMAN_MOVEMENT_NO_OCCUPY;

View File

@ -39,6 +39,7 @@ 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_gesture_mask_off_height_cm;
extern volatile uint8_t sts_head_level_low;
volatile sts_fhmos_sensor_config_t fhmos_cfg={70,4,8,8,20,80,50,0};
volatile sts_fhmos_sensor_ambient_height_t fhmos_bg={0x0}, fhmos_gesture={0x0}, fhmos_net={0x0};
@ -184,13 +185,13 @@ void STS_LMZ_Ambient_Height_Scan_Process(void)
fhmos_bg.maskoff[i] = 0;
}
for (i=0;i<8;i++)
sts_mask_bitmap[i]=0;
sts_mask_bitmap[i] =0x0;
// printf("sts sensor install height = %4d \r\n", (int)sts_sensor_install_height);
sts_high_threshold=sts_sensor_install_height;
sts_low_threshold=sts_sensor_install_height-1400;
sts_high_threshold = sts_sensor_install_height;
sts_low_threshold = sts_sensor_install_height-1400;
STS_TOF_L8_Reconfig();
//printf("%c[2H", 27); /* clear screen */
for (uint8_t k=0; k<repeat; k++)
@ -205,7 +206,7 @@ void STS_LMZ_Ambient_Height_Scan_Process(void)
//if (sts_sensor_install_height > range_distance)
fhmos_bg.h2cm[i] += ((uint32_t)sts_sensor_install_height - range_distance);
if (abs(fhmos_bg.h2cm[i])<100){
if (abs(fhmos_bg.h2cm[i])<sts_gesture_mask_off_height_cm*10){
fhmos_bg.maskoff[i] = 0;
} else {
fhmos_bg.maskoff[i] = 1;
@ -248,11 +249,11 @@ void sts_generate_fall_gesture_map(void)
fhmos_gesture.head_xy = 31; //center of FOV
for (i=0;i<8;i++)
fhmos_gesture_bitmap[i]=0;
fhmos_gesture_bitmap[i]=0x0;
for (uint8_t i = 0; i < 64; i++)
{
if ((Result.ZoneResult[i].NumberOfTargets > 0))
if ((Result.ZoneResult[i].NumberOfTargets > 0) && (fhmos_bg.maskoff[i]==0))
{
range_distance = (uint32_t)Result.ZoneResult[i].Distance[0];
if (range_distance < sts_fall_head_position)
@ -260,9 +261,9 @@ void sts_generate_fall_gesture_map(void)
sts_fall_head_position = range_distance; // simply find out the head level
head_xy = i; // head x, y coordination in 8x8 matrix
}
fhmos_gesture.h2cm[i] += ((uint32_t)sts_sensor_install_height - range_distance);
fhmos_gesture.h2cm[i] = (uint16_t)abs(sts_sensor_install_height - range_distance);
fhmos_gesture.maskoff[i]= (abs(fhmos_gesture.h2cm[i])<100)? 0:1;
fhmos_gesture.maskoff[i]= ((fhmos_gesture.h2cm[i])<sts_gesture_mask_off_height_cm*10)? 0:1;
fhmos_gesture_bitmap[(uint8_t)(i/8)] |= (fhmos_gesture.maskoff[i])<<(7-i%8);
// debug
@ -270,7 +271,7 @@ void sts_generate_fall_gesture_map(void)
printf("|%4ld %4d ", range_distance, fhmos_gesture.h2cm[i]);
}
else {
fhmos_gesture.h2cm[i] += 0;
fhmos_gesture.h2cm[i] = 0;
}
}
@ -538,7 +539,7 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
//printf("\r\nj=%d, diff=%d ", j, motion_diff);
motion_power += motion_diff;
prev_distance[j] = (uint16_t)Result->ZoneResult[j].Distance[0];
fhmos_net.h2cm[j] =
}
motion_power /=64;
if (motion_power > fhmos_cfg.th_motion_power_level)