diff --git a/Core/Inc/sts_lamp_bar.h b/Core/Inc/sts_lamp_bar.h index 739da24..8c78f07 100644 --- a/Core/Inc/sts_lamp_bar.h +++ b/Core/Inc/sts_lamp_bar.h @@ -44,7 +44,9 @@ enum sts_lamp_color { STS_PINK, //紫:5 1 0 1 STS_CYAN, //青:6 0 1 1 STS_WHITE, //白:7 1 1 1 - STS_RED_BLUE //红蓝闪烁:8 + STS_RED_BLUE, //红蓝闪烁:8 + STS_RED_DARK, //RD: 9 1 0 0 RED Flash + STS_COLOR_MAX // MAX NUM OF COLORS }; enum sts_oo_work_mode { diff --git a/Core/Inc/yunhorn_sts_prd_conf.h b/Core/Inc/yunhorn_sts_prd_conf.h index 95fe2b0..68a71cf 100644 --- a/Core/Inc/yunhorn_sts_prd_conf.h +++ b/Core/Inc/yunhorn_sts_prd_conf.h @@ -217,7 +217,7 @@ #define YUNHORN_STS_AC_CODE_SIZE 20U #define STS_O7_NVM_CFG_SIZE 32U -#define STS_O7_CFG_PCFG_SIZE 28U +#define STS_O7_CFG_PCFG_SIZE 20U #define STS_O7_CFG_CMD_SIZE 30U #define STS_O7_CFG_CMD_SHORT_LEN 8U #define STS_MODE_COLOR_CMD_LEN 5U diff --git a/Core/Inc/yunhorn_sts_sensors.h b/Core/Inc/yunhorn_sts_sensors.h index ea279af..58efb3c 100644 --- a/Core/Inc/yunhorn_sts_sensors.h +++ b/Core/Inc/yunhorn_sts_sensors.h @@ -533,7 +533,9 @@ enum nvm_order { //13, p[1] //14, p[2] // ... - //39, P[27] + //32, P[19] + // ... + NVM_LAMP_BAR_FLASHING_COLOR=39, //39, P[27] NVM_FALL_DETECTION_ACC_THRESHOLD=40, //40 NVM_FALL_DETECTION_DEPTH_THRESHOLD, //41 NVM_FALL_UNCONCIOUS_THRESHOLD, //42 @@ -556,6 +558,15 @@ typedef struct sts_cfg_nvm { uint8_t reseve01; uint8_t length; // length of following parameters except AC CODE(20bytes) uint8_t p[STS_O7_CFG_PCFG_SIZE]; + + uint8_t reserve02; + uint8_t reserve03; + uint8_t reserve04; + uint8_t reserve05; + uint8_t reserve06; + uint8_t reserve07; + uint8_t reserve08; + uint8_t lamp_bar_flashing_color; //Lamp Bar Flashing color define, 0x20, 2==STS_RED, 0 = STS_DARK, 0x23, 2=STS_RED, 3=STS_BLUE uint8_t fall_detection_acc_threshold; // 0 - 9: 0:disable: 1-9 accelaration mg/s2 uint8_t fall_detection_depth_threshold; // 0 - 9: 0:disable: 1-9 fall down depth * 10 cm uint8_t fall_unconcious_threshold; //motion level *10 diff --git a/Core/Src/sts_lamp_bar.c b/Core/Src/sts_lamp_bar.c index 0677d88..0aed368 100644 --- a/Core/Src/sts_lamp_bar.c +++ b/Core/Src/sts_lamp_bar.c @@ -58,6 +58,7 @@ extern volatile uint8_t sts_work_mode; volatile uint8_t sts_reed_hall_ext_int = 0; volatile uint8_t sts_status_color = STS_GREEN; volatile uint8_t sts_lamp_bar_color = STS_GREEN; //puColor +volatile uint8_t sts_lamp_bar_flashing_color = 0x23; // RED_BLUE; volatile uint8_t sts_cloud_netcolor = STS_GREEN; //netColor extern volatile uint8_t sts_occupancy_status; @@ -437,7 +438,7 @@ void STS_Lamp_Bar_Self_Test_Simple(void) { uint8_t color=0, lum_level=DEFAULT_LUMINANCE_LEVEL; APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#1] RGB Space Lumianance Level Testing Start\r\n"); - for (color=STS_GREEN; color <= STS_RED_BLUE; color++) + for (color=STS_GREEN; color < STS_COLOR_MAX; color++) { lum_level = 10; do { @@ -458,7 +459,7 @@ void STS_Lamp_Bar_Self_Test(void) STS_Lamp_Bar_Self_Test_Simple(); APP_LOG(TS_OFF, VLEVEL_H, "\r\n [#2] Scoller Testing\r\n"); - for (color = STS_GREEN; color < STS_RED_BLUE; color++) + for (color = STS_GREEN; color < STS_COLOR_MAX; color++) { STS_Lamp_Bar_Scoller(color, lum_level); } diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 9707b1f..1aeb58c 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -54,6 +54,7 @@ extern volatile uint8_t sts_hall1_read, sts_hall2_read; extern volatile uint8_t sts_reed_hall_1_changed, sts_reed_hall_2_changed; 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_lamp_bar_flashing_color; volatile uint8_t last_sts_lamp_bar_color=STS_DARK; extern volatile uint8_t sts_rss_result_changed_flag, sts_hall1_changed_flag, sts_hall2_changed_flag, sts_reed_hall_changed_flag; volatile uint8_t sts_fall_detection_acc_threshold = 10, sts_fall_detection_depth_threshold=20, sts_occupancy_overtime_threshold=20; @@ -81,12 +82,12 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = { 0x04, // dual mode 0x00, // service mask 0x00, //reserve01 - 0x20, //32 bytes, below start of p[0] 28 BYTES AND 4 BYTES FALL DOWN CFG - { // below 28 bytes - 0x08, //start_m [8]*0.1 meter =0.8 - 0x19, //lenght_m 0x19=[25]*0.1=2.5f meter - 0x0F, //threshold 0X0F=[15]*0.1=1.5f - 0x28, //receiver gain 0x28 =[40]*0.01=0.40f max 99=0x63 + 0x20, //32 bytes, below start of p[0] 20 BYTES AND 12 BYTES FALL DOWN CFG + { // below 20 bytes + 0x08, //start_m [8]*0.1 meter =0.8 + 0x19, //lenght_m 0x19=[25]*0.1=2.5f meter + 0x0F, //threshold 0X0F=[15]*0.1=1.5f + 0x28, //receiver gain 0x28 =[40]*0.01=0.40f max 99=0x63 0x04, //profile [4]=4 0x0A, //rate tracking 0x0A=10= 10U 0x41, //rate presence 0x41=65= 65U @@ -100,19 +101,19 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = { 0x05, //output time const 0x05=[5]*0.1=0.5 0x02, //downsampling factor [2]=2 0x03, //power saving mode ACTIVE [3] = 3U - 0x00, //reserve - 0x00, //reserve - 0x00, //reserve - 0x00, //reserve - 0x00, //reserve - 0x00, //reserve - 0x00, //reserve - 0x00, //reserve - 0x00, //reserve - 0x00, //reserve - 0x00, //reserve - }, // above 28 bytes - // below 4 bytes + 0x00, //reserve --P[17] + 0x00, //reserve --P[18] + 0x00, //reserve --P[19] + }, // above 20 bytes + 0x00, //reserve2 + 0x00, //reserve3 + 0x00, //reserve4 + 0x00, //reserve5 + 0x00, //reserve6 + 0x00, //reserve7 + 0x00, //reserve8 + // below 5 bytes + 0x23, //Lamp Bar Flashing color define, 0x20, 2==STS_RED, 0 = STS_DARK, 0x23, 2=STS_RED, 3=STS_BLUE 0x01, //fall_detection_acc_threshold = *10 acceleration measure 0x03, //fall detection_depth_threshold *10cm 0x80, //fall unconcious threshold * 10, 1280 motion level @@ -973,6 +974,7 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context) //HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin); /* STS GREEN */ //if ((sts_work_mode != STS_WIRED_MODE)) { + if (sts_lamp_bar_color == STS_RED_BLUE) { if (r_b) STS_Lamp_Bar_Set_STS_RGB_Color(STS_RED, DEFAULT_LUMINANCE_LEVEL); @@ -980,7 +982,15 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context) STS_Lamp_Bar_Set_STS_RGB_Color(STS_BLUE, DEFAULT_LUMINANCE_LEVEL); r_b = !r_b; - } else { + } else if (sts_lamp_bar_color == STS_RED_DARK) { + if (r_b) + STS_Lamp_Bar_Set_STS_RGB_Color(STS_RED, DEFAULT_LUMINANCE_LEVEL); + else + STS_Lamp_Bar_Set_STS_RGB_Color(STS_DARK, DEFAULT_LUMINANCE_LEVEL); + + r_b = !r_b; + } + else { if (last_sts_lamp_bar_color != sts_lamp_bar_color) { STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, DEFAULT_LUMINANCE_LEVEL); @@ -2164,7 +2174,7 @@ void OnStoreSTSCFGContextRequest(void) for (j = 0; j < STS_O7_CFG_PCFG_SIZE; j++) { nvm_store_value[i++] = (sts_cfg_nvm.p[j]); } - + nvm_store_value[i++] = sts_cfg_nvm.lamp_bar_flashing_color; nvm_store_value[i++] = sts_cfg_nvm.fall_detection_acc_threshold; nvm_store_value[i++] = sts_cfg_nvm.fall_detection_depth_threshold; nvm_store_value[i++] = sts_cfg_nvm.fall_unconcious_threshold; @@ -2249,6 +2259,7 @@ void STS_REBOOT_CONFIG_Init(void) sts_cfg_nvm.p[j] = (uint8_t)nvm_stored_value[NVM_CFG_START+j]; } + sts_cfg_nvm.lamp_bar_flashing_color = (uint8_t)nvm_stored_value[NVM_LAMP_BAR_FLASHING_COLOR]; sts_cfg_nvm.fall_detection_acc_threshold = (uint8_t)nvm_stored_value[NVM_FALL_DETECTION_ACC_THRESHOLD]; sts_cfg_nvm.fall_detection_depth_threshold = (uint8_t)nvm_stored_value[NVM_FALL_DETECTION_DEPTH_THRESHOLD]; sts_cfg_nvm.fall_unconcious_threshold = (uint8_t)nvm_stored_value[NVM_FALL_UNCONCIOUS_THRESHOLD]; @@ -2315,6 +2326,7 @@ void OnRestoreSTSCFGContextProcess(void) sts_work_mode = sts_cfg_nvm.work_mode; sts_lamp_bar_color = STS_GREEN; sts_service_mask = sts_cfg_nvm.sts_service_mask; + sts_lamp_bar_flashing_color = sts_cfg_nvm.lamp_bar_flashing_color; sts_fall_detection_acc_threshold = (uint8_t)sts_cfg_nvm.fall_detection_acc_threshold*10; sts_fall_detection_depth_threshold = (uint8_t)sts_cfg_nvm.fall_detection_depth_threshold*10; //in cm