diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index 2ce8c2d..242201b 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -144,6 +144,7 @@ void Error_Handler(void);
#define STS_LAMP_BAR_PWM_TIM_PERIOD (240 - 1)
#define STS_LAMP_BAR_HTIM htim1
#define STS_LAMP_BAR_LED_NUM (60) //60 for 46CM length LED strip
+#define STS_LAMP_BAR_LED_NUM_MAX (60) //60 for 46CM length LED strip
#define LED_COUNT 18 // for 30 cm lamp bar
#define WSDATA_PORT_PIN_PA8
//#define WSDATA_PORT_PIN_PA9
diff --git a/Core/Src/sts_lamp_bar.c b/Core/Src/sts_lamp_bar.c
index 317b0c1..b211b2d 100644
--- a/Core/Src/sts_lamp_bar.c
+++ b/Core/Src/sts_lamp_bar.c
@@ -50,8 +50,9 @@ volatile WS2812B_FrameTypeDef rgb_buf = {
.tail = 0
};
-uint8_t ws2812b_crr_value[LED_COUNT*24+RESET_PULSE]={00};
-uint8_t ws2812b_data[LED_COUNT*3]={0};
+//uint8_t ws2812b_crr_value[LED_COUNT*24+RESET_PULSE]={00};
+uint8_t ws2812b_crr_value[STS_LAMP_BAR_LED_NUM_MAX*24+RESET_PULSE]={00};
+uint8_t ws2812b_data[STS_LAMP_BAR_LED_NUM_MAX*3]={0};
uint8_t color_rgb[8][3] = { //STS_COLOR R G B MAPPING TABLE
{0,0,0},{0,1,0},{1,0,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,1,1}
@@ -106,7 +107,7 @@ void ws2812b_data_transfer(uint8_t *src, uint32_t len)
uint8_t i =0;
uint32_t bits = 0;
uint32_t bytes = 0;
-
+ HAL_TIM_PWM_Stop_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL);
while(len--)
{
for (i=0; i < 8; i++)
@@ -350,12 +351,12 @@ static void STS_Lamp_Bar_Set_RGB_Color_FadeOut(uint8_t red, uint8_t green, uint8
}
ws2812b_data_transfer(ws2812b_data, sizeof(ws2812b_data));
}
-
+/*
void STS_Lamp_Bar_Refresh(void)
{
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level);
}
-
+*/
void STS_Lamp_Bar_Set_STS_RGB_Color_FadeIn(uint8_t sts_lamp_color, uint8_t max_lum_level, uint8_t fade_length)
{
if (sts_lamp_color <=8)
@@ -428,7 +429,20 @@ void STS_Lamp_Bar_Set_STS_RGB_Color_FadeOut(uint8_t sts_lamp_color, uint8_t max_
}
void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t lum)
{
- ws2812b_light_all_with_lum_level(sts_lamp_color, lum);
+ //ws2812b_light_all_with_lum_level(sts_lamp_color, lum);
+ luminance_level = lum;
+ //ws2812b_light_all(color);
+ switch(sts_lamp_color)
+ {
+ case STS_DARK : ws2812b_light_custom(0, 0, 0); break;
+ case STS_GREEN : ws2812b_light_custom(0, luminance_level, 0 ); break;
+ case STS_RED : ws2812b_light_custom(luminance_level, 0, 0 ); break;
+ case STS_BLUE : ws2812b_light_custom(0, 0, luminance_level); break;
+ case STS_YELLOW : ws2812b_light_custom(luminance_level, luminance_level, 0 ); break;
+ case STS_PINK : ws2812b_light_custom(luminance_level, 0, luminance_level ); break;
+ case STS_CYAN : ws2812b_light_custom(0, luminance_level, luminance_level ); break;
+ case STS_WHITE : ws2812b_light_custom(luminance_level, luminance_level, luminance_level ); break;
+ }
/*
if (sts_lamp_color <=8)
{
diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c
index b4494ca..20250da 100644
--- a/LoRaWAN/App/lora_app.c
+++ b/LoRaWAN/App/lora_app.c
@@ -59,8 +59,8 @@ volatile uint8_t last_sts_hall1_read=STS_Status_Door_Open, last_sts_hall2_read=S
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, sts_color_occupy_vacant, sts_color_severity_l2_l3;
extern volatile uint8_t sts_lamp_bar_flashing_color;
-volatile uint8_t last_sts_lamp_bar_color=STS_DARK;
-extern volatile uint8_t sts_status_color, sts_lamp_bar_color, sts_color_occupy_vacant;//puColor
+volatile uint8_t last_sts_lamp_bar_color=STS_WHITE;
+//extern volatile uint8_t sts_status_color, sts_lamp_bar_color, sts_color_occupy_vacant;//puColor
extern volatile uint8_t sts_rss_result;
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 = 30, //0.3g
@@ -1270,7 +1270,11 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
luminance_level %= 60;
luminance_level = MAX(10,luminance_level);
#endif
-
+if (last_sts_lamp_bar_color != sts_lamp_bar_color)
+{
+ APP_LOG(TS_OFF, VLEVEL_M, "\r\n----Lamp Bar Color changed from %02x to %02x \r\n", last_sts_lamp_bar_color, sts_lamp_bar_color);
+ last_sts_lamp_bar_color = sts_lamp_bar_color;
+}
UTIL_TIMER_Stop(&STSLampBarColorTimer);
if (high4==0)
@@ -1293,6 +1297,8 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
r_b = !r_b;
}
UTIL_TIMER_Start(&STSLampBarColorTimer);
+//}
+
}
static void OnYunhornSTSDurationCheckTimerEvent(void *context)
diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject
index 68a2ceb..e7876b0 100644
--- a/STM32CubeIDE/.cproject
+++ b/STM32CubeIDE/.cproject
@@ -154,7 +154,6 @@