-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: ESP32 espShow() doesn't de-init RMT #424
Conversation
Does this change mean the updateLength(0) call then show() might be ineffective on other platforms? There doesn't seem to be the same advice about cleanup for other platforms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .update_length(0); .show()
to free resources seems too subtle to me. Either the resources (RMT, in this case) should just be freed in the destructor, and that's the only way to free resources, or there might be a .end()
routine, which doesn't do anything for most platforms, except for Espressif.
Since it wasn't correctly implemented, I was implementing the broken length/show code.
I agree; we should go in this direction instead of freeing the RMT via 2 functions. calls may be good for two reasons:
I'll go ahead and implement this, ping both you and @tyeth when |
@tyeth Can I re-request a review for this? |
#ifdef ARDUINO_ARCH_ESP32 | ||
// Release RMT resources (RMT channels and led_data) | ||
// by indirectly calling into espShow() | ||
memset(pixels, 0, numBytes); | ||
numLEDs = numBytes = 0; | ||
show(); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems OK to me. It still seems a little round-about, but I assume there are use cases for adjusting the number of LEDs on the fly and we support that.
@ladyada The issue fixed by this PR is allowing a
new
NeoPixel object on ESP32 to be destroyed and re-created. The core issue is withinesp.c
'sespShow()
implementation for IDF 5+ which looks like it was modified/written by teknynja.What should work:
Why this does not work:
updateLength()
with a value of0
, the function frees thepixels
buffershow() directly after will [early-return since the first check within
show()is for
pixels`](https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.cpp#L421)show()
calls because the RMT was neither released or re-attached properly.Addresses:
adafruit/Adafruit_Wippersnapper_Arduino#691
adafruit/Adafruit_Wippersnapper_Arduino#684