What a visual effect this code do?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Repointed
Posts: 2
Joined: Mon Jun 29, 2020 4:07 pm

What a visual effect this code do?

Post by Repointed » Mon Jun 29, 2020 4:34 pm

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

User avatar
jimmo
Posts: 1710
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: What a visual effect this code do?

Post by jimmo » Tue Jun 30, 2020 12:45 pm

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

Repointed
Posts: 2
Joined: Mon Jun 29, 2020 4:07 pm

Re: What a visual effect this code do?

Post by Repointed » Wed Jul 01, 2020 4:14 am

Thanks a lot!

Post Reply