adafruit_pixelbuf
–一个快速的 RGB(W) 像素缓冲库,用于 NeoPixel 和 DotStar
该 adafruit_pixelbuf
模块提供了PixelBuf
加速 RGB(W) 条带/矩阵操作的类,例如 DotStar 和 Neopixel。
也可作为 _pixelbuf
. 此用法已被弃用。
字节顺序是用字符串配置的,例如“RGB”或“RGBD”。
在这些板上可用
- ARAMCON Badge 2019
- ARAMCON2 Badge
- ATMegaZero ESP32-S2
- Adafruit CLUE nRF52840 Express
- Adafruit Circuit Playground Bluefruit
- Adafruit Circuit Playground Express 4-H
- Adafruit CircuitPlayground Express
- Adafruit CircuitPlayground Express with Crickit libraries
- Adafruit EdgeBadge
- Adafruit Feather Bluefruit Sense
- Adafruit Feather M0 Express
- Adafruit Feather M0 Express with Crickit libraries
- Adafruit Feather M4 CAN
- Adafruit Feather M4 Express
- Adafruit Feather MIMXRT1011
- Adafruit Feather RP2040
- Adafruit Feather STM32F405 Express
- Adafruit Feather nRF52840 Express
- Adafruit FunHouse
- Adafruit Grand Central M4 Express
- Adafruit Hallowing M4 Express
- Adafruit ItsyBitsy M0 Express
- Adafruit ItsyBitsy M4 Express
- Adafruit ItsyBitsy RP2040
- Adafruit ItsyBitsy nRF52840 Express
- Adafruit LED Glasses Driver nRF52840
- Adafruit Macropad RP2040
- Adafruit MagTag
- Adafruit Matrix Portal M4
- Adafruit Metro ESP32S2
- Adafruit Metro M0 Express
- Adafruit Metro M4 Airlift Lite
- Adafruit Metro M4 Express
- Adafruit Metro nRF52840 Express
- Adafruit Monster M4SK
- Adafruit NeoKey Trinkey M0
- Adafruit NeoPixel Trinkey M0
- Adafruit ProxLight Trinkey M0
- Adafruit PyGamer
- Adafruit PyPortal
- Adafruit PyPortal Pynt
- Adafruit PyPortal Titano
- Adafruit Pybadge
- Adafruit QT Py M0 Haxpress
- Adafruit QT Py RP2040
- Adafruit QT2040 Trinkey
- Adafruit Rotary Trinkey M0
- Adafruit Slide Trinkey M0
- Adafruit Trellis M4 Express
- AloriumTech Evo M51
- Arduino Nano 33 BLE
- Arduino Nano RP2040 Connect
- Artisense Reference Design RD00
- AtelierDuMaker nRF52840 Breakout
- BDMICRO VINA-D21
- BDMICRO VINA-D51
- BLE-SS dev board Multi Sensor
- BastBLE
- BastWiFi
- BlueMicro840
- CP Sapling M0 w/ SPI Flash
- CP32-M4
- Capable Robot Programmable USB Hub
- Cedar Grove StringCar M0 Express
- Challenger RP2040 WiFi
- Circuit Playground Express Digi-Key PyCon 2019
- CircuitBrains Basic
- CircuitBrains Deluxe
- CrumpS2
- Cytron Maker Pi RP2040
- DynOSSAT-EDU-EPS
- DynOSSAT-EDU-OBC
- ESP 12k NodeMCU
- Electronic Cats Hunter Cat NFC
- Electronut Labs Blip
- Electronut Labs Papyr
- EncoderPad RP2040
- Espruino Pico
- Espruino Wifi
- Feather ESP32S2 without PSRAM
- Feather MIMXRT1011
- Feather MIMXRT1062
- FeatherS2
- FeatherS2 Neo
- FeatherS2 PreRelease
- Fomu
- Franzininho WIFI w/Wroom
- Franzininho WIFI w/Wrover
- Gravitech Cucumber M
- Gravitech Cucumber MS
- Gravitech Cucumber R
- Gravitech Cucumber RS
- HMI-DevKit-1.1
- Hacked Feather M0 Express with 8Mbyte SPI flash
- HalloWing M0 Express
- HiiBot BlueFi
- IMXRT1010-EVK
- IkigaiSense Vita nRF52840
- Kaluga 1
- LILYGO TTGO T8 ESP32-S2 w/Display
- MDBT50Q-DB-40
- MDBT50Q-RX Dongle
- MEOWBIT
- MORPHEANS MorphESP-240
- MakerDiary nRF52840 MDK
- MakerDiary nRF52840 MDK USB Dongle
- Makerdiary M60 Keyboard
- Makerdiary Pitaya Go
- Makerdiary nRF52840 M.2 Developer Kit
- Melopero Shake RP2040
- Metro MIMXRT1011
- Mini SAM M4
- NUCLEO STM32F746
- NUCLEO STM32F767
- NUCLEO STM32H743
- OPENMV-H7 R1
- Oak Dev Tech BREAD2040
- Oak Dev Tech PixelWing ESP32S2
- Open Hardware Summit 2020 Badge
- PCA10056 nRF52840-DK
- PCA10059 nRF52840 Dongle
- PYB LR Nano V2
- Particle Argon
- Particle Boron
- Particle Xenon
- Pimoroni Interstate 75
- Pimoroni Keybow 2040
- Pimoroni PGA2040
- Pimoroni Pico LiPo (16MB)
- Pimoroni Pico LiPo (4MB)
- Pimoroni PicoSystem
- Pimoroni Plasma 2040
- Pimoroni Tiny 2040
- PyCubedv04
- PyCubedv04-MRAM
- PyCubedv05
- PyCubedv05-MRAM
- PyKey60
- PyboardV1_1
- Raspberry Pi Pico
- Robo HAT MM1 M4
- S2Mini
- SAM E54 Xplained Pro
- SAM32v26
- SPRESENSE
- ST STM32F746G Discovery
- STM32F411E_DISCO
- STM32F412G_DISCO
- STM32F4_DISCO
- Saola 1 w/Wroom
- Saola 1 w/Wrover
- Seeeduino Wio Terminal
- Serpente
- Silicognition LLC M4-Shim
- SparkFun LUMIDrive
- SparkFun MicroMod RP2040 Processor
- SparkFun MicroMod SAMD51 Processor
- SparkFun MicroMod nRF52840 Processor
- SparkFun Pro Micro RP2040
- SparkFun Pro nRF52840 Mini
- SparkFun RedBoard Turbo
- SparkFun STM32 MicroMod Processor
- SparkFun Thing Plus - RP2040
- SparkFun Thing Plus - SAMD51
- Sprite_v2b
- StackRduino M0 PRO
- TG-Boards' Datalore IP M4
- TG-Watch
- THUNDERPACK_v11
- THUNDERPACK_v12
- Targett Module Clip w/Wroom
- Targett Module Clip w/Wrover
- Teensy 4.0
- Teensy 4.1
- Teknikio Bluebird
- The Open Book Feather
- TinkeringTech ScoutMakes Azul
- TinyS2
- Trinket M0 Haxpress
- UARTLogger II
- WarmBit BluePixel nRF52840
- Winterbloom Big Honking Button
- Winterbloom Sol
- iMX RT 1020 EVK
- iMX RT 1060 EVK
- keithp.com snekboard
- microS2
- nanoESP32-S2 w/Wrover
- nanoESP32-S2 w/Wroom
- nice!nano
- stm32f411ce-blackpill
- stm32f411ce-blackpill-with-flash
-
class
adafruit_pixelbuf.
PixelBuf
(size: int, *, byteorder: str = 'BGR', brightness: float = 0, auto_write: bool = False, header: _typing.ReadableBuffer = b'', trailer: _typing.ReadableBuffer = b'')
用于 LED 和类似设备的快速 RGB[W] 像素缓冲区。
创建具有指定大小、字节顺序和每像素位数的 PixelBuf 对象。
当亮度小于 1.0 时,在调整亮度之前,将使用第二个缓冲区来存储颜色值。
当 P
(PWM 持续时间)作为字节顺序字符串的第 4 个字符出现时,像素元组/列表中的第 4 个值是单个像素亮度(0.0-1.0),并将为每个像素启用与 Dotstar 兼容的第一个字节。
- 参数
size (int) – 像素数
byteorder (str) – 字节顺序字符串(例如“RGB”、“RGBW”或“PBGR”)
brightness (float) – 亮度(0 到 1.0,默认 1.0)
auto_write (bool) – 是否自动写入像素(默认为 False)
header (ReadableBuffer) – 始终在像素值之前发送的字节序列。
trailer (ReadableBuffer) – 始终在像素值之后发送的字节序列。
-
bpp
:int
缓冲区中每个像素的字节数(只读)
-
brightness
:float
0 到 1 之间的浮点值。输出亮度。
当亮度小于 1.0 时,在调整亮度之前,将使用第二个缓冲区来存储颜色值。
-
auto_write
:bool
每次更新后是否自动写入像素。
-
byteorder
:str
缓冲区的字节顺序字符串(只读)
-
show
(self) → None
将颜色数据传输到像素,以便显示它们。这在auto_write
为 True时自动完成。
-
fill
(self, color: Union[int, Tuple[int, int, int], Tuple[int, int, int, float]]) → None
用给定的颜色填充给定的 pixelbuf。
-
__getitem__
(self, index: slice) → Union[Tuple[Tuple[int, int, int], Ellipsis], Tuple[Tuple[int, int, int, float], Ellipsis]]
-
__getitem__
(self, index: int) → Union[Tuple[int, int, int], Tuple[int, int, int, float]]
以 0 到 255 之间的 (Red, Green, Blue[, White]) 值的元组形式返回给定索引处的像素值。在 PWM (DotStar) 模式下,第 4 个元组值是从 0 开始的像素强度的浮点数-1.0。
-
__setitem__
(self, index: slice, value: Tuple[Union[int, Tuple[float, Ellipsis], List[float]], Ellipsis]) → None
-
__setitem__
(self, index: slice, value: List[Union[int, Tuple[float, Ellipsis], List[float]]]) → None
-
__setitem__
(self, index: int, value: Union[int, Tuple[float, Ellipsis], List[float]]) → None
设置给定索引处的像素值。值可以是元组或整数。元组是 0 到 255 之间的单个 (Red, Green, Blue[, White]) 值。如果给定一个整数,则将红色、绿色和蓝色值打包到低三个字节 (0xRRGGBB) 中。对于 RGBW 字节顺序,如果仅以 int 或元组形式给出 RGB 值,则当红色、绿色和蓝色值相同时,将使用白色值。