Pico panels get static IPs on 10.1.1.10–14 with per-panel LED counts, Makefile deploy targets, and Python examples for animations, sync tests, and direct Pi SPI control. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
940 B
C++
40 lines
940 B
C++
/* C API wrapper around ForsakenNGS/Pico_WS2812 */
|
|
|
|
#include "ws2812_led.h"
|
|
|
|
#include "WS2812.hpp"
|
|
|
|
#include "hardware/pio.h"
|
|
#include "pico/stdlib.h"
|
|
|
|
static WS2812 *s_strip;
|
|
|
|
extern "C" void ws2812_init(unsigned int pin, unsigned int num_leds) {
|
|
uint sm = pio_claim_unused_sm(pio0, true);
|
|
s_strip = new WS2812(pin, num_leds, pio0, sm, WS2812::FORMAT_GRB);
|
|
}
|
|
|
|
extern "C" void ws2812_set_rgb(const uint8_t *rgb, unsigned int count) {
|
|
if (s_strip == nullptr || rgb == nullptr) {
|
|
return;
|
|
}
|
|
for (unsigned int i = 0; i < count; i++) {
|
|
s_strip->setPixelColor(i, rgb[i * 3 + 0], rgb[i * 3 + 1], rgb[i * 3 + 2]);
|
|
}
|
|
}
|
|
|
|
extern "C" void ws2812_fill(uint8_t r, uint8_t g, uint8_t b) {
|
|
if (s_strip == nullptr) {
|
|
return;
|
|
}
|
|
s_strip->fill(WS2812::RGB(r, g, b));
|
|
}
|
|
|
|
extern "C" void ws2812_show(void) {
|
|
if (s_strip == nullptr) {
|
|
return;
|
|
}
|
|
s_strip->show();
|
|
sleep_us(300);
|
|
}
|