From 965b04187c4a6a9840bf6d6ae0b55ec460fe3217 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Thu, 26 Jun 2025 19:17:07 +0800 Subject: [PATCH] minor improve TIME_C --- STM32CubeIDE/.settings/language.settings.xml | 4 ++-- STS/Core/Src/yunhorn_sts_process.c | 4 ++-- STS/TOF/App/app_tof.c | 12 +++++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/STM32CubeIDE/.settings/language.settings.xml b/STM32CubeIDE/.settings/language.settings.xml index 6f79038..d7e3a93 100644 --- a/STM32CubeIDE/.settings/language.settings.xml +++ b/STM32CubeIDE/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c index 86cc5bd..3464589 100644 --- a/STS/Core/Src/yunhorn_sts_process.c +++ b/STS/Core/Src/yunhorn_sts_process.c @@ -2431,7 +2431,7 @@ void YunhornSTSDurationCheckTimer(void) LED_RED_ON; sts_lamp_bar_color = STS_OCCUPANCY_OVERSTAY_COLOR; -// APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor1 overstay set color to %d color:%s\r\n",sts_lamp_bar_color, (char*)code2color[sts_lamp_bar_color]); + APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor1 overstay set color to 0x%02x color: %s\r\n",sts_lamp_bar_color, (char*)code2color[sts_lamp_bar_color]); over_threshold |= 1<<0; // APP_LOG(TS_OFF, VLEVEL_M, "\r\n 1<<1 Over Threshold =0x%02x \r\n", over_threshold); } @@ -2450,7 +2450,7 @@ void YunhornSTSDurationCheckTimer(void) fhmos_data.state_occupancy = STS_FHMOS_OCCUPANCY_NO_OCCUPY; fhmos_data.state_human_movement = STS_FHMOS_HUMAN_MOVEMENT_NO_OCCUPY; sts_lamp_bar_color = STS_VACANT_COLOR; - + APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor1 Door Open, Overstay set color to 0x%02x color: %s\r\n",sts_lamp_bar_color, (char*)code2color[sts_lamp_bar_color]); LED_RED_OFF; LED_GREEN_ON; diff --git a/STS/TOF/App/app_tof.c b/STS/TOF/App/app_tof.c index 7af13bd..58b4195 100644 --- a/STS/TOF/App/app_tof.c +++ b/STS/TOF/App/app_tof.c @@ -57,7 +57,7 @@ extern volatile uint8_t sts_fhmos_bitmap_pending; #include "stm32wlxx_nucleo.h" //static int to_confirm = 0; static uint8_t yes_count=0, no_count=0; -#define TIME_C 2 +#define TIME_C 4 static uint32_t STS_Get_Center_Range_Distance(RANGING_SENSOR_Result_t *Result); uint16_t bg_distance[64]={0}; uint8_t idx[64]={0}; @@ -830,16 +830,21 @@ static void print_result(RANGING_SENSOR_Result_t *Result) //to_confirm ++; if (yes_count < TIME_C) { + yes_count ++; + + APP_LOG(TS_OFF, VLEVEL_M, "\r\n Yes ++ =%d \r\n", yes_count); } else { no_count =0; } - } else if ((head_distance_from_ceiling_mm < (factor2_head_level_from_floor_mm - 150))) // TODO XXX 50mm gap to avoid flapping back and forth + } else //if ((head_distance_from_ceiling_mm < (factor2_head_level_from_floor_mm - 150))) // TODO XXX 50mm gap to avoid flapping back and forth { if (no_count < TIME_C) { no_count ++; + APP_LOG(TS_OFF, VLEVEL_M, "\r\n No ++ =%d \r\n", no_count); + } else { yes_count =0; } @@ -849,7 +854,7 @@ static void print_result(RANGING_SENSOR_Result_t *Result) { sts_head_level_low = 1; - } else if (no_count > (TIME_C -1)) + } else if (no_count > (TIME_C -3)) { sts_head_level_low = 0; @@ -857,6 +862,7 @@ static void print_result(RANGING_SENSOR_Result_t *Result) APP_LOG(TS_OFF, VLEVEL_M, "\r\n return zero statues, bitmap status=%d \r\n", sts_fhmos_bitmap_pending); } + APP_LOG(TS_OFF, VLEVEL_M, "\r\n Yes =%d No =%d head low =%d \r\n", yes_count, no_count, sts_head_level_low); //OnSensorL8AStateChanged(); }