36
36
#include < FreeRTOS/include/timers.h>
37
37
#endif
38
38
39
+ static uint8_t _led_colors[WS2812_BYTES_PER_LED * LED_STRIP_LENGTH];
40
+
39
41
extern const stm32_pulse_timer_t _led_timer;
40
42
41
43
static TimerHandle_t rgbLedTimer = nullptr ;
@@ -55,15 +57,22 @@ uint32_t rgbGetLedColor(uint8_t led)
55
57
return ws2812_get_color (led);
56
58
}
57
59
58
-
59
60
bool rgbGetState (uint8_t led)
60
61
{
61
62
return ws2812_get_state (led);
62
63
}
63
64
64
65
void rgbLedColorApply ()
65
66
{
66
- ws2812_update (&_led_timer);;
67
+ ws2812_update (&_led_timer);
68
+ }
69
+
70
+ void rgbLedClearAll ()
71
+ {
72
+ for (uint8_t i = 0 ; i < LED_STRIP_LENGTH; i++) {
73
+ ws2812_set_color (i, 0 , 0 , 0 );
74
+ }
75
+ ws2812_update (&_led_timer);
67
76
}
68
77
69
78
static void rgbLedTimerCb (TimerHandle_t xTimer)
@@ -111,6 +120,12 @@ const stm32_pulse_timer_t _led_timer = {
111
120
.DMA_TC_CallbackPtr = nullptr ,
112
121
};
113
122
123
+ void rgbLedInit ()
124
+ {
125
+ ws2812_init (&_led_timer, _led_colors, LED_STRIP_LENGTH, WS2812_GRB);
126
+ rgbLedClearAll ();
127
+ }
128
+
114
129
// Make sure the timer channel is supported
115
130
static_assert (__STM32_PULSE_IS_TIMER_CHANNEL_SUPPORTED(LED_STRIP_TIMER_CHANNEL),
116
131
"Unsupported timer channel");
@@ -128,4 +143,4 @@ extern "C" void LED_STRIP_TIMER_DMA_IRQHandler()
128
143
ws2812_dma_isr (&_led_timer);
129
144
}
130
145
131
- #endif
146
+ #endif
0 commit comments