Skip to content

Commit 107baf3

Browse files
authored
Merge pull request #18 from RetiredWizard/main
Replace depreciated .show() & changes to displayio
2 parents 3cbac14 + 740777a commit 107baf3

File tree

3 files changed

+42
-12
lines changed

3 files changed

+42
-12
lines changed

README.rst

+15-4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ Usage Example
6464
6565
import board
6666
import displayio
67+
# Starting in CircuitPython 9.x fourwire will be a seperate internal library
68+
# rather than a component of the displayio library
69+
try:
70+
from fourwire import FourWire
71+
# Use for I2C
72+
# from i2cdisplaybus import I2CDisplayBus
73+
except ImportError:
74+
from displayio import FourWire
75+
# from displayio import I2CDisplay as I2CDisplayBus
6776
import terminalio
6877
from adafruit_display_text import label
6978
import adafruit_displayio_ssd1305
@@ -74,12 +83,14 @@ Usage Example
7483
spi = board.SPI()
7584
oled_cs = board.D5
7685
oled_dc = board.D6
77-
display_bus = displayio.FourWire(spi, command=oled_dc, chip_select=oled_cs,
78-
baudrate=1000000, reset=board.D9)
86+
display_bus = FourWire(
87+
spi, command=oled_dc, chip_select=oled_cs, baudrate=1000000, reset=board.D9
88+
)
7989
8090
# Use for I2C
8191
# i2c = board.I2C()
82-
# display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)
92+
#
93+
# display_bus = I2CDisplayBus(i1c, device_address=0x3c)
8394
8495
WIDTH = 128
8596
HEIGHT = 64 # Change to 32 if needed
@@ -90,7 +101,7 @@ Usage Example
90101
91102
# Make the display context
92103
splash = displayio.Group()
93-
display.show(splash)
104+
display.root_group = splash
94105
95106
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
96107
color_palette = displayio.Palette(1)

adafruit_displayio_ssd1305.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@
2929

3030
# imports
3131

32-
import displayio
32+
# Starting in CircuitPython 9.x fourwire will be a seperate internal library
33+
# rather than a component of the displayio library
34+
try:
35+
from fourwire import FourWire
36+
from busdisplay import BusDisplay
37+
from i2cdisplaybus import I2CDisplayBus
38+
except ImportError:
39+
from displayio import FourWire
40+
from displayio import Display as BusDisplay
41+
from displayio import I2CDisplay as I2CDisplayBus
3342

3443
try:
3544
from typing import Union
@@ -61,7 +70,7 @@
6170

6271

6372
# pylint: disable=too-few-public-methods
64-
class SSD1305(displayio.Display):
73+
class SSD1305(BusDisplay):
6574
"""
6675
SSD1305 driver
6776
@@ -71,9 +80,7 @@ class SSD1305(displayio.Display):
7180
One of (0, 90, 180, 270)
7281
"""
7382

74-
def __init__(
75-
self, bus: Union[displayio.Fourwire, displayio.I2CDisplay], **kwargs
76-
) -> None:
83+
def __init__(self, bus: Union[FourWire, I2CDisplayBus], **kwargs) -> None:
7784
colstart = 0
7885
# Patch the init sequence for 32 pixel high displays.
7986
init_sequence = bytearray(_INIT_SEQUENCE)

examples/displayio_ssd1305_simpletest.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88

99
import board
1010
import displayio
11+
12+
# Starting in CircuitPython 9.x fourwire will be a seperate internal library
13+
# rather than a component of the displayio library
14+
try:
15+
from fourwire import FourWire
16+
17+
# Use for I2C
18+
# from i2cdisplaybus import I2CDisplayBus
19+
except ImportError:
20+
from displayio import FourWire
21+
22+
# from displayio import I2CDisplay as I2CDisplayBus
1123
import terminalio
1224
from adafruit_display_text import label
1325
import adafruit_displayio_ssd1305
@@ -21,14 +33,14 @@
2133
spi = board.SPI()
2234
oled_cs = board.D5
2335
oled_dc = board.D6
24-
display_bus = displayio.FourWire(
36+
display_bus = FourWire(
2537
spi, command=oled_dc, chip_select=oled_cs, baudrate=1000000, reset=oled_reset
2638
)
2739

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

3345
WIDTH = 128
3446
HEIGHT = 64 # Change to 32 if needed
@@ -39,7 +51,7 @@
3951

4052
# Make the display context
4153
splash = displayio.Group()
42-
display.show(splash)
54+
display.root_group = splash
4355

4456
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
4557
color_palette = displayio.Palette(1)

0 commit comments

Comments
 (0)