From 80650d7ab5b95c9acc2d41e7572a57307b8f5295 Mon Sep 17 00:00:00 2001 From: ladyada Date: Sat, 28 Oct 2023 19:11:26 -0400 Subject: [PATCH 1/2] nothing done yet --- esp.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/esp.c b/esp.c index c480a20..2dcebf4 100644 --- a/esp.c +++ b/esp.c @@ -26,7 +26,21 @@ #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) #define HAS_ESP_IDF_4 #endif +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) +#define HAS_ESP_IDF_5 #endif +#endif + + + +#ifdef HAS_ESP_IDF_5 + + + + + +#else + // This code is adapted from the ESP-IDF v3.4 RMT "led_strip" example, altered // to work with the Arduino version of the ESP-IDF (3.2) @@ -175,4 +189,7 @@ void espShow(uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) gpio_set_direction(pin, GPIO_MODE_OUTPUT); } -#endif +#endif // ifndef IDF5 + + +#endif // ifdef(ESP32) From a5856b2a11db8ba1471db1c5e2ba91b894991a6e Mon Sep 17 00:00:00 2001 From: ladyada Date: Sat, 28 Oct 2023 19:43:24 -0400 Subject: [PATCH 2/2] werkin --- esp.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/esp.c b/esp.c index 2dcebf4..1598b7a 100644 --- a/esp.c +++ b/esp.c @@ -20,7 +20,6 @@ #if defined(ESP32) #include -#include "driver/rmt.h" #if defined(ESP_IDF_VERSION) #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) @@ -35,12 +34,43 @@ #ifdef HAS_ESP_IDF_5 +void espShow(uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) { + rmt_data_t led_data[numBytes * 8]; + + if (!rmtInit(pin, RMT_TX_MODE, RMT_MEM_NUM_BLOCKS_1, 10000000)) { + log_e("Failed to init RMT TX mode on pin %d", pin); + return; + } + + int i=0; + for (int b=0; b < numBytes; b++) { + for (int bit=0; bit<8; bit++){ + if ( pixels[b] & (1<<(7-bit)) ) { + led_data[i].level0 = 1; + led_data[i].duration0 = 8; + led_data[i].level1 = 0; + led_data[i].duration1 = 4; + } else { + led_data[i].level0 = 1; + led_data[i].duration0 = 4; + led_data[i].level1 = 0; + led_data[i].duration1 = 8; + } + i++; + } + } + //pinMode(pin, OUTPUT); // don't do this, will cause the rmt to disable! + rmtWrite(pin, led_data, numBytes * 8, RMT_WAIT_FOR_EVER); + delay(10); +} #else +#include "driver/rmt.h" + // This code is adapted from the ESP-IDF v3.4 RMT "led_strip" example, altered // to work with the Arduino version of the ESP-IDF (3.2)