Open krupis opened 3 years ago
I am also confused why library reserves all RMT channels and then just uses the last channel available?
rmt_channel_t channel = ADAFRUIT_RMT_CHANNEL_MAX;
for (size_t i = 0; i < ADAFRUIT_RMT_CHANNEL_MAX; i++)
{
if (!rmt_reserved_channels[i])
{
rmt_reserved_channels[i] = true;
channel = i;
}
}
if (channel == ADAFRUIT_RMT_CHANNEL_MAX)
{
// Ran out of channels!
return 0;
}
Wouldnt it make more sense to return after one non reserved rmt channel is found? Why need to reserve all the channels?
@hierophect any thoughts?
I last worked on this several IDF versions ago which could explain the API differences, but the reservation thing definitely doesn't make any sense. I'll check out my notes to try and see if that was a debugging edit, or a merge issue, or what.
@krupis I had some time to catch up on this this morning. To start with, I don't know if this code is an ideal example for using the RMT with an up to date ESP-IDF submodule - at the time it was written, the IDF in the ESP32 Arduino core was lagging a bit behind their main release (3.2 vs 3.4), and has some hacks involved to get around the API differences present at that time.
The ws2812_rmt_adapter
is based off the LED strip demo from the ESP-IDF. It functions to translate the color bytes provided to espShow
into the rmt_item32_t
structure required by the RMT, calculating the number of ticks for the line to be high/low in a way the Neopixel understands, and putting them into an array that the RMT can output.
While I used it to avoid reinventing the wheel here, the RMT Translator concept isn't super well documented by Espressif, and I don't know whether or not there's a performance benefit over just calling the contents of ws2812_rmt_adapter
manually every time and then using rmt_write_items
. If that's something you'd like to test out yourself, it might be an interesting experiment.
As for the reservation problem, that's a bug! There should be a break;
in there. Thanks for pointing it out!
Thanks for clarifying!
Hello. I am learning about the RMT and how it is specifically configured to generate required signals for driving the neopixels. I have come across this library and been digging through the code. I notice that you are using the RMT therefore I have decided to use this project as an example.
When the show() fmethod is being called, the following functions are being used:
I have also read RMT documentation from espressif: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/rmt.html
And after configuring the rmt, they are suggesting to use follwing functions:
However, in adafruit neopixel, a different method is used which involves the use of translator unit with a callback and rmt_write_sample instead of rmt_write_sample.
I am not able to fully understand what is happening in the ws2812_rmt_adapter and esp_show. Could someone help me understand this rmt code ? Is it possible to simplify it and rewrite it using rmt_write_items() ?