minor improve

This commit is contained in:
Yunhorn 2025-05-22 17:38:30 +08:00
parent f701c5bf46
commit 9d35bc4e42
5 changed files with 37 additions and 19 deletions

View File

@ -149,7 +149,7 @@ void STS_WS2812B_Set_RGB(uint8_t red, uint8_t green, uint8_t blue, uint8_t idx)
void STS_Lamp_Bar_Set_RGB_Color(uint8_t red, uint8_t green, uint8_t blue )
{
uint8_t i =0;
UTIL_MEM_set_8((void*)rgb_buf.GRB,0x00,(WS2812B_DATA_LEN+RESET_PULSE));
//UTIL_MEM_set_8((void*)rgb_buf.GRB,0x00,(WS2812B_DATA_LEN+RESET_PULSE));
for(i = 0; i < STS_LAMP_BAR_LED_NUM; i++)
{

View File

@ -699,7 +699,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
// APP_LOG(TS_OFF, VLEVEL_M,"\r\n EXTI_CALLBACK, Door Open: sts status color =%d, lampbar_color=%d \r\n", sts_status_color, sts_lamp_bar_color);
}
if (last_sts_hall1_read != sts_hall1_read) // to eliminate power drop issue of PCB with long REEDSWITCH CABLES
//if (last_sts_hall1_read != sts_hall1_read) // to eliminate power drop issue of PCB with long REEDSWITCH CABLES
{
// 1) record event start/stop time
APP_LOG(TS_OFF, VLEVEL_M,"\r\n EXIT_CALLBACK, Door state =%d \r\n", sts_hall1_read);
@ -797,16 +797,18 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
if (sts_pir_read ==0)
{
sts_pir_duration_check_time = SysTimeGet();
if (takeLowTime)
{
sts_pir_duration_check_time = SysTimeGet();
//sts_pir_duration_check_time = SysTimeGet();
lowIn = sts_pir_duration_check_time.Seconds;
takeLowTime = false;
}
sts_pir_duration_check_time = SysTimeGet();
if ((!lockLow && (sts_pir_duration_check_time.Seconds - lowIn) > 5))
if ((!lockLow && (sts_pir_duration_check_time.Seconds - lowIn) > 10))
//if ((!lockLow && (sts_pir_duration_check_time.Seconds - sts_pir_start_time.Seconds) > 10))
{
PIRValue = 0;
lockLow = true;
@ -814,8 +816,14 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
APP_LOG(TS_OFF, VLEVEL_M, "\r\n PIRValue=%d \r\n", PIRValue);
if (sts_pir_read != prev_sts_pir_state) {
sts_pir_state_changed = 1;
} else {
sts_pir_state_changed = 0;
}
prev_sts_pir_state = sts_pir_read;
} else {
PIRValue = 1;
sts_pir_read = 1;
}
}
// HAL_Delay(50);
@ -1814,7 +1822,7 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
r_b = !r_b;
}
UTIL_TIMER_Start(&STSLampBarColorTimer);
UTIL_TIMER_Start(&STSLampBarColorTimer);
#if 0
#if defined(STS_O6)||defined(O1L)
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP3), CFG_SEQ_Prio_0);

View File

@ -757,47 +757,48 @@ void USER_APP_Parse_CMD_P(uint8_t *parse_buffer, uint8_t parse_buffer_size)
case 8:
if ((parse_buffer[CFG_CMD4]=='T') && (parse_buffer[CFG_CMD5]>='0')&& (parse_buffer[CFG_CMD5]<='9'))
{
uint8_t sts_fhmos_cfg_index = (uint8_t)(parse_buffer[CFG_CMD5]-0x30);
uint8_t sts_fhmos_cfg_value = (parse_buffer[CFG_CMD6]-0x30)*100+(parse_buffer[CFG_CMD7]-0x30)*10+(parse_buffer[CFG_CMD8]-0x30);
uint8_t sts_fhmos_cfg_index = (uint8_t)(parse_buffer[CFG_CMD5]-0x30)&0x0F; // index < 15
uint8_t sts_fhmos_cfg_value = (uint8_t)(0xff&(parse_buffer[CFG_CMD6]-0x30)*100+(parse_buffer[CFG_CMD7]-0x30)*10+(parse_buffer[CFG_CMD8]-0x30));
APP_LOG(TS_OFF, VLEVEL_M, "\r\nCFG_CMD Index=%d, VALUE =0X%02X =%d \r\n", sts_fhmos_cfg_index, sts_fhmos_cfg_value,sts_fhmos_cfg_value);
switch (sts_fhmos_cfg_index) {
case 1: // head level height threshold
fhmos_cfg.th_head_level_height_cm = sts_fhmos_cfg_value;
fhmos_cfg.th_head_level_height_cm = MIN(sts_fhmos_cfg_value, 150); // LIMITED TO 150CM
break;
case 2:
fhmos_cfg.th_fall_duration_potential_15sec = sts_fhmos_cfg_value;
fhmos_cfg.th_fall_duration_potential_15sec = MIN(sts_fhmos_cfg_value, 99); // POTENTIAL FALL DOWN DURATION
break;
case 3:
fhmos_cfg.th_fall_duration_confirm_15sec = sts_fhmos_cfg_value;
fhmos_cfg.th_fall_duration_confirm_15sec = MIN(sts_fhmos_cfg_value, 99); // HIGH POTENTIAL FALL DOWN DURATION
break;
case 4:
fhmos_cfg.th_motionless_short_15sec = sts_fhmos_cfg_value;
fhmos_cfg.th_motionless_short_15sec = MIN(sts_fhmos_cfg_value, 255); // motionless threshold short
break;
case 5:
fhmos_cfg.th_motionless_long_15sec = sts_fhmos_cfg_value;
fhmos_cfg.th_motionless_long_15sec = MIN(sts_fhmos_cfg_value, 255); // MOTIONLESS THRESHOLD LONG
break;
case 6:
fhmos_cfg.th_occupancy_overstay_15sec = sts_fhmos_cfg_value;
fhmos_cfg.th_occupancy_overstay_15sec = MIN(sts_fhmos_cfg_value, 255); // OVERSTAY THRESHOLD
break;
case 7:
fhmos_cfg.th_gesture_mask_off_height_cm = sts_fhmos_cfg_value;
fhmos_cfg.th_gesture_mask_off_height_cm = MIN(sts_fhmos_cfg_value, 100); // MASK OFF HEIGHT
break;
case 8:
fhmos_cfg.th_fall_body_min_height_cm = sts_fhmos_cfg_value;;
fhmos_cfg.th_fall_body_min_height_cm = MIN(sts_fhmos_cfg_value, 150); // MIN BODY HEIGHT
break;
case 9: // cmd for upload messages
fhmos_cmd.cmd_index = sts_fhmos_cfg_index;
fhmos_cmd.cmd_value = sts_fhmos_cfg_value;
STS_FHMOS_sensor_upload_map(sts_fhmos_cfg_value&0x03);
STS_FHMOS_sensor_upload_map(sts_fhmos_cfg_value&0x07); // 02,03,04
break;
default:
@ -1990,7 +1991,7 @@ void STS_FHMOS_sensor_upload_map(uint8_t map_index)
APP_LOG(TS_OFF, VLEVEL_M, "\r\n +++++++++++++++++++++++ \r\nBitmap Pending to upload flag=%02x index=%d \r\n", sts_fhmos_bitmap_pending, map_index);
uint8_t tstbuf[32] ={0x0};
uint8_t tstbuf[64] ={0x0};
uint8_t i=0;
//tstbuf[i++] = (uint8_t) 'G';
@ -2037,9 +2038,18 @@ void STS_FHMOS_sensor_upload_map(uint8_t map_index)
tstbuf[i++] = (uint8_t) (sts_mask_bitmap[6]);
tstbuf[i++] = (uint8_t) (sts_mask_bitmap[7]);
} else if (map_index == 0x04)
{
tstbuf[i++] = (uint8_t) (33)&0xff; //length of following data
tstbuf[i++] = (uint8_t) map_index; // payload type 0x04=Gesture map
// cube
for (uint8_t cc=0; cc<32; cc++)
{
tstbuf[i++] = (uint8_t) (fhmos_gesture.cube[cc]);
}
}
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Bitmap uploading, size=%02x\r\n", i);
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Bitmap uploading, size=%02d\r\n", i);
int status=STS_SENSOR_Upload_Message(YUNHORN_STS_L8_LORA_APP_DATA_PORT, i, (uint8_t *)tstbuf);
if ((map_index ==0x02)&& (status ==0))
{