From 6df4a4ed74621ce5df26791b84b9157902aeaa83 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Tue, 30 Nov 2021 01:06:49 -0700 Subject: Break out code into tasks. Increases the nmuber of LEDs to the full 300 roll. Can connect to the device using netcat. Set the color by entering white red green blue yellow teal magenta black --- include/drv/ws2812b.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/drv/ws2812b.h b/include/drv/ws2812b.h index 39f2794..49337ed 100644 --- a/include/drv/ws2812b.h +++ b/include/drv/ws2812b.h @@ -13,7 +13,10 @@ typedef struct { } ws2812b_rgb_t; typedef struct { - uint8_t* buf_; /* Buffer to hold the value to spi. */ + /* Double-buffering strategy for speed-up. */ + uint8_t* buf_1; + uint8_t* buf_2; + uint8_t* buf_; /* Points to either buf_1 or buf_2 */ uint32_t n_rgb; /* Number of rgb values which exist. */ ws2812b_rgb_t rgb[]; /* Colors to write. */ @@ -24,9 +27,11 @@ typedef struct WS2812B ws2812b_t; ws2812b_buffer_t* ws2812b_new_buffer(uint32_t size); +esp_err_t ws2812b_wait(ws2812b_t* drv); + ws2812b_t* ws2812b_init(spi_device_handle_t spi); -esp_err_t ws2812b_write_sync(ws2812b_t* drv, ws2812b_buffer_t* buffer); +esp_err_t ws2812b_write(ws2812b_t* drv, ws2812b_buffer_t* buffer); static inline void ws2812b_buffer_set_rgb( ws2812b_buffer_t* buf, size_t idx, uint8_t r, uint8_t g, uint8_t b) -- cgit