aboutsummaryrefslogtreecommitdiff
path: root/main/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/main.c')
-rw-r--r--main/main.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/main/main.c b/main/main.c
index b4c744f..cffa6f5 100644
--- a/main/main.c
+++ b/main/main.c
@@ -5,6 +5,8 @@
#include "esp_spi_flash.h"
#include "driver/spi_master.h"
+#include "drv/ws2812b.h"
+
#ifdef CONFIG_IDF_TARGET_ESP32
#define LCD_HOST HSPI_HOST
@@ -82,23 +84,19 @@ void app_main(void)
printf("Configuration complete!!\n");
- for (int i = 0; i < sizeof(buffer); ++ i) {
- buffer[i] = 0xfa;
- }
-
- spi_transaction_t t = {0};
- t.tx_buffer = buffer;
- t.length = sizeof(buffer) * 8;
+ ws2812b_t* drv = ws2812b_init(spi);
+ ws2812b_buffer_t* buffer = ws2812b_new_buffer(5);
- spi_transaction_t* rt;
+ ws2812b_buffer_set_rgb(buffer, 0, 255, 0, 0);
+ ws2812b_buffer_set_rgb(buffer, 1, 0, 255, 0);
+ ws2812b_buffer_set_rgb(buffer, 2, 0, 0, 255);
+ ws2812b_buffer_set_rgb(buffer, 3, 255, 255, 0);
+ ws2812b_buffer_set_rgb(buffer, 4, 255, 0, 255);
while (1) {
- error = spi_device_queue_trans(spi, &t, portMAX_DELAY);
- assert(error == ESP_OK);
- printf("SPI Transaction Equeued!!\n");
-
- error = spi_device_get_trans_result(spi, &rt, portMAX_DELAY);
- assert(error == ESP_OK);
- printf("SPI Transaction Sent!!\n");
+ ws2812b_write_sync(drv, buffer);
+ // TODO(rahm) push this into the sync write, or otherwise make this better
+ // to deal with.
+ vTaskDelay(10 / portTICK_PERIOD_MS);
}
}