0

I have a set of WS2811 lights controlled using neopixels. The light data line is connected to GPIO18.

    for i in range (N):
        pixels[i] = colour
    pixels.show()

I expected this to be the equivalent of pixels.fill(colour) but when it runs I can see the lights change iteratively and progressively. It takes a couple of seconds to change all the lights.

I want to fill the pixel buffer with all the colours per pixel and have them all change at once. How can I do this? Why is the above demo so slow?

spraff
  • 101
  • You are asking us to guess the number of LEDs you are driving as well as to guess the details of the software you are using. – joan Oct 21 '21 at 15:49

1 Answers1

1

WS2811 LEDs implement a serial interface where each LED gets its own color information, and then transmits the rest of the bit stream down the line. Each LED changes colors as soon as it receives its own data. No matter what you do, there is a limit of how fast this bitstream is transmitted, and with enough LEDs the update lag will become visible.

If your code updates the LEDs significantly slower than pixels.fill(colour), you must check the libraries you have installed. With original Adafruit neopixel the update time should be the same, because fill calls show just as your code does:

    def fill(self, color):
        """
        Fills the given pixelbuf with the given color.
        :param pixelbuf: A pixel object.
        :param color: Color to set.
        """
        r, g, b, w = self._parse_color(color)
        for i in range(self._pixels):
            self._set_item(i, r, g, b, w)
        if self.auto_write:
            self.show()
Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144