adafruit_pixelbuf
- A pure Python implementation of adafruit_pixelbuf.¶
This class is used when the native adafruit_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 & Rose Hooper
- class adafruit_pixelbuf.PixelBuf(size: int, *, byteorder: str = 'BGR', brightness: float = 1.0, auto_write: bool = False, header: bytes | None = None, trailer: bytes | None = None)¶
A sequence of RGB/RGBW pixels.
This is the pure python implementation of CircuitPython’s adafruit_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.
- property bpp¶
The number of bytes per pixel in the buffer (read-only).
- property 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.
- property byteorder¶
ByteOrder string for the buffer (read-only)
- fill(color: int | Tuple[int, int, int] | Tuple[int, int, int, int])¶
Fills the given pixelbuf with the given color. :param pixelbuf: A pixel object. :param color: Color to set.
- static parse_byteorder(byteorder: str) Tuple[int, str, bool, bool] ¶
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)
- Parameters:
bpp (~str) – bpp string.
- Return ~tuple:
bpp, byteorder, has_white, dotstar_mode
- show()¶
Call the associated write function to display the pixels