LED Panel (WS2812b) + Pico == bad speed

Posted on
  • I'm working on a digital art LED panel with WS2812b pixels/strips.
    Currently I'm using a teensy 3.1 controller + FastLED library.

    This is a video of the small size prototype:
    video link

    As you can see, it is very smooth and fast.

    Yesterday I try to port this to the Pico, but the refresh rate is very bad.
    The small dummy prototype has only 45 LEDs - the final panel should have more than 1024 LEDs.
    As Espruino can only write all data at once (because of not synchronous SPI write commands)
    this would be a lot of data - and I wonder if this could work on this amount of LEDs?

    Ok I will change the setting to use APA102 LEDs instead of the WS2812b - so it is possible to chain all together and drive the clock with higher frequency rate.

    But can Espruino handle this?
    Or would it be better to move the LED implementation to the firmware part?

  • With WS2812B you can output 33000 LEDs/sec - but as you say, that doesn't leave much time for anything else. With APA102 you should be fine though - however one issue you may hit is the time it takes to actually do the graphics.

    If you're drawing lines with the graphics library you'll be fine, but if you're actually setting all the individual pixels with JavaScript each frame then I think you may find Espruino's execution of JS too slow, rather than the actual IO.

    The JS compiler might work to speed things up, but it's still pretty beta, so more complex code may not work. If that doesn't you'll have to use C code compiled into the firmware - and then you're probably not gaining much over having the Teensy.

  • Ok thanks.
    The hint with the graphics library is perfect. So setting each pixel value takes too much time for the interpreter, so the interval loop could be overrun?
    I think I will choose the APA102 LEDs and run them with higher SPI speed;
    And try to build up a new LED library.

    Before I start, I should do some benchmarks, to see how long did it take to fill led buffer pixel by pixel.
    Can you help me to figure out how to get the fastest baud of SPI port?

    @Gordon could a faster chip like the STM32F427 help to get better times on pixel-by-pixel changing? Or is the JS time also with 180 MHz clock too slow?

  • setting each pixel value takes too much time for the interpreter

    Almost certainly - you could time it with:

    var t=getTime();
    // stuff
    // SPI send

    It's also worth making sure you're writing code that executes quickly on Espruino, see this page for some pointers. You can usually get some quite good speedups by following what's there - but post up if you need some pointers about how to get a bit more speed.

    Can you help me to figure out how to get the fastest baud of SPI port?

    On the APA102, just set the SPI baud rate to something like 16000000 - Espruino won't be able to drive it much faster than that. Also try using the build from http://www.espruino.com/binaries/git/com­mits/d1139b57f9957ea844e0beef1907ffd7e6a­923b5

    It's not released yet but there are some speed improvements for SPI in recent builds.


    Yes, it would help I'm sure. However the experience with the other boards doesn't tend to be quite as polished as it is with the Espruino ones :)

  • Wow thanks, I will try this the next days...
    But one question:
    is it possible to compile JS functions or source code and store it on SD card,
    and load them from SD and execute them without interpreter?

    If this is possible I can compile my effect functions and execute them from SD card like small programs

    This would be great to have this feature.
    Your main program is running in JavaScript and you can execute small compiled code programs.

  • Yes, you can do that. Easiest way it to look at the code that gets sent to Espruino for a compiled function (E.nativeCall(....)) by looking back in the command history, and you can then just copy that, put it on an SD card, and use eval to evaluate it and return the result (the native function).

    Only downside is that the native functions will be different for each firmware version of Espruino, so if you update the firmware you'll have to update each function.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

LED Panel (WS2812b) + Pico == bad speed

Posted by Avatar for Jorgen @Jorgen