Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace depreciated .show() & changes to displayio #18

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 15 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ Usage Example

import board
import displayio
# Starting in CircuitPython 9.x fourwire will be a seperate internal library
# rather than a component of the displayio library
try:
from fourwire import FourWire
# Use for I2C
# from i2cdisplaybus import I2CDisplayBus
except ImportError:
from displayio import FourWire
# from displayio import I2CDisplay as I2CDisplayBus
import terminalio
from adafruit_display_text import label
import adafruit_displayio_ssd1305
Expand All @@ -74,12 +83,14 @@ Usage Example
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)
display_bus = 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)
#
# display_bus = I2CDisplayBus(i1c, device_address=0x3c)

WIDTH = 128
HEIGHT = 64 # Change to 32 if needed
Expand All @@ -90,7 +101,7 @@ Usage Example

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

color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
Expand Down
17 changes: 12 additions & 5 deletions adafruit_displayio_ssd1305.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@

# imports

import displayio
# Starting in CircuitPython 9.x fourwire will be a seperate internal library
# rather than a component of the displayio library
try:
from fourwire import FourWire
from busdisplay import BusDisplay
from i2cdisplaybus import I2CDisplayBus
except ImportError:
from displayio import FourWire
from displayio import Display as BusDisplay
from displayio import I2CDisplay as I2CDisplayBus

try:
from typing import Union
Expand Down Expand Up @@ -61,7 +70,7 @@


# pylint: disable=too-few-public-methods
class SSD1305(displayio.Display):
class SSD1305(BusDisplay):
"""
SSD1305 driver

Expand All @@ -71,9 +80,7 @@ class SSD1305(displayio.Display):
One of (0, 90, 180, 270)
"""

def __init__(
self, bus: Union[displayio.Fourwire, displayio.I2CDisplay], **kwargs
) -> None:
def __init__(self, bus: Union[FourWire, I2CDisplayBus], **kwargs) -> None:
colstart = 0
# Patch the init sequence for 32 pixel high displays.
init_sequence = bytearray(_INIT_SEQUENCE)
Expand Down
18 changes: 15 additions & 3 deletions examples/displayio_ssd1305_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@

import board
import displayio

# Starting in CircuitPython 9.x fourwire will be a seperate internal library
# rather than a component of the displayio library
try:
from fourwire import FourWire

# Use for I2C
# from i2cdisplaybus import I2CDisplayBus
except ImportError:
from displayio import FourWire

# from displayio import I2CDisplay as I2CDisplayBus
import terminalio
from adafruit_display_text import label
import adafruit_displayio_ssd1305
Expand All @@ -21,14 +33,14 @@
spi = board.SPI()
oled_cs = board.D5
oled_dc = board.D6
display_bus = displayio.FourWire(
display_bus = FourWire(
spi, command=oled_dc, chip_select=oled_cs, baudrate=1000000, reset=oled_reset
)

# Use for I2C
# i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
# display_bus = displayio.I2CDisplay(i2c, device_address=0x3c, reset=oled_reset)
# display_bus = I2CDisplayBus(i2c, device_address=0x3c, reset=oled_reset)

WIDTH = 128
HEIGHT = 64 # Change to 32 if needed
Expand All @@ -39,7 +51,7 @@

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

color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
Expand Down