I'm experimenting with MicroPython on the Micro:bit V1. Playing around with some NeoPixel/WS2812 LED strips, I see much slower update speeds than I expect. I can implement similar things to what I'm doing in my Python script on https://makecode.microbit.org/, and they will run MUCH quicker than my Python code?
Here is an example fading LEDs out. I expect the fading to occur MUCH faster than it actally does. Even precomputing the values I calculate by multipying, do not help (much). Seems like the for loops are inherently slow??
Code: Select all
import neopixel
import microbit as mb
led_strip = neopixel.NeoPixel(mb.pin0, 128)
while True:
# All LEDs on
for i in range(len(led_strip)):
led_strip[i] = (0x0F, 0x00, 0x00)
led_strip.show()
# Fade out
for n in range(10):
for i in range(len(led_strip)):
led_strip[i] = ( int(led_strip[i][0]*0.8), 0, 0)
led_strip.show()
- When writing my Python script, I use the documentation here: https://microbit-micropython.readthedocs.io/en/v2-docs/
- This is how I upload the code: uflash my_code.py
- I'm running Linux
- My Python code is inappropriate for use on a microcontroller
- MicroPython is too slow for my purposes
- The neopixel library i'm using, is very slow, and I should use another
Regards,
Tobias