Page 1 of 1

FastLED for MicroPython

Posted: Mon Sep 04, 2017 9:12 pm
by ayke
I've ported over some animations from FastLED to MicroPython, to make animations actually *fast*. The default LED implementation was way too slow for me. I took inspiration from how NumPy accelerates calculations by doing them on a whole array at once.

Example (BBCode doesn't seem to work, sorry about that):

import pixels
import machine
import time
l = pixels.Pixels(machine.Pin(15), 150, pixels.GRB)
hue = 0
while True:
. . hue = (hue + 0.005) % 1
. . l.fill_rainbow(hue, -0.02)
. . l.write()
. . time.sleep(0.01)

More complicated animations are also possible. I ported both Fire2012WithPalette[1] and pride2015[2] over to this library, with decent speed (about 80fps and 115fps respectively for 150 LEDs). It's about 2-10 times slower than native FastLED on the ESP8266 and sometimes slower than FastLED on the Arduino Uno. On the other hand, we have to consider it's written in Python and lacking all template-based optimization that FastLED normally uses so it's actually quite fast. Writing out the LEDs (WS2812) is slower than generating the next frame, unless you have very complicated animations or are doing them pixel-by-pixel in Python.

The code is over here in the modpixel branch: Some documentation can be found over here: ... /

I would love to see something like this in the MicroPython core, but I doubt that's going to happen. If there was a way to include true native code in a Python library I'd try that.

[1]: ... alette.ino

Re: FastLED for MicroPython

Posted: Fri Sep 29, 2017 5:34 am
by gomibako
Great Job! This is what i am looking for. Thanks a lot.

Re: FastLED for MicroPython

Posted: Tue Feb 27, 2018 9:18 pm
by sunrise17
I am getting following error in ESP32 board. Is it possible to adjust it?
File "", line 4, in <module>
ImportError: no module named '_pixels'

Re: FastLED for MicroPython

Posted: Sat Jun 09, 2018 7:32 am
by dn8beats
Are your ports of Fire2012WithPalette and pride2015 available online?

Re: FastLED for MicroPython

Posted: Tue Jun 12, 2018 8:13 pm
by ayke
I haven't originally written them myself (only converted them), but I've put them online here: ... 6e4b0f3b64