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>
39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
#ifndef WS2812_H
|
|
#define WS2812_H
|
|
|
|
#include "hardware/pio.h"
|
|
#include "pico/types.h"
|
|
|
|
class WS2812 {
|
|
public:
|
|
enum DataByte { NONE = 0, RED = 1, GREEN = 2, BLUE = 3, WHITE = 4 };
|
|
enum DataFormat { FORMAT_RGB = 0, FORMAT_GRB = 1, FORMAT_WRGB = 2 };
|
|
|
|
WS2812(uint pin, uint length, PIO pio, uint sm);
|
|
WS2812(uint pin, uint length, PIO pio, uint sm, DataFormat format);
|
|
~WS2812();
|
|
|
|
static uint32_t RGB(uint8_t red, uint8_t green, uint8_t blue) {
|
|
return (uint32_t)(blue) << 16 | (uint32_t)(green) << 8 | (uint32_t)(red);
|
|
}
|
|
|
|
void setPixelColor(uint index, uint32_t color);
|
|
void setPixelColor(uint index, uint8_t red, uint8_t green, uint8_t blue);
|
|
void fill(uint32_t color);
|
|
void show();
|
|
|
|
private:
|
|
uint pin;
|
|
uint length;
|
|
PIO pio;
|
|
uint sm;
|
|
DataByte bytes[4];
|
|
uint32_t *data;
|
|
|
|
void initialize(uint pin, uint length, PIO pio, uint sm, DataByte b1, DataByte b2,
|
|
DataByte b3, DataByte b4);
|
|
uint32_t convertData(uint32_t rgbw);
|
|
};
|
|
|
|
#endif
|