From 1a436f6a2ceb04ba8327b71cc4391be8c5667c5d Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Wed, 18 Jun 2025 12:39:01 +0800 Subject: [PATCH] add occupy/vacant color control of dark for ATAL --- Core/Inc/yunhorn_sts_prd_conf.h | 2 +- Core/Inc/yunhorn_sts_sensors.h | 2 +- Core/Src/sts_lamp_bar.c | 6 ++++++ Core/Src/yunhorn_sts_process.c | 11 +++++++--- LoRaWAN/App/app_lorawan.c | 2 +- LoRaWAN/App/lora_app.c | 36 ++++++++++++++++++++++++++------ STM32CubeIDE/.cproject | 1 + STM32CubeIDE/Release/STS_O7.bin | Bin 244124 -> 244252 bytes 8 files changed, 48 insertions(+), 12 deletions(-) diff --git a/Core/Inc/yunhorn_sts_prd_conf.h b/Core/Inc/yunhorn_sts_prd_conf.h index 815e625..49d2d98 100644 --- a/Core/Inc/yunhorn_sts_prd_conf.h +++ b/Core/Inc/yunhorn_sts_prd_conf.h @@ -247,7 +247,7 @@ #define MajorVer 25U #define MinorVer 6U -#define SubMinorVer 17U +#define SubMinorVer 18U #define FirmwareVersion 3U #define YUNHORN_STS_MAX_NVM_CFG_SIZE 64U diff --git a/Core/Inc/yunhorn_sts_sensors.h b/Core/Inc/yunhorn_sts_sensors.h index 6933937..91a26f2 100644 --- a/Core/Inc/yunhorn_sts_sensors.h +++ b/Core/Inc/yunhorn_sts_sensors.h @@ -652,7 +652,7 @@ typedef struct sts_cfg_nvm { uint8_t length; // length of following parameters except AC CODE(20bytes) uint8_t p[STS_O7_CFG_PCFG_SIZE]; - uint8_t reserve02; + uint8_t color_occupy_vacant; // occupy color and vacant color define, C_OCCUPY<<4|C_VACANT uint8_t reserve03; uint8_t sensor_install_height_in_10cm; uint8_t alarm_parameter05; diff --git a/Core/Src/sts_lamp_bar.c b/Core/Src/sts_lamp_bar.c index 9419345..0d321ab 100644 --- a/Core/Src/sts_lamp_bar.c +++ b/Core/Src/sts_lamp_bar.c @@ -56,6 +56,12 @@ extern volatile uint8_t sts_service_mask; extern volatile uint8_t sts_work_mode; volatile uint8_t sts_reed_hall_ext_int = 0; volatile uint8_t sts_status_color = STS_GREEN; +#ifdef ATAL +volatile uint8_t sts_color_occupy_vacant = (STS_RED<<4)|(STS_DARK&0x0f); +#else +volatile uint8_t sts_color_occupy_vacant = (STS_RED<<4)|(STS_GREEN&0x0f); +#endif + volatile uint8_t sts_lamp_bar_color = STS_GREEN; //puColor volatile uint8_t sts_lamp_bar_flashing_color = STS_RED_DARK; //0x23; RED_BLUE; volatile uint8_t sts_cloud_netcolor = STS_GREEN; //netColor diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 94ad41c..23761f8 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -81,7 +81,7 @@ extern volatile uint8_t sts_presence_fall_detection; extern volatile uint8_t last_sts_fall_rising_detected_result; extern volatile uint8_t sts_time_c_threshold; extern volatile uint16_t sts_motionless_duration_threshold_in_min; -extern volatile uint8_t sts_status_color, sts_lamp_bar_color;//puColor +extern volatile uint8_t sts_status_color, sts_lamp_bar_color, sts_color_occupy_vacant;//puColor extern volatile uint8_t sts_cloud_netcolor; //netColor extern uint8_t luminance_level; SysTime_t mems_event_time; @@ -137,6 +137,9 @@ char sts_presence_fall_detection_message[10][20]={ #endif +#define STS_COLOR_DEFAULT_VACANT (sts_color_occupy_vacant&0x0f) +#define STS_COLOR_DEFAULT_OCCUPY ((sts_color_occupy_vacant>>4)&0x0f) + /* // UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP4), CFG_SEQ_Prio_0); @@ -395,11 +398,13 @@ void STS_YunhornSTSEventP3_Process(void) #if (defined(STS_O6) ||defined(STS_O7)) if (STS_Reed_Hall_State == STS_Status_Door_Open) { - sts_lamp_bar_color =STS_GREEN; + // sts_lamp_bar_color =STS_GREEN; + sts_lamp_bar_color = STS_COLOR_DEFAULT_VACANT; } else { - sts_lamp_bar_color =STS_RED; + // sts_lamp_bar_color =STS_RED; + sts_lamp_bar_color = STS_COLOR_DEFAULT_OCCUPY; } STS_Lamp_Bar_Scoller(sts_lamp_bar_color, luminance_level); #endif diff --git a/LoRaWAN/App/app_lorawan.c b/LoRaWAN/App/app_lorawan.c index 0317ebe..fa2c740 100644 --- a/LoRaWAN/App/app_lorawan.c +++ b/LoRaWAN/App/app_lorawan.c @@ -25,7 +25,7 @@ #include "stm32_seq.h" /* USER CODE BEGIN Includes */ - +#include "sts_lamp_bar.h" /* USER CODE END Includes */ /* External variables ---------------------------------------------------------*/ diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 5c3f1c1..aedb5cb 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -57,7 +57,7 @@ extern volatile uint8_t sts_hall1_read, sts_hall2_read, sts_hall3_read, sts_hall volatile uint8_t last_sts_hall1_read=STS_Status_Door_Open, last_sts_hall2_read=STS_Status_SOS_Release, last_sts_hall3_read=STS_Status_Door_Open, last_sts_hall4_read=STS_Status_Door_Open ; volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close -extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color; +extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color, sts_color_occupy_vacant; extern volatile uint8_t sts_lamp_bar_flashing_color; volatile uint8_t last_sts_lamp_bar_color=STS_DARK; extern volatile uint8_t sts_rss_result; @@ -128,7 +128,11 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = { 0x6E, //P[18] RSS_CFG_BG_MOTION_NOISE 2025-04-14 0x8C, //P[19] RSS SLIDING WINDOW CFG: 0x08 AS threshold, 0x0C as window size }, // above 20 bytes - 0x00, //reserve2 +#ifdef ATAL + 0x20, // 0x20 occupy(red:2) | color vacant (dark:0) for ATAL-HK 20241230 +#else + 0x21, // color occupy (red:2) | color vacant (green:1) or other 0x20 occupy(red:2) | color vacant (dark:0) for ATAL-HK 20241230 +#endif 0x00, //reserve3 0x20, //sensor install height in 10 cm, default 32*10=320cm, 3.2meter @@ -1115,7 +1119,7 @@ static void SendTxData(void) } uint8_t ich= (sts_lamp_bar_color>>4 & 0x0f); - uint8_t icl= (sts_lamp_bar_color & 0x0f); + //uint8_t icl= (sts_lamp_bar_color & 0x0f); char colorshow[30]=""; strcpy(colorshow, (ich==0)?"":sts_lamp_color_code[ich]); @@ -2572,7 +2576,26 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size) STS_Combined_Status_Processing(); - } else if (tlv_buf_size == 7 && tlv_buf[CFG_CMD4]=='F') // Change fall detection + } else if (tlv_buf_size == 6 && tlv_buf[CFG_CMD4]=='L') //switch LAMP BAR OCCUPY VACANT COLOR + { + invalid_flag = 0; // P 1 1 L O V + if (((tlv_buf[CFG_CMD5] >='0') && (tlv_buf[CFG_CMD5]<='9')) && ((tlv_buf[CFG_CMD6]<='9') && (tlv_buf[CFG_CMD6]>='0'))) + { + sts_cfg_nvm.color_occupy_vacant = ((uint8_t)(tlv_buf[CFG_CMD5]-0x30)<<4)|((uint8_t)(tlv_buf[CFG_CMD6]-0x30)); + sts_color_occupy_vacant = sts_cfg_nvm.color_occupy_vacant; + APP_LOG(TS_OFF, VLEVEL_M, "\r\n Workmode=%d Color Occupy=%02X Vacant=%02X \r\n", sts_work_mode, STS_COLOR_DEFAULT_OCCUPY, STS_COLOR_DEFAULT_VACANT); + + OnStoreSTSCFGContextRequest(); + + } + + i=0; // Step 1: Prepare status update message + UTIL_MEM_set_8((void*)outbuf, 0x0, sizeof(outbuf)); + UTIL_MEM_cpy_8((void*)outbuf,(void*)tlv_buf, tlv_buf_size); + i = tlv_buf_size; + + } + else if (tlv_buf_size == 7 && tlv_buf[CFG_CMD4]=='F') // Change fall detection { invalid_flag = 0; // P 1 1 F A B C if (((tlv_buf[CFG_CMD5] >='0') && (tlv_buf[CFG_CMD5]<='9')) && ((tlv_buf[CFG_CMD6]<='9') && (tlv_buf[CFG_CMD6]>='0')) @@ -3073,7 +3096,7 @@ void STS_REBOOT_CONFIG_Init(void) for (uint8_t j=0; j< STS_O7_CFG_PCFG_SIZE; j++) { // P RSS CONFIG SIZE= 20U sts_cfg_nvm.p[j] = (uint8_t)nvm_stored_value[NVM_CFG_START+j]; } - sts_cfg_nvm.reserve02 =(uint8_t)nvm_stored_value[NVM_RESERVE02]; + sts_cfg_nvm.color_occupy_vacant =(uint8_t)nvm_stored_value[NVM_RESERVE02]; sts_cfg_nvm.reserve03 =(uint8_t)nvm_stored_value[NVM_RESERVE03]; sts_cfg_nvm.sensor_install_height_in_10cm =(uint8_t)nvm_stored_value[NVM_SENSOR_INSTALL_HEIGHT]; sts_cfg_nvm.alarm_parameter05 =(uint8_t)nvm_stored_value[NVM_ALARM_PARAMETER05]; @@ -3162,6 +3185,7 @@ void OnRestoreSTSCFGContextProcess(void) sts_lamp_bar_color = STS_GREEN; sts_service_mask = sts_cfg_nvm.sts_service_mask; sts_lamp_bar_flashing_color = sts_cfg_nvm.alarm_lamp_bar_flashing_color; + sts_color_occupy_vacant = sts_cfg_nvm.color_occupy_vacant; if (sts_work_mode == STS_UNI_MODE){ sts_presence_fall_detection =TRUE; } else { @@ -3209,7 +3233,7 @@ void STS_SENSOR_Distance_Test_Process(void) void STS_SENSOR_Function_Test_Process(void) { - uint8_t tstbuf[128] ={0x0}; uint8_t i=0, count = 0; + uint8_t tstbuf[128] ={0x0}; uint8_t i=0; //, count = 0; uint8_t mems_Dev_ID[2] = {0x0}; tstbuf[i++] = (uint8_t) 'S'; diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject index 7870d0d..e7876b0 100644 --- a/STM32CubeIDE/.cproject +++ b/STM32CubeIDE/.cproject @@ -154,6 +154,7 @@