displayio – High level, display object compositing system

The displayio module contains classes to define what objects to display. It is optimized for low memory use and, therefore, computes final pixel values for dirty regions as needed.

Separate modules manage transmitting the display contents to a display.

For more a more thorough explanation and guide for using displayio, please refer to this Learn guide.

Available on these boards
  • 01Space 0.42 OLED ESP32C3
  • 0xCB Helios
  • 42. Keebs Frood
  • 8086 USB Interposer
  • AITHinker ESP32-C3S_Kit
  • AITHinker ESP32-C3S_Kit_2M
  • ARAMCON Badge 2019
  • ARAMCON2 Badge
  • ATMegaZero ESP32-S2
  • Adafruit CLUE nRF52840 Express
  • Adafruit Camera
  • Adafruit Circuit Playground Bluefruit
  • Adafruit CircuitPlayground Express with displayio
  • Adafruit EdgeBadge
  • Adafruit Feather Bluefruit Sense
  • Adafruit Feather ESP32 V2
  • Adafruit Feather ESP32-C6 4MB Flash No PSRAM
  • Adafruit Feather ESP32-S2 Reverse TFT
  • Adafruit Feather ESP32-S2 TFT
  • Adafruit Feather ESP32-S3 Reverse TFT
  • Adafruit Feather ESP32-S3 TFT
  • Adafruit Feather ESP32S2
  • Adafruit Feather ESP32S3 4MB Flash 2MB PSRAM
  • Adafruit Feather ESP32S3 No PSRAM
  • Adafruit Feather HUZZAH32
  • Adafruit Feather M0 Express
  • Adafruit Feather M4 CAN
  • Adafruit Feather M4 Express
  • Adafruit Feather MIMXRT1011
  • Adafruit Feather RP2040
  • Adafruit Feather RP2040 Adalogger
  • Adafruit Feather RP2040 CAN
  • Adafruit Feather RP2040 DVI
  • Adafruit Feather RP2040 Prop-Maker
  • Adafruit Feather RP2040 RFM
  • Adafruit Feather RP2040 Scorpio
  • Adafruit Feather RP2040 ThinkInk
  • Adafruit Feather RP2040 USB Host
  • Adafruit Feather RP2350
  • Adafruit Feather STM32F405 Express
  • Adafruit Feather nRF52840 Express
  • Adafruit Floppsy RP2040
  • Adafruit FunHouse
  • Adafruit Grand Central M4 Express
  • Adafruit HUZZAH32 Breakout
  • Adafruit Hallowing M4 Express
  • Adafruit ItsyBitsy ESP32
  • Adafruit ItsyBitsy M0 Express
  • Adafruit ItsyBitsy M4 Express
  • Adafruit ItsyBitsy RP2040
  • Adafruit ItsyBitsy nRF52840 Express
  • Adafruit KB2040
  • Adafruit LED Glasses Driver nRF52840
  • Adafruit Macropad RP2040
  • Adafruit MagTag
  • Adafruit Matrix Portal M4
  • Adafruit MatrixPortal S3
  • Adafruit Metro ESP32S2
  • Adafruit Metro ESP32S3
  • Adafruit Metro M0 Express
  • Adafruit Metro M4 Airlift Lite
  • Adafruit Metro M4 Express
  • Adafruit Metro RP2040
  • Adafruit Metro RP2350
  • Adafruit Metro nRF52840 Express
  • Adafruit Monster M4SK
  • Adafruit PyGamer
  • Adafruit PyPortal
  • Adafruit PyPortal Pynt
  • Adafruit PyPortal Titano
  • Adafruit Pybadge
  • Adafruit QT Py ESP32 PICO
  • Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM
  • Adafruit QT Py ESP32-S3 no psram
  • Adafruit QT Py ESP32C3
  • Adafruit QT Py ESP32S2
  • Adafruit QT Py M0 Haxpress
  • Adafruit QT Py RP2040
  • Adafruit QT2040 Trinkey
  • Adafruit Trellis M4 Express
  • Adafruit Vindie S2
  • Adafruit-Qualia-S3-RGB666
  • Ai Thinker ESP32-CAM
  • AloriumTech Evo M51
  • Archi RP2040
  • Arduino Nano 33 BLE
  • Arduino Nano 33 BLE Rev2
  • Arduino Nano ESP32
  • Arduino Nano RP2040 Connect
  • Artisense Reference Design RD00
  • AtelierDuMaker nRF52840 Breakout
  • AutosportLabs-ESP32-CAN-X2
  • BARDUINO 4.0.2
  • BBQ20KBD
  • BDMICRO VINA-D51
  • BLE-SS dev board Multi Sensor
  • BLING!
  • BLOK
  • BPI-Bit-S2
  • BPI-Leaf-S3
  • BPI-PicoW-S3
  • BastBLE
  • BastWiFi
  • Bee-Data-Logger
  • Bee-Motion-S3
  • Bee-S3
  • BlizzardS3
  • BlueMicro840
  • Bradán Lane STUDIO Explorer Badge
  • COSMO-Pico
  • CP Sapling M0 w/ SPI Flash
  • CP32-M4
  • CRCibernetica IdeaBoard
  • Cedar Grove StringCar M0 Express
  • Challenger NB RP2040 WiFi
  • Challenger RP2040 LTE
  • Challenger RP2040 LoRa
  • Challenger RP2040 SD/RTC
  • Challenger RP2040 SubGHz
  • Challenger RP2040 WiFi
  • Challenger RP2040 WiFi/BLE
  • Challenger+ RP2350 BConnect
  • Challenger+ RP2350 WiFi6/BLE5
  • CircuitART Zero S3
  • CircuitBrains Basic
  • CircuitBrains Deluxe
  • ColumbiaDSL-Sensor-Board-V1
  • CrumpS2
  • Cytron EDU PICO W
  • Cytron IRIV IO Controller
  • Cytron MOTION 2350 Pro
  • Cytron Maker Feather AIoT S3
  • Cytron Maker Nano RP2040
  • Cytron Maker Pi RP2040
  • Cytron Maker Uno RP2040
  • DFRobot Beetle ESP32-C3
  • DFRobot FireBeetle 2 ESP32-S3
  • Datanoise PicoADK
  • Datanoise PicoADK V2
  • Deneyap Kart
  • Deneyap Kart 1A
  • Deneyap Kart 1A v2
  • Deneyap Kart G
  • Deneyap Mini
  • Deneyap Mini v2
  • Diodes Delight Piunora
  • DynOSSAT-EDU-EPS
  • DynOSSAT-EDU-OBC
  • E-Fidget
  • ELECFREAKS PICO:ED
  • ES3ink
  • ESP 12k NodeMCU
  • ESP32 Devkit V1
  • ESP32-C3-DevKitM-1
  • ESP32-C6-DevKitC-1-N8
  • ESP32-C6-DevKitM-1
  • ESP32-H2-DevKitM-1
  • ESP32-P4-Function-EV
  • ESP32-S2-DevKitC-1-N4
  • ESP32-S2-DevKitC-1-N4R2
  • ESP32-S2-DevKitC-1-N8R2
  • ESP32-S3-Box-2.5
  • ESP32-S3-Box-Lite
  • ESP32-S3-DevKitC-1-N16
  • ESP32-S3-DevKitC-1-N32R8
  • ESP32-S3-DevKitC-1-N8
  • ESP32-S3-DevKitC-1-N8R2
  • ESP32-S3-DevKitC-1-N8R8
  • ESP32-S3-DevKitC-1-N8R8-with-HACKTABLET
  • ESP32-S3-DevKitM-1-N8
  • ESP32-S3-EYE
  • ESP32-S3-USB-OTG-N8
  • ESP8684-DevKitC-02-N4
  • Electrolama minik
  • Electronic Cats Hunter Cat NFC
  • Electronut Labs Blip
  • Electronut Labs Papyr
  • EncoderPad RP2040
  • Espressif ESP32 DevKitc V4 WROOM-32E
  • Espressif ESP32 DevKitc V4 WROVER
  • Espressif ESP32 TTGO T8 v1.7
  • Espressif ESP32-EYE
  • Espressif ESP32-LyraT
  • Espressif-ESP32-S3-LCD-EV-Board
  • Espressif-ESP32-S3-LCD-EV-Board_v1.5
  • Espruino Bangle.js 2
  • Espruino Pico
  • Espruino Wifi
  • Feather MIMXRT1011
  • Feather MIMXRT1062
  • FeatherS2
  • FeatherS2 Neo
  • FeatherS2 PreRelease
  • FeatherS3
  • FeatherS3 Neo
  • Fig Pi
  • Flipper Zero Wi-Fi Dev
  • Franzininho WIFI w/Wroom
  • Franzininho WIFI w/Wrover
  • Freenove ESP32-WROVER-DEV-CAM
  • Gravitech Cucumber M
  • Gravitech Cucumber MS
  • Gravitech Cucumber R
  • Gravitech Cucumber RS
  • HEIA-FR Picomo V2
  • HMI-DevKit-1.1
  • Hack Club Sprig
  • Hacked Feather M0 Express with 8Mbyte SPI flash
  • HalloWing M0 Express
  • Hardkernel Odroid Go
  • Heltec ESP32-S3-WIFI-LoRa-V3
  • HexKyS2
  • HiiBot BlueFi
  • IMXRT1010-EVK
  • IMXRT1015-EVK
  • IkigaiSense Vita nRF52840
  • IoTs2
  • Kaluga 1
  • LILYGO T-DECK
  • LILYGO T-DISPLAY
  • LILYGO T-DISPLAY S3 v1.2
  • LILYGO T-Display S3 Pro
  • LILYGO T-Watch-S3
  • LILYGO TEMBED ESP32S3
  • LILYGO TTGO T-01C3
  • LILYGO TTGO T-DISPLAY v1.1
  • LILYGO TTGO T-DISPLAY v1.1 4M
  • LILYGO TTGO T-OI PLUS
  • LILYGO TTGO T8 ESP32-S2
  • LILYGO TTGO T8 ESP32-S2 w/Display
  • LOLIN S3 16MB Flash 8MB PSRAM
  • LOLIN S3 MINI 4MB Flash 2MB PSRAM
  • LOLIN S3 PRO 16MB Flash 8MB PSRAM
  • Lilygo T-watch 2020 V3
  • Luatos Core-ESP32C3
  • M5STACK STAMP-C3
  • M5Stack Atom Echo
  • M5Stack Atom Lite
  • M5Stack Atom Matrix
  • M5Stack Atom U
  • M5Stack AtomS3
  • M5Stack AtomS3 Lite
  • M5Stack AtomS3U
  • M5Stack Cardputer
  • M5Stack Core Basic
  • M5Stack Core Fire
  • M5Stack Core2
  • M5Stack CoreS3
  • M5Stack Dial
  • M5Stack M5Paper
  • M5Stack Stick C
  • M5Stack Stick C Plus
  • M5Stack Timer Camera X
  • MDBT50Q-DB-40
  • MDBT50Q-RX Dongle
  • MEOWBIT
  • MORPHEANS MorphESP-240
  • MagiClick S3 N4R2
  • Maker Go ESP32C3 Supermini
  • Maker Go ESP32C6 Supermini
  • Maker badge by Czech maker
  • MakerDiary nRF52840 MDK
  • MakerDiary nRF52840 MDK USB Dongle
  • MakerFabs-ESP32-S3-Parallel-TFT-With-Touch-7inch
  • Makerdiary M60 Keyboard
  • Makerdiary Pitaya Go
  • Makerdiary nRF52840 Connect Kit
  • Makerdiary nRF52840 M.2 Developer Kit
  • Maple Computing Elite-Pi
  • Melopero Shake RP2040
  • Metro MIMXRT1011
  • MicroDev microC3
  • MicroDev microS2
  • Mini SAM M4
  • MixGo CE
  • NUCLEO STM32F746
  • NUCLEO STM32F767
  • NUCLEO STM32H743
  • NanoS3
  • Neuron
  • NodeMcu-ESP32-C2
  • OMGS3
  • OPENMV-H7 R1
  • Oak Dev Tech BREAD2040
  • Oak Dev Tech Cast-Away RP2040
  • Oak Dev Tech PixelWing ESP32S2
  • Oak Dev Tech RPGA Feather
  • Open Hardware Summit 2020 Badge
  • Oxocard Artwork
  • Oxocard Connect
  • Oxocard Galaxy
  • Oxocard Science
  • P1AM-200
  • PCA10056 nRF52840-DK
  • PCA10059 nRF52840 Dongle
  • PYB LR Nano V2
  • Pajenicko PicoPad
  • Particle Argon
  • Particle Boron
  • Particle Xenon
  • PewPew LCD
  • PewPew M4
  • PillBug
  • Pimoroni Badger 2040
  • Pimoroni Badger 2040 W
  • Pimoroni Inky Frame 5.7
  • Pimoroni Inky Frame 7.3
  • Pimoroni Interstate 75
  • Pimoroni Keybow 2040
  • Pimoroni Motor 2040
  • Pimoroni PGA2040
  • Pimoroni PGA2350
  • Pimoroni Pico DV Base W
  • Pimoroni Pico LiPo (16MB)
  • Pimoroni Pico LiPo (4MB)
  • Pimoroni Pico Plus 2
  • Pimoroni Pico dv Base
  • Pimoroni PicoSystem
  • Pimoroni Plasma 2040
  • Pimoroni Plasma 2040W
  • Pimoroni Plasma 2350
  • Pimoroni Servo 2040
  • Pimoroni Tiny 2040 (2MB)
  • Pimoroni Tiny 2040 (8MB)
  • Pimoroni Tiny 2350
  • Pimoroni Tiny FX
  • ProS3
  • PyKey 18 Numpad
  • PyKey 44 Ergo
  • PyKey 60
  • PyKey 87 TKL
  • PyboardV1_1
  • RF.Guru RP2040
  • RGBTouch Mini
  • RP2.65-F
  • RP2040 Stamp
  • RP2350 Stamp
  • RP2350 Stamp XL
  • Raspberry Breadstick
  • Raspberry Pi 4B
  • Raspberry Pi Compute Module 4
  • Raspberry Pi Compute Module 4 IO Board
  • Raspberry Pi Pico
  • Raspberry Pi Pico 2
  • Raspberry Pi Pico W
  • Raspberry Pi Zero
  • Raspberry Pi Zero 2W
  • Raspberry Pi Zero W
  • S2Mini
  • S2Pico
  • SAM E54 Xplained Pro
  • SAM32v26
  • SQFMI Watchy
  • SSCI ISP1807 Dev Board
  • SSCI ISP1807 Micro Board
  • ST STM32F746G Discovery
  • STM32F411E_DISCO
  • STM32F412G_DISCO
  • STM32F4_DISCO
  • Saola 1 w/Wroom
  • Saola 1 w/Wrover
  • Seeed Studio XIAO ESP32C3
  • Seeed XIAO nRF52840 Sense
  • Seeed Xiao ESP32-C6 4MB Flash 512KB SRAM
  • Seeed Xiao ESP32-S3 Sense
  • Seeeduino Wio Terminal
  • Seeeduino XIAO RP2040
  • Seeeduino XIAO RP2350
  • Serpente
  • SiLabs xG24 Dev Kit
  • SiLabs xG24 Explorer Kit
  • Silicognition LLC M4-Shim
  • Silicognition LLC RP2040-Shim
  • SparkFun LUMIDrive
  • SparkFun MicroMod RP2040 Processor
  • SparkFun MicroMod SAMD51 Processor
  • SparkFun MicroMod nRF52840 Processor
  • SparkFun Pro Micro RP2040
  • SparkFun Pro Micro RP2350
  • SparkFun Pro nRF52840 Mini
  • SparkFun RedBoard Turbo
  • SparkFun STM32 MicroMod Processor
  • SparkFun Teensy MicroMod Processor
  • SparkFun Thing Plus - RP2040
  • SparkFun Thing Plus - SAMD51
  • SparkFun Thing Plus - STM32
  • Sparkfun Thing Plus MGM240P
  • Spotpear ESP32C3 LCD 1.44
  • StackRduino M0 PRO
  • Sunton ESP32-2424S012
  • Sunton-ESP32-8048S050
  • Sunton-ESP32-8048S070
  • SuperMini NRF52840
  • Swan R5
  • TG-Boards' Datalore IP M4
  • TG-Watch
  • THUNDERPACK_v11
  • THUNDERPACK_v12
  • TTGO T8 ESP32-S2-WROOM
  • Targett Module Clip w/Wroom
  • Targett Module Clip w/Wrover
  • Teensy 4.0
  • Teensy 4.1
  • Teknikio Bluebird
  • The Open Book Feather
  • ThingPulse Pendrive S3
  • TinkeringTech ScoutMakes Azul
  • TinyC6
  • TinyPICO
  • TinyPICO Nano
  • TinyS2
  • TinyS3
  • TinyWATCH S3
  • Trinket M0 Haxpress
  • UARTLogger II
  • VCC-GND Studio YD RP2040
  • VCC-GND YD-ESP32-S3 (N16R8)
  • VCC-GND YD-ESP32-S3 (N8R8)
  • VIDI X V1.1
  • W5100S-EVB-Pico
  • W5500-EVB-Pico
  • WK-50 Trackball Keyboard
  • WSC-1450
  • WarmBit BluePixel nRF52840
  • Waveshare ESP32-S2-Pico
  • Waveshare ESP32-S2-Pico-LCD
  • Waveshare ESP32-S3-GEEK
  • Waveshare ESP32-S3-Pico
  • Waveshare ESP32-S3-Tiny
  • Waveshare ESP32-S3-Zero
  • Waveshare ESP32S3 LCD 1.28
  • Waveshare RP2040-GEEK
  • Waveshare RP2040-LCD-0.96
  • Waveshare RP2040-LCD-1.28
  • Waveshare RP2040-One
  • Waveshare RP2040-PiZero
  • Waveshare RP2040-Plus (16MB)
  • Waveshare RP2040-Plus (4MB)
  • Waveshare RP2040-TOUCH-LCD-1.28
  • Waveshare RP2040-Tiny
  • Waveshare RP2040-Zero
  • WeAct ESP32-C6 (4MB)
  • WeAct ESP32-C6 (8MB)
  • WeAct Studio Pico
  • WeAct Studio Pico 16MB
  • WeMos LOLIN32 Lite
  • Wemos Lolin C3 Mini
  • Wemos Lolin C3 Pico
  • WisdPi Ardu2040M
  • WisdPi Tiny RP2040
  • iLabs Challenger 840
  • iMX RT 1020 EVK
  • iMX RT 1040 EVK
  • iMX RT 1050 EVKB
  • iMX RT 1060 EVK
  • iMX RT 1060 EVKB
  • iMX RT1011 Nano Kit
  • keithp.com snekboard
  • nanoESP32-S2 w/Wrover
  • nanoESP32-S2 w/Wroom
  • nice!nano
  • nullbits Bit-C PRO
  • senseBox MCU-S2 ESP32S2
  • splitkb.com Liatris
  • stm32f411ce-blackpill
  • stm32f411ce-blackpill-with-flash
  • sunton_esp32_2432S028
  • sunton_esp32_2432S032C
  • takayoshiotake Octave RP2040
  • uGame10
  • uGame22

displayio.CIRCUITPYTHON_TERMINAL: Group

The displayio.Group that is the displayed serial terminal (REPL).

displayio.release_displays() None

Releases any actively used displays so their buses and pins can be used again. This will also release the builtin display on boards that have one. You will need to reinitialize it yourself afterwards. This may take seconds to complete if an active EPaperDisplay is refreshing.

Use this once in your code.py if you initialize a display. Place it right before the initialization so the display is active as long as possible.

class displayio.Colorspace

The colorspace for a ColorConverter to operate in

RGB888: Colorspace

The standard 24-bit colorspace. Bits 0-7 are blue, 8-15 are green, and 16-24 are red. (0xRRGGBB)

RGB565: Colorspace

The standard 16-bit colorspace. Bits 0-4 are blue, bits 5-10 are green, and 11-15 are red (0bRRRRRGGGGGGBBBBB)

RGB565_SWAPPED: Colorspace

The swapped 16-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB565

RGB555: Colorspace

The standard 15-bit colorspace. Bits 0-4 are blue, bits 5-9 are green, and 11-14 are red. The top bit is ignored. (0bxRRRRRGGGGGBBBBB)

RGB555_SWAPPED: Colorspace

The swapped 15-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB555

class displayio.Bitmap(width: int, height: int, value_count: int)

Stores values of a certain size in a 2D array

Bitmaps can be treated as read-only buffers. If the number of bits in a pixel is 8, 16, or 32; and the number of bytes per row is a multiple of 4, then the resulting memoryview will correspond directly with the bitmap’s contents. Otherwise, the bitmap data is packed into the memoryview with unspecified padding.

A Bitmap can be treated as a buffer, allowing its content to be viewed and modified using e.g., with ulab.numpy.frombuffer, but the displayio.Bitmap.dirty method must be used to inform displayio when a bitmap was modified through the buffer interface.

bitmaptools.arrayblit can also be useful to move data efficiently into a Bitmap.

Create a Bitmap object with the given fixed size. Each pixel stores a value that is used to index into a corresponding palette. This enables differently colored sprites to share the underlying Bitmap. value_count is used to minimize the memory used to store the Bitmap.

Parameters:
  • width (int) – The number of values wide

  • height (int) – The number of values high

  • value_count (int) – The number of possible pixel values.

width: int

Width of the bitmap. (read only)

height: int

Height of the bitmap. (read only)

bits_per_value: int

Bits per Pixel of the bitmap. (read only)

__getitem__(index: Tuple[int, int] | int) int

Returns the value at the given index. The index can either be an x,y tuple or an int equal to y * width + x.

This allows you to:

print(bitmap[0,1])
__setitem__(index: Tuple[int, int] | int, value: int) None

Sets the value at the given index. The index can either be an x,y tuple or an int equal to y * width + x.

This allows you to:

bitmap[0,1] = 3
fill(value: int) None

Fills the bitmap with the supplied palette index value.

dirty(x1: int = 0, y1: int = 0, x2: int = -1, y2: int = -1) None

Inform displayio of bitmap updates done via the buffer protocol.

Parameters:
  • x1 (int) – Minimum x-value for rectangular bounding box to be considered as modified

  • y1 (int) – Minimum y-value for rectangular bounding box to be considered as modified

  • x2 (int) – Maximum x-value (exclusive) for rectangular bounding box to be considered as modified

  • y2 (int) – Maximum y-value (exclusive) for rectangular bounding box to be considered as modified

If x1 or y1 are not specified, they are taken as 0. If x2 or y2 are not specified, or are given as -1, they are taken as the width and height of the image. Thus, calling dirty() with the default arguments treats the whole bitmap as modified.

When a bitmap is modified through the buffer protocol, the display will not be properly updated unless the bitmap is notified of the “dirty rectangle” that encloses all modified pixels.

deinit() None

Release resources allocated by Bitmap.

class displayio.ColorConverter(*, input_colorspace: Colorspace = Colorspace.RGB888, dither: bool = False)

Converts one color format to another.

Create a ColorConverter object to convert color formats.

Parameters:
  • colorspace (Colorspace) – The source colorspace, one of the Colorspace constants

  • dither (bool) – Adds random noise to dither the output image

convert(color: int) int

Converts the given color to RGB565 according to the Colorspace

dither: bool

When True the ColorConverter dithers the output by adding random noise when truncating to display bitdepth

make_transparent(color: int) None

Set the transparent color or index for the ColorConverter. This will raise an Exception if there is already a selected transparent index.

Parameters:

color (int) – The color to be transparent

make_opaque(color: int) None

Make the ColorConverter be opaque and have no transparent pixels.

Parameters:

color (int) – [IGNORED] Use any value

class displayio.Group(*, scale: int = 1, x: int = 0, y: int = 0)

Manage a group of sprites and groups and how they are inter-related.

Create a Group of a given size and scale. Scale is in one dimension. For example, scale=2 leads to a layer’s pixel being 2x2 pixels when in the group.

Parameters:
  • scale (int) – Scale of layer pixels in one dimension.

  • x (int) – Initial x position within the parent.

  • y (int) – Initial y position within the parent.

hidden: bool

True when the Group and all of its layers are not visible. When False, the Group’s layers are visible if they haven’t been hidden.

scale: int

Scales each pixel within the Group in both directions. For example, when scale=2 each pixel will be represented by 2x2 pixels.

x: int

X position of the Group in the parent.

y: int

Y position of the Group in the parent.

append(layer: vectorio.Circle | vectorio.Rectangle | vectorio.Polygon | Group | TileGrid) None

Append a layer to the group. It will be drawn above other layers.

insert(index: int, layer: vectorio.Circle | vectorio.Rectangle | vectorio.Polygon | Group | TileGrid) None

Insert a layer into the group.

index(layer: vectorio.Circle | vectorio.Rectangle | vectorio.Polygon | Group | TileGrid) int

Returns the index of the first copy of layer. Raises ValueError if not found.

pop(i: int = -1) vectorio.Circle | vectorio.Rectangle | vectorio.Polygon | Group | TileGrid

Remove the ith item and return it.

remove(layer: vectorio.Circle | vectorio.Rectangle | vectorio.Polygon | Group | TileGrid) None

Remove the first copy of layer. Raises ValueError if it is not present.

__bool__() bool
__contains__(item: vectorio.Circle | vectorio.Rectangle | vectorio.Polygon | Group | TileGrid) bool
__iter__() Iterator[vectorio.Circle | vectorio.Rectangle | vectorio.Polygon | Group | TileGrid]
__len__() int

Returns the number of layers in a Group

__getitem__(index: int) vectorio.Circle | vectorio.Rectangle | vectorio.Polygon | Group | TileGrid

Returns the value at the given index.

This allows you to:

print(group[0])
__setitem__(index: int, value: vectorio.Circle | vectorio.Rectangle | vectorio.Polygon | Group | TileGrid) None

Sets the value at the given index.

This allows you to:

group[0] = sprite
__delitem__(index: int) None

Deletes the value at the given index.

This allows you to:

del group[0]
sort(key: function, reverse: bool) None

Sort the members of the group.

class displayio.OnDiskBitmap(file: str | BinaryIO)

Loads values straight from disk. This minimizes memory use but can lead to much slower pixel load times. These load times may result in frame tearing where only part of the image is visible.

It’s easiest to use on a board with a built in display such as the Hallowing M0 Express.

import board
import displayio
import time
import pulseio

board.DISPLAY.brightness = 0
splash = displayio.Group()
board.DISPLAY.root_group = splash

odb = displayio.OnDiskBitmap('/sample.bmp')
face = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader)
splash.append(face)
# Wait for the image to load.
board.DISPLAY.refresh(target_frames_per_second=60)

# Fade up the backlight
for i in range(100):
    board.DISPLAY.brightness = 0.01 * i
    time.sleep(0.05)

# Wait forever
while True:
    pass

Create an OnDiskBitmap object with the given file.

Parameters:

file (file) – The name of the bitmap file. For backwards compatibility, a file opened in binary mode may also be passed.

Older versions of CircuitPython required a file opened in binary mode. CircuitPython 7.0 modified OnDiskBitmap so that it takes a filename instead, and opens the file internally. A future version of CircuitPython will remove the ability to pass in an opened file.

width: int

Width of the bitmap. (read only)

height: int

Height of the bitmap. (read only)

pixel_shader: ColorConverter | Palette

The image’s pixel_shader. The type depends on the underlying bitmap’s structure. The pixel shader can be modified (e.g., to set the transparent pixel or, for palette shaded images, to update the palette.)

class displayio.Palette(color_count: int, *, dither: bool = False)

Map a pixel palette_index to a full color. Colors are transformed to the display’s format internally to save memory.

Create a Palette object to store a set number of colors.

Parameters:
  • color_count (int) – The number of colors in the Palette

  • dither (bool) – When true, dither the RGB color before converting to the display’s color space

dither: bool

When True the Palette dithers the output color by adding random noise when truncating to display bitdepth

__bool__() bool
__len__() int

Returns the number of colors in a Palette

__getitem__(index: int) int | None

Return the pixel color at the given index as an integer.

__setitem__(index: int, value: int | circuitpython_typing.ReadableBuffer | Tuple[int, int, int]) None

Sets the pixel color at the given index. The index should be an integer in the range 0 to color_count-1.

The value argument represents a color, and can be from 0x000000 to 0xFFFFFF (to represent an RGB value). Value can be an int, bytes (3 bytes (RGB) or 4 bytes (RGB + pad byte)), bytearray, or a tuple or list of 3 integers.

This allows you to:

palette[0] = 0xFFFFFF                     # set using an integer
palette[1] = b'\xff\xff\x00'              # set using 3 bytes
palette[2] = b'\xff\xff\x00\x00'          # set using 4 bytes
palette[3] = bytearray(b'\x00\x00\xFF')   # set using a bytearay of 3 or 4 bytes
palette[4] = (10, 20, 30)                 # set using a tuple of 3 integers
make_transparent(palette_index: int) None
make_opaque(palette_index: int) None
is_transparent(palette_index: int) bool

Returns True if the palette index is transparent. Returns False if opaque.

class displayio.TileGrid(bitmap: Bitmap | OnDiskBitmap, *, pixel_shader: ColorConverter | Palette, width: int = 1, height: int = 1, tile_width: int | None = None, tile_height: int | None = None, default_tile: int = 0, x: int = 0, y: int = 0)

A grid of tiles sourced out of one bitmap

Position a grid of tiles sourced from a bitmap and pixel_shader combination. Multiple grids can share bitmaps and pixel shaders.

A single tile grid is also known as a Sprite.

Create a TileGrid object. The bitmap is source for 2d pixels. The pixel_shader is used to convert the value and its location to a display native pixel color. This may be a simple color palette lookup, a gradient, a pattern or a color transformer.

To save RAM usage, tile values are only allowed in the range from 0 to 255 inclusive (single byte values).

tile_width and tile_height match the height of the bitmap by default.

Parameters:
  • bitmap (Bitmap,OnDiskBitmap) – The bitmap storing one or more tiles.

  • pixel_shader (ColorConverter,Palette) – The pixel shader that produces colors from values

  • width (int) – Width of the grid in tiles.

  • height (int) – Height of the grid in tiles.

  • tile_width (int) – Width of a single tile in pixels. Defaults to the full Bitmap and must evenly divide into the Bitmap’s dimensions.

  • tile_height (int) – Height of a single tile in pixels. Defaults to the full Bitmap and must evenly divide into the Bitmap’s dimensions.

  • default_tile (int) – Default tile index to show.

  • x (int) – Initial x position of the left edge within the parent.

  • y (int) – Initial y position of the top edge within the parent.

hidden: bool

True when the TileGrid is hidden. This may be False even when a part of a hidden Group.

x: int

X position of the left edge in the parent.

y: int

Y position of the top edge in the parent.

width: int

Width of the tilegrid in tiles.

height: int

Height of the tilegrid in tiles.

tile_width: int

Width of a single tile in pixels.

tile_height: int

Height of a single tile in pixels.

flip_x: bool

If true, the left edge rendered will be the right edge of the right-most tile.

flip_y: bool

If true, the top edge rendered will be the bottom edge of the bottom-most tile.

transpose_xy: bool

If true, the TileGrid’s axis will be swapped. When combined with mirroring, any 90 degree rotation can be achieved along with the corresponding mirrored version.

contains(touch_tuple: tuple) bool

Returns True if the first two values in touch_tuple represent an x,y coordinate inside the tilegrid rectangle bounds.

pixel_shader: ColorConverter | Palette

The pixel shader of the tilegrid.

bitmap: Bitmap | OnDiskBitmap

The bitmap of the tilegrid.

__getitem__(index: Tuple[int, int] | int) int

Returns the tile index at the given index. The index can either be an x,y tuple or an int equal to y * width + x.

This allows you to:

print(grid[0])
__setitem__(index: Tuple[int, int] | int, value: int) None

Sets the tile index at the given index. The index can either be an x,y tuple or an int equal to y * width + x.

This allows you to:

grid[0] = 10

or:

grid[0,0] = 10