Replace MicroPython runtime with Pico C + W5500 firmware.
Ship UDP RGB panel firmware (eight WS2812 strips) and drop the ESP32 Wi-Fi/MicroPython stack. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
46
firmware/WS2812.hpp
Normal file
46
firmware/WS2812.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#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();
|
||||
void show(uint count);
|
||||
void setPin(uint pin);
|
||||
uint getPin() const { return pin; }
|
||||
|
||||
private:
|
||||
uint pin;
|
||||
uint length;
|
||||
PIO pio;
|
||||
uint sm;
|
||||
uint offset;
|
||||
uint bits;
|
||||
int dma_chan;
|
||||
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);
|
||||
void applyPinConfig();
|
||||
void dma_wait(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user