diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2021-11-30 01:06:49 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2021-11-30 01:06:49 -0700 |
commit | 6df4a4ed74621ce5df26791b84b9157902aeaa83 (patch) | |
tree | f48c79a6b6c11ee60f6bbf7ba3441beddfc8a512 /include | |
parent | 80d6050ab3fe42f8850bf166c33eb3c9150a252b (diff) | |
download | esp32-ws2812b-6df4a4ed74621ce5df26791b84b9157902aeaa83.tar.gz esp32-ws2812b-6df4a4ed74621ce5df26791b84b9157902aeaa83.tar.bz2 esp32-ws2812b-6df4a4ed74621ce5df26791b84b9157902aeaa83.zip |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/drv/ws2812b.h | 9 |
1 files changed, 7 insertions, 2 deletions
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) |