diff options
Diffstat (limited to 'platforms/avr/drivers/ws2812_i2c.c')
-rw-r--r-- | platforms/avr/drivers/ws2812_i2c.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/platforms/avr/drivers/ws2812_i2c.c b/platforms/avr/drivers/ws2812_i2c.c new file mode 100644 index 000000000..1c332e24b --- /dev/null +++ b/platforms/avr/drivers/ws2812_i2c.c | |||
@@ -0,0 +1,27 @@ | |||
1 | #include "ws2812.h" | ||
2 | #include "i2c_master.h" | ||
3 | |||
4 | #ifdef RGBW | ||
5 | # error "RGBW not supported" | ||
6 | #endif | ||
7 | |||
8 | #ifndef WS2812_ADDRESS | ||
9 | # define WS2812_ADDRESS 0xb0 | ||
10 | #endif | ||
11 | |||
12 | #ifndef WS2812_TIMEOUT | ||
13 | # define WS2812_TIMEOUT 100 | ||
14 | #endif | ||
15 | |||
16 | void ws2812_init(void) { i2c_init(); } | ||
17 | |||
18 | // Setleds for standard RGB | ||
19 | void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { | ||
20 | static bool s_init = false; | ||
21 | if (!s_init) { | ||
22 | ws2812_init(); | ||
23 | s_init = true; | ||
24 | } | ||
25 | |||
26 | i2c_transmit(WS2812_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_TIMEOUT); | ||
27 | } | ||