From 9f5e3d4ba21720f05568f0eebeaddd77565e441b Mon Sep 17 00:00:00 2001 From: tekktrik Date: Sat, 12 Mar 2022 18:57:07 -0500 Subject: [PATCH] Switch to circuitpython_typing, remove _typing --- _typing.py | 37 ------------------------------------- displayio/_display.py | 8 ++++---- displayio/_displaycore.py | 12 +++++++++--- displayio/_epaperdisplay.py | 12 +++++++----- displayio/_fourwire.py | 15 ++++++++++++--- displayio/_i2cdisplay.py | 11 ++++++++--- displayio/_palette.py | 4 ++-- paralleldisplay.py | 4 ++-- requirements.txt | 3 ++- setup.py | 5 +++-- 10 files changed, 49 insertions(+), 62 deletions(-) delete mode 100644 _typing.py diff --git a/_typing.py b/_typing.py deleted file mode 100644 index 85cb393..0000000 --- a/_typing.py +++ /dev/null @@ -1,37 +0,0 @@ -# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams -# -# SPDX-License-Identifier: MIT - -""" -`_typing` -================================================================================ - -Type aliases for Blinka - -**Software and Dependencies:** - -* Adafruit Blinka: - https://github.com/adafruit/Adafruit_Blinka/releases - -* Author(s): Melissa LeBlanc-Williams - -""" - -from typing import Union - -__version__ = "0.0.0-auto.0" -__repo__ = "https://github.com/adafruit/Adafruit_Blinka_Displayio.git" - - -WriteableBuffer = Union[ - bytearray, - memoryview, - # array.array, - # ulab.numpy.ndarray, - # rgbmatrix.RGBMatrix -] - -ReadableBuffer = Union[ - bytes, - WriteableBuffer, -] diff --git a/displayio/_display.py b/displayio/_display.py index 8038722..8890087 100644 --- a/displayio/_display.py +++ b/displayio/_display.py @@ -26,7 +26,7 @@ import digitalio from PIL import Image import numpy import microcontroller -import _typing +import circuitpython_typing from ._displaycore import _DisplayCore from ._displaybus import _DisplayBus from ._colorconverter import ColorConverter @@ -60,7 +60,7 @@ class Display: def __init__( self, display_bus: _DisplayBus, - init_sequence: _typing.ReadableBuffer, + init_sequence: circuitpython_typing.ReadableBuffer, *, width: int, height: int, @@ -367,8 +367,8 @@ class Display: return struct.pack(self._bounds_encoding, x, y) # pylint: disable=no-member def fill_row( - self, y: int, buffer: _typing.WriteableBuffer - ) -> _typing.WriteableBuffer: + self, y: int, buffer: circuitpython_typing.WriteableBuffer + ) -> circuitpython_typing.WriteableBuffer: """Extract the pixels from a single row""" for x in range(0, self._width): _rgb_565 = self._colorconverter.convert(self._buffer.getpixel((x, y))) diff --git a/displayio/_displaycore.py b/displayio/_displaycore.py index a68f666..afb92c8 100644 --- a/displayio/_displaycore.py +++ b/displayio/_displaycore.py @@ -23,7 +23,7 @@ __repo__ = "https://github.com/adafruit/Adafruit_Blinka_Displayio.git" from typing import Union -import _typing +import circuitpython_typing from paralleldisplay import ParallelBus from ._fourwire import FourWire from ._group import Group @@ -227,7 +227,10 @@ class _DisplayCore: self._current_group._in_group = False def fill_area( - self, area: Area, mask: _typing.WriteableBuffer, buffer: _typing.WriteableBuffer + self, + area: Area, + mask: circuitpython_typing.WriteableBuffer, + buffer: circuitpython_typing.WriteableBuffer, ) -> bool: # pylint: disable=protected-access """Call the current group's fill area function""" @@ -261,7 +264,10 @@ class _DisplayCore: return True def send( - self, data_type: int, chip_select: int, data: _typing.ReadableBuffer + self, + data_type: int, + chip_select: int, + data: circuitpython_typing.ReadableBuffer, ) -> None: """ Send the data to the current bus diff --git a/displayio/_epaperdisplay.py b/displayio/_epaperdisplay.py index 29f8a54..7e17fa9 100644 --- a/displayio/_epaperdisplay.py +++ b/displayio/_epaperdisplay.py @@ -19,7 +19,7 @@ displayio for Blinka from typing import Optional import microcontroller -import _typing +import circuitpython_typing from ._group import Group from ._displaybus import _DisplayBus @@ -42,8 +42,8 @@ class EPaperDisplay: def __init__( self, display_bus: _DisplayBus, - start_sequence: _typing.ReadableBuffer, - stop_sequence: _typing.ReadableBuffer, + start_sequence: circuitpython_typing.ReadableBuffer, + stop_sequence: circuitpython_typing.ReadableBuffer, *, width: int, height: int, @@ -84,8 +84,10 @@ class EPaperDisplay: :param display_bus: The bus that the display is connected to :type _DisplayBus: displayio.FourWire or displayio.ParallelBus - :param ~_typing.ReadableBuffer start_sequence: Byte-packed initialization sequence. - :param ~_typing.ReadableBuffer stop_sequence: Byte-packed initialization sequence. + :param ~circuitpython_typing.ReadableBuffer start_sequence: Byte-packed + initialization sequence. + :param ~circuitpython_typing.ReadableBuffer stop_sequence: Byte-packed + initialization sequence. :param int width: Width in pixels :param int height: Height in pixels :param int ram_width: RAM width in pixels diff --git a/displayio/_fourwire.py b/displayio/_fourwire.py index 0aae5da..3d5fa7e 100644 --- a/displayio/_fourwire.py +++ b/displayio/_fourwire.py @@ -22,7 +22,7 @@ from typing import Optional import digitalio import busio import microcontroller -import _typing +import circuitpython_typing from ._constants import ( CHIP_SELECT_TOGGLE_EVERY_BYTE, CHIP_SELECT_UNTOUCHED, @@ -93,7 +93,11 @@ class FourWire: time.sleep(0.001) def send( - self, command, data: _typing.ReadableBuffer, *, toggle_every_byte: bool = False + self, + command, + data: circuitpython_typing.ReadableBuffer, + *, + toggle_every_byte: bool = False, ) -> None: """ Sends the given command value followed by the full set of data. Display state, @@ -112,7 +116,12 @@ class FourWire: self._send(DISPLAY_DATA, chip_select, data) self._end_transaction() - def _send(self, data_type: int, chip_select: int, data: _typing.ReadableBuffer): + def _send( + self, + data_type: int, + chip_select: int, + data: circuitpython_typing.ReadableBuffer, + ): self._dc.value = data_type == DISPLAY_DATA if chip_select == CHIP_SELECT_TOGGLE_EVERY_BYTE: for byte in data: diff --git a/displayio/_i2cdisplay.py b/displayio/_i2cdisplay.py index 421fd10..958ce1d 100644 --- a/displayio/_i2cdisplay.py +++ b/displayio/_i2cdisplay.py @@ -23,7 +23,7 @@ displayio for Blinka import time import busio import digitalio -import _typing +import circuitpython_typing from ._constants import CHIP_SELECT_UNTOUCHED, DISPLAY_COMMAND __version__ = "0.0.0-auto.0" @@ -76,7 +76,7 @@ class I2CDisplay: while not self._i2c.try_lock(): pass - def send(self, command: int, data: _typing.ReadableBuffer) -> None: + def send(self, command: int, data: circuitpython_typing.ReadableBuffer) -> None: """ Sends the given command value followed by the full set of data. Display state, such as vertical scroll, set via ``send`` may or may not be reset once the code is @@ -86,7 +86,12 @@ class I2CDisplay: self._send(DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, bytes([command] + data)) self._end_transaction() - def _send(self, data_type: int, chip_select: int, data: _typing.ReadableBuffer): + def _send( + self, + data_type: int, + chip_select: int, + data: circuitpython_typing.ReadableBuffer, + ): # pylint: disable=unused-argument if data_type == DISPLAY_COMMAND: n = len(data) diff --git a/displayio/_palette.py b/displayio/_palette.py index 8579bcb..c008c87 100644 --- a/displayio/_palette.py +++ b/displayio/_palette.py @@ -18,7 +18,7 @@ displayio for Blinka """ from typing import Optional, Union, Tuple -import _typing +import circuitpython_typing __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git" @@ -73,7 +73,7 @@ class Palette: def __setitem__( self, index: int, - value: Union[int, _typing.ReadableBuffer, Tuple[int, int, int]], + value: Union[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. diff --git a/paralleldisplay.py b/paralleldisplay.py index b666121..0627418 100644 --- a/paralleldisplay.py +++ b/paralleldisplay.py @@ -18,7 +18,7 @@ paralleldisplay for Blinka """ import microcontroller -import _typing +import circuitpython_typing __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git" @@ -61,7 +61,7 @@ class ParallelBus: """ raise NotImplementedError("ParallelBus reset has not been implemented yet") - def send(self, command: int, data: _typing.ReadableBuffer) -> None: + def send(self, command: int, data: circuitpython_typing.ReadableBuffer) -> None: """Sends the given command value followed by the full set of data. Display state, such as vertical scroll, set via ``send`` may or may not be reset once the code is done. diff --git a/requirements.txt b/requirements.txt index 10356cb..054614e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ # # SPDX-License-Identifier: Unlicense -Adafruit-Blinka +Adafruit-Blinka>=7.0.0 +adafruit-circuitpython-typing pillow numpy diff --git a/setup.py b/setup.py index 64f2711..2d4a233 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,8 @@ setup( author="Adafruit Industries", author_email="circuitpython@adafruit.com", install_requires=[ - "Adafruit-Blinka", + "Adafruit-Blinka>=7.0.0", + "adafruit-circuitpython-typing", "pillow", "numpy", ], @@ -54,6 +55,6 @@ setup( keywords="adafruit blinka circuitpython micropython displayio lcd tft display pitft", # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). - py_modules=["fontio", "terminalio", "paralleldisplay", "_typing"], + py_modules=["fontio", "terminalio", "paralleldisplay"], packages=["displayio"], ) -- 2.49.0