Skip to content

Commit 67e2522

Browse files
committed
Make ESP-IDF driver work.
1 parent 95be9e8 commit 67e2522

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -684,14 +684,20 @@ void IRAM_ATTR ESP32RMTController::fillNext()
684684
// This function is only used when the built-in RMT driver is chosen
685685
void ESP32RMTController::initPulseBuffer(int size_in_bytes)
686686
{
687-
if (mBuffer == 0) {
688-
// -- Each byte has 8 bits, each bit needs a 32-bit RMT item
689-
mBufferSize = size_in_bytes * 8 * 4;
690687

691-
mBuffer = (rmt_item32_t *) calloc( mBufferSize, sizeof(rmt_item32_t));
692-
693-
}
694688
mCurPulse = 0;
689+
690+
// maybe we already have a buffer of the right size, it's likely
691+
if (mBuffer && (mBufferSize == size_in_bytes * 8))
692+
return;
693+
694+
if (mBuffer) { free(mBuffer); mBuffer = 0; }
695+
696+
// -- Each byte has 8 bits, each bit needs a 32-bit RMT item
697+
mBufferSize = size_in_bytes * 8;
698+
699+
mBuffer = (rmt_item32_t *) calloc( mBufferSize, sizeof(rmt_item32_t) );
700+
695701
}
696702

697703
// -- Convert a byte into RMT pulses
@@ -700,7 +706,7 @@ void ESP32RMTController::convertByte(uint32_t byteval)
700706
{
701707
// -- Write one byte's worth of RMT pulses to the big buffer
702708
byteval <<= 24;
703-
for (register uint32_t j = 0; j < 8; j++) {
709+
for (uint32_t j = 0; j < 8; j++) {
704710
mBuffer[mCurPulse] = (byteval & 0x80000000L) ? mOne : mZero;
705711
byteval <<= 1;
706712
mCurPulse++;

0 commit comments

Comments
 (0)