forked from jappel/VersaMCU
Initial commit
This commit is contained in:
commit
b49984b9c0
32 changed files with 2394 additions and 0 deletions
35
src/hal/ws2812.cpp
Normal file
35
src/hal/ws2812.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// 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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue