Skip to main content

DisplayIO driver for SSD1305 monochrome displays

Project description

Introduction

Documentation Status Discord Build Status Code Style: Black

DisplayIO driver for SSD1305 monochrome displays

For the framebuf based driver see Adafruit CircuitPython SSD1305.

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-displayio-ssd1305

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-displayio-ssd1305

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-displayio-ssd1305

Usage Example

import board
import displayio
import terminalio
from adafruit_display_text import label
import adafruit_displayio_ssd1305

displayio.release_displays()

# Use for SPI
spi = board.SPI()
oled_cs = board.D5
oled_dc = board.D6
display_bus = displayio.FourWire(spi, command=oled_dc, chip_select=oled_cs,
                                 baudrate=1000000, reset=board.D9)

# Use for I2C
# i2c = board.I2C()
# display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)

WIDTH = 128
HEIGHT = 64     # Change to 32 if needed
BORDER = 8
FONTSCALE = 1

display = adafruit_displayio_ssd1305.SSD1305(display_bus, width=WIDTH, height=HEIGHT)

# Make the display context
splash = displayio.Group()
display.show(splash)

color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0xFFFFFF # White

bg_sprite = displayio.TileGrid(color_bitmap,
                               pixel_shader=color_palette,
                               x=0, y=0)
splash.append(bg_sprite)

# Draw a smaller inner rectangle
inner_bitmap = displayio.Bitmap(display.width - BORDER * 2, display.height - BORDER * 2, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0x000000 # Black
inner_sprite = displayio.TileGrid(inner_bitmap,
                                  pixel_shader=inner_palette,
                                  x=BORDER, y=BORDER)
splash.append(inner_sprite)

# Draw a label
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFFFF)
text_width = text_area.bounding_box[2] * FONTSCALE
text_group = displayio.Group(scale=FONTSCALE, x=display.width // 2 - text_width // 2,
                             y=display.height // 2)
text_group.append(text_area) # Subgroup for text scaling
splash.append(text_group)

while True:
    pass

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file adafruit-circuitpython-displayio-ssd1305-1.3.10.tar.gz.

File metadata

File hashes

Hashes for adafruit-circuitpython-displayio-ssd1305-1.3.10.tar.gz
Algorithm Hash digest
SHA256 33beb7d7fbd438b126debde2792fda2a1a6e854b5753530e091ce21659bf9d2c
MD5 216104ee83d8e792431348d218bf0863
BLAKE2b-256 396f1f957842eae725e3e937d20b53e2d7bc71c0853df93f2f51678093e4ec26

See more details on using hashes here.

File details

Details for the file adafruit_circuitpython_displayio_ssd1305-1.3.10-py3-none-any.whl.

File metadata

File hashes

Hashes for adafruit_circuitpython_displayio_ssd1305-1.3.10-py3-none-any.whl
Algorithm Hash digest
SHA256 61c3e3fce2ec5049240494ce98f93927141081d712da9a3cfe3838f8b8354871
MD5 33aadf0e4ad8fabc9907780ad1a6a0a5
BLAKE2b-256 2f0dd3d2e350699d1b19e89864944f2665a9b14773d7ef3ab6832fcb6d8193b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page