VersaMCU/src/hal/ws2812.cpp
2026-03-29 14:47:13 +02:00

35 lines
647 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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();
}