forked from jappel/VersaMCU
35 lines
647 B
C++
35 lines
647 B
C++
// WS2812 driver – wraps Adafruit NeoPixel (bit-bang, no SERCOM needed)
|
||
|
||
#include "ws2812.h"
|
||
#include <Adafruit_NeoPixel.h>
|
||
|
||
static Adafruit_NeoPixel s_strip(WS2812_COUNT, WS2812_PIN, NEO_GRB + NEO_KHZ800);
|
||
|
||
void ws2812_init()
|
||
{
|
||
s_strip.begin();
|
||
s_strip.clear();
|
||
s_strip.show();
|
||
}
|
||
|
||
void ws2812_set(uint8_t idx, uint8_t r, uint8_t g, uint8_t b)
|
||
{
|
||
if (idx >= WS2812_COUNT) return;
|
||
s_strip.setPixelColor(idx, r, g, b);
|
||
}
|
||
|
||
void ws2812_fill(uint8_t r, uint8_t g, uint8_t b)
|
||
{
|
||
s_strip.fill(s_strip.Color(r, g, b));
|
||
}
|
||
|
||
void ws2812_show()
|
||
{
|
||
s_strip.show();
|
||
}
|
||
|
||
void ws2812_clear()
|
||
{
|
||
s_strip.clear();
|
||
s_strip.show();
|
||
}
|