-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
Defer calling begin() on buses #4312
Conversation
NeoPixelBus requires that all parallel I2S bus members be constructed before any of them call Begin(). Implement this by deferring the call to the end of bus construction. Fixes Aircoookie#4301.
I haven't tested the runtime but nice design. Maybe just add a comment to the begin interference that explains a little when this is called to help anyone writing a bus implementation what this method is for |
Unit did not crash once I repeated that pin assignment in #4301 so seems fixed . Edit: A reboot of the unit seems to have fixed that and outputs went back to 10 only |
@Makuna (hope your reading this) we are still not 100% sure if mixing different led strip types on the same "parallel I2S bus" is supported (esp32), or it may lead to errors and spurious crashes? Our most important use case would be to have both ws2812b (RGB) and sk6812 (RGBW) on the same parallel I2S driver. It this "safe", or would you say better to use the parallel bus for only one type, and have single RMT busses for other types? |
The "Feature" can be unique per parallel channel without any concern. So, mixing RGB with RGBW or even 8 bit per element and 16 bit per element isn't an issue. |
Defer calling begin() on buses
@@ -597,7 +597,7 @@ class PolyBus { | |||
case I_HS_P98_3: busPtr = new B_HS_P98_3(len, pins[1], pins[0]); break; | |||
case I_SS_P98_3: busPtr = new B_SS_P98_3(len, pins[1], pins[0]); break; | |||
} | |||
begin(busPtr, busType, pins, clock_kHz); |
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 previous code had begin() with 4 arguments ( including clock_kHz), while the code in the previous reinit
is calling PolyBus::begin(_busPtr, _iType, _pins);
with 3 args - just wondering if this works as expected, and APA102 busses are still initialized with a custom SPI speed?
(late question, sorry. just spotted it now).
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.
Good catch! I've put a fix in #4327.
Fixes bug introduced by Aircoookie#4312.
Fix missing clock setting introduce by #4312
Fixes bug introduced by #4312.
NeoPixelBus requires that all parallel I2S bus members be constructed before any of them call Begin(). Implement this by deferring the Begin() call to the end of the bus initialization process. This replaces the "reinit" logic previously used to work around a similar initialization ordering issue for ESP8266 pins.
Fixes #4301.
This PR introduces a new virtual begin() call on Bus types, although it's only currently used on digital buses. This seemed like a cleaner abstraction than requiring a bunch of type-checking logic at the point of use, and maps more closely to the NeoPixelBus expected call sequence. It also leaves a hook behind for future bus types that might need separate initialization phases.