diff --git a/src/main/drivers/light_ws2811strip.c b/src/main/drivers/light_ws2811strip.c index 149c9b6129..15607cd346 100644 --- a/src/main/drivers/light_ws2811strip.c +++ b/src/main/drivers/light_ws2811strip.c @@ -89,6 +89,11 @@ void ws2811LedStripInit(ioTag_t ioTag) { memset(&ledStripDMABuffer, 0, WS2811_DMA_BUFFER_SIZE); ws2811LedStripHardwareInit(ioTag); + + const hsvColor_t hsv_white = { 0, 255, 255}; + setStripColor(&hsv_white); + ws2811UpdateStrip(); + ws2811UpdateStrip(); } diff --git a/src/main/drivers/light_ws2811strip.h b/src/main/drivers/light_ws2811strip.h index 894ef4b1d6..2a1f708e7f 100644 --- a/src/main/drivers/light_ws2811strip.h +++ b/src/main/drivers/light_ws2811strip.h @@ -19,23 +19,34 @@ #include "io_types.h" -#define WS2811_LED_STRIP_LENGTH 32 -#define WS2811_BITS_PER_LED 24 -#define WS2811_DELAY_BUFFER_LENGTH 42 // for 50us delay +#define WS2811_LED_STRIP_LENGTH 32 +#define WS2811_BITS_PER_LED 24 +// for 50us delay +#define WS2811_DELAY_BUFFER_LENGTH 42 #define WS2811_DATA_BUFFER_SIZE (WS2811_BITS_PER_LED * WS2811_LED_STRIP_LENGTH) - -#define WS2811_DMA_BUFFER_SIZE (WS2811_DATA_BUFFER_SIZE + WS2811_DELAY_BUFFER_LENGTH) // number of bytes needed is #LEDs * 24 bytes + 42 trailing bytes) +// number of bytes needed is #LEDs * 24 bytes + 42 trailing bytes) +#define WS2811_DMA_BUFFER_SIZE (WS2811_DATA_BUFFER_SIZE + WS2811_DELAY_BUFFER_LENGTH) #if defined(STM32F40_41xxx) -#define BIT_COMPARE_1 67 // timer compare value for logical 1 -#define BIT_COMPARE_0 33 // timer compare value for logical 0 +#define WS2811_TIMER_HZ 84000000 +#define WS2811_TIMER_PERIOD 104 +// timer compare value for logical 1 +#define BIT_COMPARE_1 67 +// timer compare value for logical 0 +#define BIT_COMPARE_0 33 #elif defined(STM32F7) -#define BIT_COMPARE_1 76 // timer compare value for logical 1 -#define BIT_COMPARE_0 38 // timer compare value for logical 0 +// timer compare value for logical 1 +#define BIT_COMPARE_1 76 +// timer compare value for logical 0 +#define BIT_COMPARE_0 38 #else -#define BIT_COMPARE_1 17 // timer compare value for logical 1 -#define BIT_COMPARE_0 9 // timer compare value for logical 0 +#define WS2811_TIMER_HZ 24000000 +#define WS2811_TIMER_PERIOD 29 +// timer compare value for logical 1 +#define BIT_COMPARE_1 17 +// timer compare value for logical 0 +#define BIT_COMPARE_0 9 #endif void ws2811LedStripInit(ioTag_t ioTag); diff --git a/src/main/drivers/light_ws2811strip_hal.c b/src/main/drivers/light_ws2811strip_hal.c index 5d8e4cd0c2..260b9b374d 100644 --- a/src/main/drivers/light_ws2811strip_hal.c +++ b/src/main/drivers/light_ws2811strip_hal.c @@ -131,9 +131,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag) return; } - const hsvColor_t hsv_white = { 0, 255, 255}; ws2811Initialised = true; - setStripColor(&hsv_white); } @@ -145,9 +143,9 @@ void ws2811LedStripDMAEnable(void) return; } - if( HAL_TIM_PWM_Start_DMA(&TimHandle, timerChannel, ledStripDMABuffer, WS2811_DMA_BUFFER_SIZE) != HAL_OK) + if (HAL_TIM_PWM_Start_DMA(&TimHandle, timerChannel, ledStripDMABuffer, WS2811_DMA_BUFFER_SIZE) != HAL_OK) { - /* Starting PWM generation Error */ + /* Starting PWM generation Error */ ws2811LedDataTransferInProgress = 0; return; } diff --git a/src/main/drivers/light_ws2811strip_stm32f10x.c b/src/main/drivers/light_ws2811strip_stm32f10x.c index 1933e0a1c8..e0bb9656fc 100644 --- a/src/main/drivers/light_ws2811strip_stm32f10x.c +++ b/src/main/drivers/light_ws2811strip_stm32f10x.c @@ -30,9 +30,6 @@ #include "rcc.h" #include "timer.h" -#define WS2811_TIMER_HZ 24000000 -#define WS2811_TIMER_PERIOD 29 - static IO_t ws2811IO = IO_NONE; bool ws2811Initialised = false; static DMA_Channel_TypeDef *dmaChannel = NULL; @@ -116,10 +113,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag) DMA_ITConfig(dmaChannel, DMA_IT_TC, ENABLE); dmaSetHandler(timerHardware->dmaIrqHandler, WS2811_DMA_IRQHandler, NVIC_PRIO_WS2811_DMA, 0); - const hsvColor_t hsv_white = { 0, 255, 255}; ws2811Initialised = true; - setStripColor(&hsv_white); - ws2811UpdateStrip(); } void ws2811LedStripDMAEnable(void) diff --git a/src/main/drivers/light_ws2811strip_stm32f30x.c b/src/main/drivers/light_ws2811strip_stm32f30x.c index ffb6269d85..0165241f53 100644 --- a/src/main/drivers/light_ws2811strip_stm32f30x.c +++ b/src/main/drivers/light_ws2811strip_stm32f30x.c @@ -31,9 +31,6 @@ #include "rcc.h" #include "timer.h" -#define WS2811_TIMER_HZ 24000000 -#define WS2811_TIMER_PERIOD 29 - static IO_t ws2811IO = IO_NONE; bool ws2811Initialised = false; static DMA_Channel_TypeDef *dmaChannel = NULL; @@ -126,10 +123,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag) DMA_ITConfig(dmaChannel, DMA_IT_TC, ENABLE); dmaSetHandler(timerHardware->dmaIrqHandler, WS2811_DMA_IRQHandler, NVIC_PRIO_WS2811_DMA, 0); - const hsvColor_t hsv_white = { 0, 255, 255}; ws2811Initialised = true; - setStripColor(&hsv_white); - ws2811UpdateStrip(); } void ws2811LedStripDMAEnable(void) diff --git a/src/main/drivers/light_ws2811strip_stm32f4xx.c b/src/main/drivers/light_ws2811strip_stm32f4xx.c index 4fd38325ee..e2b7d1dbfa 100644 --- a/src/main/drivers/light_ws2811strip_stm32f4xx.c +++ b/src/main/drivers/light_ws2811strip_stm32f4xx.c @@ -33,9 +33,6 @@ #include "timer_stm32f4xx.h" #include "io.h" -#define WS2811_TIMER_HZ 84000000 -#define WS2811_TIMER_PERIOD 104 - static IO_t ws2811IO = IO_NONE; bool ws2811Initialised = false; static DMA_Stream_TypeDef *stream = NULL; @@ -140,10 +137,7 @@ void ws2811LedStripHardwareInit(ioTag_t ioTag) dmaSetHandler(timerHardware->dmaIrqHandler, WS2811_DMA_IRQHandler, NVIC_PRIO_WS2811_DMA, 0); - const hsvColor_t hsv_white = { 0, 255, 255 }; ws2811Initialised = true; - setStripColor(&hsv_white); - ws2811UpdateStrip(); } void ws2811LedStripDMAEnable(void)