You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Conflict between Audio library and ObjectFLED driver (Teensy 4.x) #1818
When I saw the release notes for v3.9.8 I was thrilled to see this technology integrated into FastLED, so I made a quick test, replacing #define USE_WS2812SERIAL with #define FASTLED_USES_OBJECTFLED.
It kind of worked, as the fps jumped from 43 (plain FastLED) to 133 (the same I get with WS2812Serial), but there some issues, like random pixels flickering all the time (see video).
Probably there's something in my code, but maybe not. Perhaps some interaction with the audio shield and its library? For now I'll stay with WS2812Serial, as it works buttery smooth with my project, and I don't need massive scalability, but if you want me to do some specific test to try debugging this issue, please let me know and I'd be happy to collaborate.
I know the DMA code uses channels dma0-dma3; not sure if audio library has a dependency on those channels or not.
When I was testing objectFLED, flickering like that seemed to be related to having too short a latch delay time. Does FastLED let you increase this from default of 75 uS? Or provide access to it's waveform timing capability?
@PaulStoffregen thanks for the great audio library. Any insight here?
Yes! My thanks as well, @PaulStoffregen. I enjoyed learning how your code works, and after trying to get parallelism with software spi and uart, discovering your DMA solution was awesome!
I tried to make it into a beginner-friendly package, to co-exist with FastLED. Hopefully, this will lead others in the LED art community to discover the power of Teensy!
I know the DMA code uses channels dma0-dma3; not sure if audio library has a dependency on those channels or not.
When I was testing objectFLED, flickering like that seemed to be related to having too short a latch delay time. Does FastLED let you increase this from default of 75 uS? Or provide access to it's waveform timing capability?
I never tested ObjectFLED with other apps running DMA in the background. Increasing DMA block sz decreased the amount of background interrupts generated by DMA end-of-block handling. However it also increased the amount of time show() blocked before it returned. So I made it as small as I could before interrupt activity started to degrade fps on a 4k LED object.
Isn't the latest ObjectFLED driver supposed to be using the very same timings as WS2812Serial?
I studied WS2812Serial a while back. They are using 5-bit patterns for each LED pulse (each serial byte + 2 start/stop bits = 2 LED pulses). So their 1250 nS clock is divided into 1/5 for 0H and 4/5 for 1H; T0H = 250, T1H = 1000. The equivalent ObjectFLED setup is .begin(1250, 250, 1000, 300); //300 uS latch delay coded into WS2812Serial.
If I'm not mistaken, your static problem was fixed when Zach updated FastLED to 1.1.0 ObjectFLED, right? Now it's broke again even with 1.2 OC factor, which also once fixed this problem?
I'm a bit confused by the square buffer problem. When var length strings use a 2D array for buffer, and row length matches longest string, you draw each row according to known sting lengths, then pass the array to a display driver, which blindly sends full rows to each string. Those strings which receive extra data from excess row size, will blindly ignore the extra data while waiting for the latch pulse. Why is it necessary to do any processing on these over-sized buffer rows?
Isn't the latest ObjectFLED driver supposed to be using the very same timings as WS2812Serial?
I studied WS2812Serial a while back. They are using 5-bit patterns for each LED pulse (each serial byte + 2 start/stop bits = 2 LED pulses). So their 1250 nS clock is divided into 1/5 for 0H and 4/5 for 1H; T0H = 250, T1H = 1000. The equivalent ObjectFLED setup is .begin(1250, 250, 1000, 300); //300 uS latch delay coded into WS2812Serial.
If I'm not mistaken, your static problem was fixed when Zach updated FastLED to 1.1.0 ObjectFLED, right? Now it's broke again even with 1.2 OC factor, which also once fixed this problem?
Before the fix I was having flickering on any string. With latest version only on a couple of older ones, which I'm using in my setup. However, with WS2812Serial even those old clunkers worked good :-)
I'm a bit confused by the square buffer problem. When var length strings use a 2D array for buffer, and row length matches longest string, you draw each row according to known sting lengths, then pass the array to a display driver, which blindly sends full rows to each string. Those strings which receive extra data from excess row size, will blindly ignore the extra data while waiting for the latch pulse. Why is it necessary to do any processing on these over-sized buffer rows?
Ok, I have 2 strings, one 50 LEDs one 100. I use CRGB[2][100] array to draw both strings, then call show() for the entire array. Driver sends 100 * 3 bytes to each string, then a latch pulse to tell the LEDs to latch their register data to the DACs which drive the actual LED (turns the lights on).
Even though there's only 50 LEDs on the short string, during transmission of 100 * 3 bytes of draw buffer, the short string only stores the first 50 * 3 bytes into their registers. The remaining 50 * 3 bytes are passed onto the next LED all the way to the end where that last LED is not connected. The last 50 * 3 bytes are ignored by every LED on the string because they each already got populated with the first 50 * 3 bytes. At the end of 100 * 3 bytes transmitted on each string, the latch pulse comes and the color data is displayed as drawn in the array.
So why does this 2D array need refactoring or special handling? How does it cause a problem?
Ok, I have 2 strings, one 50 LEDs one 100. I use CRGB[2][100] array to draw both strings, then call show() for the entire array. Driver sends 100 * 3 bytes to each string, then a latch pulse to tell the LEDs to latch their register data to the DACs which drive the actual LED (turns the lights on).
This is what is being done internally.
So why does this 2D array need refactoring or special handling? How does it cause a problem?
I got lazy and implemented it wrong. I was using vector push back and forgot to add extra fill bytes.
I put this all under test then used some typing to enforce correct usage.
Also FYI, FastLED completely ignores all of the extra modes and just does RGB mode only. RGBW mode is supported by extending the buffer, adding an extra pixel if needed, then sending all the RGBW data down the pipe as if it were RGB data. Works great and we get all the RGBW fastled functions to work.
This is how I bolted on RGBW onto the Yves S3 I2S driver.
Activity
zackees commentedon Dec 28, 2024
My one request for you would be to
#if 0out any code so that it's only running with the ObjectFLED driver.Please let me know if it's stable then.
zackees commentedon Dec 29, 2024
Can you explain how you enable the Serial WS2812 driver in your project?
lpaolini commentedon Dec 29, 2024
See lines 6-8 here and 396-399 here
Then I'm addressing LEDs using
CRGBSets.lpaolini commentedon Dec 29, 2024
Yes, it must be an interaction with the Audio library.
I have managed to reproduce the issue with the following code, by uncommenting line 10.
https://github.com/lpaolini/FastLED-1818
lpaolini commentedon Dec 30, 2024
I hope this incompatibility can be resolved, as the Audio library offers immense value for LED projects based on Teensy 4.x.
zackees commentedon Dec 30, 2024
@PaulStoffregen thanks for the great audio library. Any insight here?
KurtMF commentedon Dec 31, 2024
I know the DMA code uses channels dma0-dma3; not sure if audio library has a dependency on those channels or not.
When I was testing objectFLED, flickering like that seemed to be related to having too short a latch delay time. Does FastLED let you increase this from default of 75 uS? Or provide access to it's waveform timing capability?
KurtMF commentedon Dec 31, 2024
I will try to dig into the audio library, and see if it's trying to use the same dma or timer channels as OctoWS2811/ObjectFLED.
What LED chip are you using? WS2812?
KurtMF commentedon Dec 31, 2024
Yes! My thanks as well, @PaulStoffregen. I enjoyed learning how your code works, and after trying to get parallelism with software spi and uart, discovering your DMA solution was awesome!
I tried to make it into a beginner-friendly package, to co-exist with FastLED. Hopefully, this will lead others in the LED art community to discover the power of Teensy!
zackees commentedon Dec 31, 2024
I'll add it now
adds the ability to set the latch delay on the ObjectFLED driver #1818
adds FASTLED_OBJECTFLED_LATCH_DELAY for user sketches #1818
zackees commentedon Dec 31, 2024
Okay, checked into master, enable it like this:
zackees commentedon Dec 31, 2024
Kurt, did you see any change in stability when the DMA buffer size was increased?
KurtMF commentedon Dec 31, 2024
I never tested ObjectFLED with other apps running DMA in the background. Increasing DMA block sz decreased the amount of background interrupts generated by DMA end-of-block handling. However it also increased the amount of time show() blocked before it returned. So I made it as small as I could before interrupt activity started to degrade fps on a 4k LED object.
33 remaining items
lpaolini commentedon Jan 12, 2025
Awesome, the overflow issue seems to be solved!
I've tried changing the order of initialization and it's working good.
However, one of the strips is still flickering.
Isn't the latest ObjectFLED driver supposed to be using the very same timings as WS2812Serial?
zackees commentedon Jan 12, 2025
Merged.
Try this:
lpaolini commentedon Jan 12, 2025
When I do that, the already working strips continue to do so, while the flickering one shows noise.
KurtMF commentedon Jan 12, 2025
I studied WS2812Serial a while back. They are using 5-bit patterns for each LED pulse (each serial byte + 2 start/stop bits = 2 LED pulses). So their 1250 nS clock is divided into 1/5 for 0H and 4/5 for 1H; T0H = 250, T1H = 1000. The equivalent ObjectFLED setup is .begin(1250, 250, 1000, 300); //300 uS latch delay coded into WS2812Serial.
If I'm not mistaken, your static problem was fixed when Zach updated FastLED to 1.1.0 ObjectFLED, right? Now it's broke again even with 1.2 OC factor, which also once fixed this problem?
KurtMF commentedon Jan 12, 2025
I'm a bit confused by the square buffer problem. When var length strings use a 2D array for buffer, and row length matches longest string, you draw each row according to known sting lengths, then pass the array to a display driver, which blindly sends full rows to each string. Those strings which receive extra data from excess row size, will blindly ignore the extra data while waiting for the latch pulse. Why is it necessary to do any processing on these over-sized buffer rows?
lpaolini commentedon Jan 12, 2025
Before the fix I was having flickering on any string. With latest version only on a couple of older ones, which I'm using in my setup. However, with WS2812Serial even those old clunkers worked good :-)
zackees commentedon Jan 12, 2025
Can you elaborate
KurtMF commentedon Jan 12, 2025
Ok, I have 2 strings, one 50 LEDs one 100. I use CRGB[2][100] array to draw both strings, then call show() for the entire array. Driver sends 100 * 3 bytes to each string, then a latch pulse to tell the LEDs to latch their register data to the DACs which drive the actual LED (turns the lights on).
Even though there's only 50 LEDs on the short string, during transmission of 100 * 3 bytes of draw buffer, the short string only stores the first 50 * 3 bytes into their registers. The remaining 50 * 3 bytes are passed onto the next LED all the way to the end where that last LED is not connected. The last 50 * 3 bytes are ignored by every LED on the string because they each already got populated with the first 50 * 3 bytes. At the end of 100 * 3 bytes transmitted on each string, the latch pulse comes and the color data is displayed as drawn in the array.
So why does this 2D array need refactoring or special handling? How does it cause a problem?
zackees commentedon Jan 12, 2025
This is what is being done internally.
I got lazy and implemented it wrong. I was using vector push back and forgot to add extra fill bytes.
I put this all under test then used some typing to enforce correct usage.
zackees commentedon Jan 13, 2025
https://github.com/FastLED/FastLED/blob/master/src/fl/rectangular_draw_buffer.h
KurtMF commentedon Jan 13, 2025
Ah vectors. So I guess you bypass ObjectFLED.genFrameBuffer() and create your own (FastLED) framebuffer in vectors?
Just looked at the header file. Looks complicated. :-)
zackees commentedon Jan 13, 2025
No I don't bypass it.
I just use more memory.
zackees commentedon Jan 13, 2025
Also FYI, FastLED completely ignores all of the extra modes and just does RGB mode only. RGBW mode is supported by extending the buffer, adding an extra pixel if needed, then sending all the RGBW data down the pipe as if it were RGB data. Works great and we get all the RGBW fastled functions to work.
This is how I bolted on RGBW onto the Yves S3 I2S driver.
zackees commentedon Jan 13, 2025
Okay, I minted a new release 3.9.11 with all the fixes.
Tomorrow I'm going to ask again if ObjectFLED is stable enough to be the main driver, so that we can make it the default for 3.9.12.