diff --git a/Core/Src/sts_lamp_bar.c b/Core/Src/sts_lamp_bar.c index afdf6d9..6d464d5 100644 --- a/Core/Src/sts_lamp_bar.c +++ b/Core/Src/sts_lamp_bar.c @@ -32,20 +32,20 @@ #define ZERO_PULSE (20) #define LED_DATA_LEN 24 -#define WS2812B_DATA_LEN (24 * (STS_LAMP_BAR_LED_NUM+1)) -#define RESET_PULSE (24) //(80) TO FIX DARK_COLOR AND SM2 +#define WS2812B_DATA_LEN (LED_DATA_LEN * (STS_LAMP_BAR_LED_NUM+1)) +#define RESET_PULSE (16) //(80) TO FIX DARK_COLOR AND SM2 typedef struct ws2812b_e { - uint16_t head[3]; + //uint16_t head[3]; uint16_t GRB[WS2812B_DATA_LEN]; uint16_t tail; } WS2812B_FrameTypeDef; volatile WS2812B_FrameTypeDef rgb_buf = { - .head[0] = 0, - .head[1] = 0, - .head[2] = 0, +// .head[0] = 0, +// .head[1] = 0, +// .head[2] = 0, .tail = 0 }; @@ -101,11 +101,9 @@ void STS_Lamp_Bar_Set_Dark(void) void STS_WS2812B_Refresh(void) { - STS_WS2812B_Set_RGB(0,0,0,STS_LAMP_BAR_LED_NUM ); - - __disable_irq(); - HAL_TIM_PWM_Start_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL, (uint32_t *)rgb_buf.GRB, (uint16_t)(sizeof(rgb_buf.GRB))); - __enable_irq(); + //__disable_irq(); + HAL_TIM_PWM_Start_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL, (uint32_t *)&rgb_buf, (WS2812B_DATA_LEN+1)); + //__enable_irq(); //HAL_TIM_PWM_Start_IT(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL); } @@ -143,15 +141,15 @@ void STS_Lamp_Bar_Scoller(uint8_t color, uint8_t lum_level) } -void STS_WS2812B_Set_RGB(uint8_t R, uint8_t G, uint8_t B, uint8_t idx) +void STS_WS2812B_Set_RGB(uint8_t red, uint8_t green, uint8_t blue, uint8_t idx) { - if (idx < STS_LAMP_BAR_LED_NUM) + //if (idx < STS_LAMP_BAR_LED_NUM) { for (uint8_t j = 0; j < 8; j ++) { - rgb_buf.GRB[idx*24+j] = (uint16_t)(((G<