adafruit_pypixelbuf - A pure python implementation of _pixelbuf

This class is used when _pixelbuf is not available in CircuitPython. It is based on the work in neopixel.py and adafruit_dotstar.py.

  • Author(s): Damien P. George & Limor Fried & Scott Shawcroft & Roy Hooper
class adafruit_pypixelbuf.PixelBuf(n, byteorder='BGR', brightness=1.0, auto_write=False, header=None, trailer=None)

A sequence of RGB/RGBW pixels.

This is the pure python implementation of CircuitPython’s _pixelbuf.

Parameters:
  • n (~int) – Number of pixels
  • byteorder (~str) – Byte order string constant (also sets bpp)
  • brightness (~float) – Brightness (0 to 1.0, default 1.0)
  • auto_write (~bool) – Whether to automatically write pixels (Default False)
  • header (bytes) – Sequence of bytes to always send before pixel values.
  • trailer (bytes) – Sequence of bytes to always send after pixel values.
bpp

The number of bytes per pixel in the buffer (read-only).

brightness

Float value between 0 and 1. Output brightness.

When brightness is less than 1.0, a second buffer will be used to store the color values before they are adjusted for brightness.

byteorder

ByteOrder string for the buffer (read-only)

fill(color)

Fills the given pixelbuf with the given color. :param pixelbuf: A pixel object. :param color: Color to set.

static parse_byteorder(byteorder)

Parse a Byteorder string for validity and determine bpp, byte order, and dostar brightness bits.

Byteorder strings may contain the following characters:
R - Red G - Green B - Blue W - White P - PWM (PWM Duty cycle for pixel - dotstars 0 - 1.0)
Param:~str bpp: bpp string.
Returns:~tuple: bpp, byteorder, has_white, dotstar_mode
show()

Call the associated write function to display the pixels

adafruit_pypixelbuf.colorwheel(pos)

Helper to create a colorwheel.

Parameters:pos – int 0-255 of color value to return
Returns:tuple of RGB values
adafruit_pypixelbuf.wheel(pos)

Helper to create a colorwheel.

Parameters:pos – int 0-255 of color value to return
Returns:tuple of RGB values