Skip to content

Conflict between Audio library and ObjectFLED driver (Teensy 4.x) #1818

Closed

Description

@lpaolini

I've been using FastLED with the mighty Teensy 4.x platform for years for my Striptease project, together with Paul Stoffregen's WS2812Serial library, which implements non-blocking rendering to get the highest possible framerate, and Paul Stoffregen's Audio library, which provides professional audio processing capabilities.

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.

Activity

  1. zackees commented on Dec 28, 2024

    @zackees
    Member

    My one request for you would be to #if 0 out any code so that it's only running with the ObjectFLED driver.

    Please let me know if it's stable then.

  2. zackees commented on Dec 29, 2024

    @zackees
    Member

    Can you explain how you enable the Serial WS2812 driver in your project?

  3. lpaolini commented on Dec 29, 2024

    @lpaolini
    Author

    Can you explain how you enable the Serial WS2812 driver in your project?

    See lines 6-8 here and 396-399 here

    Then I'm addressing LEDs using CRGBSets.

  4. lpaolini commented on Dec 29, 2024

    @lpaolini
    Author

    My one request for you would be to #if 0 out any code so that it's only running with the ObjectFLED driver.

    Please let me know if it's stable then.

    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

  5. lpaolini commented on Dec 30, 2024

    @lpaolini
    Author

    I hope this incompatibility can be resolved, as the Audio library offers immense value for LED projects based on Teensy 4.x.

  6. zackees commented on Dec 30, 2024

    @zackees
    Member

    @PaulStoffregen thanks for the great audio library. Any insight here?

  7. KurtMF commented on Dec 31, 2024

    @KurtMF

    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?

  8. KurtMF commented on Dec 31, 2024

    @KurtMF

    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?

  9. KurtMF commented on Dec 31, 2024

    @KurtMF

    @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!

  10. zackees commented on Dec 31, 2024

    @zackees
    Member

    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'll add it now

  11. zackees commented on Dec 31, 2024

    @zackees
    Member

    Okay, checked into master, enable it like this:

    #define FASTLED_OBJECTFLED_LATCH_DELAY 150  // microseconds
    #include "FastLED.h"
  12. zackees commented on Dec 31, 2024

    @zackees
    Member

    Kurt, did you see any change in stability when the DMA buffer size was increased?

  13. KurtMF commented on Dec 31, 2024

    @KurtMF

    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.

  14. 33 remaining items

  15. lpaolini commented on Jan 12, 2025

    @lpaolini
    Author

    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?

  16. zackees commented on Jan 12, 2025

    @zackees
    Member

    Awesome, the overflow issue seems to be solved! I've tried changing the order of initialization and it's working good.

    Merged.

    However, one of the strips is still flickering. Isn't the latest ObjectFLED driver supposed to be using the very same timings as WS2812Serial?

    Try this:

    #define FASTLED_OVERCLOCK 1.2
    #include "FastLED.h"
  17. lpaolini commented on Jan 12, 2025

    @lpaolini
    Author

    When I do that, the already working strips continue to do so, while the flickering one shows noise.

  18. KurtMF commented on Jan 12, 2025

    @KurtMF

    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?

  19. KurtMF commented on Jan 12, 2025

    @KurtMF

    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?

  20. lpaolini commented on Jan 12, 2025

    @lpaolini
    Author

    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 :-)

  21. zackees commented on Jan 12, 2025

    @zackees
    Member

    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?

    Can you elaborate

  22. KurtMF commented on Jan 12, 2025

    @KurtMF

    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?

  23. zackees commented on Jan 12, 2025

    @zackees
    Member

    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.

  24. KurtMF commented on Jan 13, 2025

    @KurtMF

    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. :-)

  25. zackees commented on Jan 13, 2025

    @zackees
    Member

    So I guess you bypass ObjectFLED.genFrameBuffer() and create your own (FastLED) framebuffer in vectors?

    No I don't bypass it.

    I just use more memory.

  26. zackees commented on Jan 13, 2025

    @zackees
    Member

    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.

  27. zackees commented on Jan 13, 2025

    @zackees
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions