Skip to content

Commit

Permalink
Merge pull request #131 from makermelissa/split-displayio
Browse files Browse the repository at this point in the history
Update to CircuitPython 9.0.0 API
  • Loading branch information
makermelissa authored Mar 20, 2024
2 parents 09889f5 + 91b383d commit 6776bc6
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 237 deletions.
13 changes: 13 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2023 Melissa LeBlanc-Williams, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT

change-template: "- $TITLE #$NUMBER by @$AUTHOR"
template: |
## What's Changed
$CHANGES
To use in CPython, `pip3 install adafruit-blinka-displayio`.
Read the [docs](https://adafruit-blinka-displayio.readthedocs.io/en/latest/)) for info on how to use it.
25 changes: 25 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: 2023 Melissa LeBlanc-Williams, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT

name: Release Drafter

on:
push:
branches:
- main

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42 changes: 16 additions & 26 deletions displayio/_display.py → busdisplay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# SPDX-License-Identifier: MIT

"""
`displayio.display`
`busdisplay`
================================================================================
displayio for Blinka
busdisplay for Blinka
**Software and Dependencies:**
Expand All @@ -22,12 +22,11 @@
import digitalio
import microcontroller
from circuitpython_typing import WriteableBuffer, ReadableBuffer
from ._displaycore import _DisplayCore
from ._displaybus import _DisplayBus
from ._colorconverter import ColorConverter
from ._group import Group, circuitpython_splash
from ._area import Area
from ._constants import (
from displayio._displaycore import _DisplayCore
from displayio._colorconverter import ColorConverter
from displayio._group import Group, circuitpython_splash
from displayio._area import Area
from displayio._constants import (
CHIP_SELECT_TOGGLE_EVERY_BYTE,
CHIP_SELECT_UNTOUCHED,
DISPLAY_COMMAND,
Expand All @@ -37,12 +36,13 @@
NO_COMMAND,
DELAY,
)
from ._displaybus import _DisplayBus

__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git"


class Display:
class BusDisplay:
# pylint: disable=too-many-instance-attributes, too-many-statements
"""This initializes a display and connects it into CircuitPython. Unlike other objects
in CircuitPython, Display objects live until ``displayio.release_displays()`` is called.
Expand Down Expand Up @@ -82,8 +82,8 @@ def __init__(
SH1107_addressing: bool = False,
):
# pylint: disable=too-many-locals,invalid-name, too-many-branches
"""Create a Display object on the given display bus (`displayio.FourWire` or
`paralleldisplay.ParallelBus`).
"""Create a Display object on the given display bus (`fourwire.FourWire` or
`paralleldisplaybus.ParallelBus`).
The ``init_sequence`` is bitpacked to minimize the ram impact. Every command begins
with a command byte followed by a byte to determine the parameter count and if a
Expand All @@ -101,7 +101,7 @@ def __init__(
b"\\x11\\x80\\x78" # Exit Sleep then delay 0x78 (120ms)
b"\\x29\\x80\\x78" # Display on then delay 0x78 (120ms)
)
display = displayio.Display(display_bus, init_sequence, width=320, height=240)
display = busdisplay.BusDisplay(display_bus, init_sequence, width=320, height=240)
The first command is 0xE1 with 15 (0x0F) parameters following. The second and third
are 0x11 and 0x29 respectively with delays (0x80) of 120ms (0x78) and no parameters.
Expand Down Expand Up @@ -225,7 +225,7 @@ def __init__(
self.auto_refresh = auto_refresh

def __new__(cls, *args, **kwargs):
from . import ( # pylint: disable=import-outside-toplevel, cyclic-import
from displayio import ( # pylint: disable=import-outside-toplevel, cyclic-import
allocate_display,
)

Expand All @@ -242,19 +242,9 @@ def _send_pixels(self, pixels):
)
self._core.send(DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, pixels)

def show(self, group: Group) -> None:
"""
.. note:: `show()` is deprecated and will be removed when CircuitPython 9.0.0
is released. Use ``.root_group = group`` instead.
Switches to displaying the given group of layers. When group is None, the
default CircuitPython terminal will be shown.
:param Group group: The group to show.
"""
if group is None:
group = circuitpython_splash
self._core.set_root_group(group)
@staticmethod
def show(_group: Group) -> None: # pylint: disable=missing-function-docstring
raise AttributeError(".show(x) removed. Use .root_group = x")

def _set_root_group(self, root_group: Group) -> None:
ok = self._core.set_root_group(root_group)
Expand Down
14 changes: 8 additions & 6 deletions displayio/_displaybus.py → busdisplay/_displaybus.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# SPDX-License-Identifier: MIT

"""
`displayio._displaybus`
`busdisplay._displaybus`
================================================================================
Type aliases for Blinka
DisplayBus Type aliases for Blinka
**Software and Dependencies:**
Expand All @@ -18,11 +18,13 @@
"""

from typing import Union
import paralleldisplay
from ._fourwire import FourWire
from ._i2cdisplay import I2CDisplay
import paralleldisplaybus
import fourwire
import i2cdisplaybus

__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_Blinka_Displayio.git"

_DisplayBus = Union[FourWire, I2CDisplay, paralleldisplay.ParallelBus]
_DisplayBus = Union[
fourwire.FourWire, i2cdisplaybus.I2CDisplayBus, paralleldisplaybus.ParallelBus
]
11 changes: 4 additions & 7 deletions displayio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,16 @@
"""
import threading
from typing import Union
from ._fourwire import FourWire
from ._i2cdisplay import I2CDisplay
from busdisplay import BusDisplay
from busdisplay._displaybus import _DisplayBus
from epaperdisplay import EPaperDisplay
from ._bitmap import Bitmap
from ._colorspace import Colorspace
from ._colorconverter import ColorConverter
from ._display import Display
from ._epaperdisplay import EPaperDisplay
from ._group import Group
from ._ondiskbitmap import OnDiskBitmap
from ._palette import Palette
from ._shape import Shape
from ._tilegrid import TileGrid
from ._displaybus import _DisplayBus
from ._constants import CIRCUITPY_DISPLAY_LIMIT

__version__ = "0.0.0+auto.0"
Expand Down Expand Up @@ -63,7 +60,7 @@ def release_displays() -> None:
display_buses.clear()


def allocate_display(new_display: Union[Display, EPaperDisplay]) -> None:
def allocate_display(new_display: Union[BusDisplay, EPaperDisplay]) -> None:
"""Add a display to the displays pool and return the new display"""
if len(displays) >= CIRCUITPY_DISPLAY_LIMIT:
raise RuntimeError("Too many displays")
Expand Down
10 changes: 5 additions & 5 deletions displayio/_displaycore.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import time
import struct
from circuitpython_typing import WriteableBuffer, ReadableBuffer
from paralleldisplay import ParallelBus
from ._fourwire import FourWire
from paralleldisplaybus import ParallelBus
from fourwire import FourWire
from i2cdisplaybus import I2CDisplayBus
from busdisplay._displaybus import _DisplayBus
from ._group import Group
from ._i2cdisplay import I2CDisplay
from ._structs import ColorspaceStruct, TransformStruct
from ._area import Area
from ._displaybus import _DisplayBus
from ._helpers import bswap16
from ._constants import (
CHIP_SELECT_UNTOUCHED,
Expand Down Expand Up @@ -99,7 +99,7 @@ def __init__(
self.last_refresh = 0

if bus:
if isinstance(bus, (FourWire, I2CDisplay, ParallelBus)):
if isinstance(bus, (FourWire, I2CDisplayBus, ParallelBus)):
self._bus_reset = bus.reset
self._bus_free = bus._free
self._begin_transaction = bus._begin_transaction
Expand Down
5 changes: 1 addition & 4 deletions displayio/_ondiskbitmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class OnDiskBitmap:
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
<https://www.adafruit.com/product/3900>`_.
.. code-block:: Python
import board
Expand All @@ -48,7 +45,7 @@ class OnDiskBitmap:
board.DISPLAY.auto_brightness = False
board.DISPLAY.brightness = 0
splash = displayio.Group()
board.DISPLAY.show(splash)
board.DISPLAY.root_group = splash
odb = displayio.OnDiskBitmap(\'/sample.bmp\')
face = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader)
Expand Down
129 changes: 0 additions & 129 deletions displayio/_shape.py

This file was deleted.

Loading

0 comments on commit 6776bc6

Please sign in to comment.