Page 1 of 1

What a visual effect this code do?

Posted: Mon Jun 29, 2020 4:34 pm
by Repointed
Hey guys!

I'm translating the MicroPython tutorial for ESP8266 to russian language right now and I have a problem with this part (from here):

Code: Select all

# Demo 3: Fade all pixels together through rainbow colours, offset each pixel
for r in range(5):
    for n in range(256):
        for i in range(strip.n):
            strip[i] = wheel(((i * 256 // strip.n) + n) & 255, brightness)
        strip.write()
    time.sleep_ms(25)
I know just really basics in programming and I don't have an ESP8266 chip and an APA102 LEDs so I can't check it for myself.

So can you please explain me what do this code do? Does it force the LEDs to change their color through all the rainbow colors and then fade out? Or the rainbow colors just repeatively change each other without fading out? Does the colors move across the strip during color changing (the "offset each pixel" phrase in the description means just like that, right?).

Or maybe it's too much to ask but it would be really nice if you make a little video of what visual effect this code do (I mean, if you have an ESP8266 and an APA102).

Please help :)

Re: What a visual effect this code do?

Posted: Tue Jun 30, 2020 12:45 pm
by jimmo
It looks like this code makes the strip show a rainbow and then does one rotation of moving the starting point (in 256 steps).

i.e.

Code: Select all

R...O...Y...G...B...I...V...
.R...O...Y...G...B...I...V..
..R...O...Y...G...B...I...V.
...R...O...Y...G...B...I...V
V...R...O...Y...G...B...I...
...
...O...Y...G...B...I...V...R

Re: What a visual effect this code do?

Posted: Wed Jul 01, 2020 4:14 am
by Repointed
Thanks a lot!