From c45084914e2f40a670f65b6a8e0e41f66617b7c8 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Thu, 1 Sep 2022 20:16:31 -0400 Subject: [PATCH 01/15] Add .venv to .gitignore Signed-off-by: Alec Delaney <89490472+tekktrik@users.noreply.github.com> --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 544ec4a..db3d538 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ _build # Virtual environment-specific files .env +.venv # MacOS-specific files *.DS_Store From 7aa8e9076d9575d5ae8862edb94ae79b47756b70 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Thu, 19 Jan 2023 23:39:55 -0500 Subject: [PATCH 02/15] Add upload url to release action Signed-off-by: Alec Delaney <89490472+tekktrik@users.noreply.github.com> --- .github/workflows/release_gh.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release_gh.yml b/.github/workflows/release_gh.yml index b8aa8d6..9acec60 100644 --- a/.github/workflows/release_gh.yml +++ b/.github/workflows/release_gh.yml @@ -16,3 +16,4 @@ jobs: uses: adafruit/workflows-circuitpython-libs/release-gh@main with: github-token: ${{ secrets.GITHUB_TOKEN }} + upload-url: ${{ github.event.release.upload_url }} From e163b979041a21c5f3458e552d010d900f773122 Mon Sep 17 00:00:00 2001 From: Sebastien Fauque Date: Tue, 25 Apr 2023 15:12:27 -0600 Subject: [PATCH 03/15] added typing for image, scs, and, reverse_bit num --- adafruit_sharpmemorydisplay.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/adafruit_sharpmemorydisplay.py b/adafruit_sharpmemorydisplay.py index 526095c..e45bbf2 100644 --- a/adafruit_sharpmemorydisplay.py +++ b/adafruit_sharpmemorydisplay.py @@ -33,7 +33,9 @@ from micropython import const try: + from PIL import Image import numpy + from digitalio import DigitalInOut except ImportError: numpy = None @@ -45,7 +47,7 @@ _SHARPMEM_BIT_CLEAR = const(0x20) # in lsb -def reverse_bit(num): +def reverse_bit(num: float): """Turn an LSB byte to an MSB byte, and vice versa. Used for SPI as it is LSB for the SHARP, but 99% of SPI implementations are MSB only!""" result = 0 @@ -62,7 +64,15 @@ class SharpMemoryDisplay(adafruit_framebuf.FrameBuffer): # pylint: disable=too-many-instance-attributes,abstract-method - def __init__(self, spi, scs_pin, width, height, *, baudrate=2000000): + def __init__( + self, + spi: SPIDevice, + scs_pin: DigitalInOut, + width: float, + height: float, + *, + baudrate=2000000 + ): scs_pin.switch_to_output(value=True) self.spi_device = SPIDevice( spi, scs_pin, cs_active_value=True, baudrate=baudrate @@ -105,7 +115,7 @@ def show(self): image_buffer.extend(self._buf) spi.write(image_buffer) - def image(self, img): + def image(self, img: Image): """Set buffer to value of Python Imaging Library image. The image should be in 1 bit mode and a size equal to the display size.""" # determine our effective width/height, taking rotation into account From 2e2763672a3f28fea7c2192c6ee2a3f89f3f0be7 Mon Sep 17 00:00:00 2001 From: Sebastien Fauque Date: Tue, 25 Apr 2023 16:04:54 -0600 Subject: [PATCH 04/15] added future annotations for the DigitalInOut --- adafruit_sharpmemorydisplay.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_sharpmemorydisplay.py b/adafruit_sharpmemorydisplay.py index e45bbf2..6468ea5 100644 --- a/adafruit_sharpmemorydisplay.py +++ b/adafruit_sharpmemorydisplay.py @@ -27,6 +27,7 @@ """ # pylint: enable=line-too-long +from __future__ import annotations import adafruit_framebuf from adafruit_bus_device.spi_device import SPIDevice @@ -71,7 +72,7 @@ def __init__( width: float, height: float, *, - baudrate=2000000 + baudrate=2000000, ): scs_pin.switch_to_output(value=True) self.spi_device = SPIDevice( From 9cd001b338c27ef2ee004c155ad00365aaa10f20 Mon Sep 17 00:00:00 2001 From: Sebastien Fauque Date: Wed, 26 Apr 2023 22:27:12 -0700 Subject: [PATCH 05/15] Added stubbed out type versions, fixed num types, added None return types. --- adafruit_sharpmemorydisplay.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/adafruit_sharpmemorydisplay.py b/adafruit_sharpmemorydisplay.py index 6468ea5..609df0e 100644 --- a/adafruit_sharpmemorydisplay.py +++ b/adafruit_sharpmemorydisplay.py @@ -27,16 +27,22 @@ """ # pylint: enable=line-too-long -from __future__ import annotations + + +try: + from __future__ import annotations + from busio import SPI + from digitalio import DigitalInOut + from circuitpython_typing.pil import Image +except ImportError: + pass import adafruit_framebuf from adafruit_bus_device.spi_device import SPIDevice from micropython import const try: - from PIL import Image import numpy - from digitalio import DigitalInOut except ImportError: numpy = None @@ -48,7 +54,7 @@ _SHARPMEM_BIT_CLEAR = const(0x20) # in lsb -def reverse_bit(num: float): +def reverse_bit(num: int) -> int: """Turn an LSB byte to an MSB byte, and vice versa. Used for SPI as it is LSB for the SHARP, but 99% of SPI implementations are MSB only!""" result = 0 @@ -67,10 +73,10 @@ class SharpMemoryDisplay(adafruit_framebuf.FrameBuffer): def __init__( self, - spi: SPIDevice, + spi: SPI, scs_pin: DigitalInOut, - width: float, - height: float, + width: int, + height: int, *, baudrate=2000000, ): @@ -89,7 +95,7 @@ def __init__( # Set the vcom bit to a defined state self._vcom = True - def show(self): + def show(self) -> None: """write out the frame buffer via SPI, we use MSB SPI only so some bit-swapping is required. """ @@ -116,7 +122,7 @@ def show(self): image_buffer.extend(self._buf) spi.write(image_buffer) - def image(self, img: Image): + def image(self, img: Image) -> None: """Set buffer to value of Python Imaging Library image. The image should be in 1 bit mode and a size equal to the display size.""" # determine our effective width/height, taking rotation into account From bf3a570b2722bd41e18c3973ea4f4171e51ffa4c Mon Sep 17 00:00:00 2001 From: Sebastien Fauque Date: Wed, 26 Apr 2023 22:33:25 -0700 Subject: [PATCH 06/15] Moving __future__ due to failed CI. --- adafruit_sharpmemorydisplay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_sharpmemorydisplay.py b/adafruit_sharpmemorydisplay.py index 609df0e..27ecbfa 100644 --- a/adafruit_sharpmemorydisplay.py +++ b/adafruit_sharpmemorydisplay.py @@ -27,10 +27,10 @@ """ # pylint: enable=line-too-long +from __future__ import annotations try: - from __future__ import annotations from busio import SPI from digitalio import DigitalInOut from circuitpython_typing.pil import Image From 0b5469bba911990f90339ecbc3d0fddf29c0f734 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Thu, 27 Apr 2023 19:08:49 -0500 Subject: [PATCH 07/15] add typing import --- adafruit_sharpmemorydisplay.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adafruit_sharpmemorydisplay.py b/adafruit_sharpmemorydisplay.py index 27ecbfa..d73eb7e 100644 --- a/adafruit_sharpmemorydisplay.py +++ b/adafruit_sharpmemorydisplay.py @@ -31,6 +31,8 @@ try: + # pylint: disable=unused-import + import typing from busio import SPI from digitalio import DigitalInOut from circuitpython_typing.pil import Image From 7000b152cab32913e5bb95a1c0186b25b1a66c6f Mon Sep 17 00:00:00 2001 From: Tekktrik Date: Tue, 9 May 2023 20:26:25 -0400 Subject: [PATCH 08/15] Update pre-commit hooks Signed-off-by: Tekktrik --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e5fccc..70ade69 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,21 +4,21 @@ repos: - repo: https://github.com/python/black - rev: 22.3.0 + rev: 23.3.0 hooks: - id: black - repo: https://github.com/fsfe/reuse-tool - rev: v0.14.0 + rev: v1.1.2 hooks: - id: reuse - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.4.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/pycqa/pylint - rev: v2.15.5 + rev: v2.17.4 hooks: - id: pylint name: pylint (library code) From 8fd70d4284a676d4d42d414b837553772e6e5307 Mon Sep 17 00:00:00 2001 From: Tekktrik Date: Wed, 10 May 2023 22:43:39 -0400 Subject: [PATCH 09/15] Run pre-commit --- adafruit_sharpmemorydisplay.py | 1 - 1 file changed, 1 deletion(-) diff --git a/adafruit_sharpmemorydisplay.py b/adafruit_sharpmemorydisplay.py index d73eb7e..2875f71 100644 --- a/adafruit_sharpmemorydisplay.py +++ b/adafruit_sharpmemorydisplay.py @@ -103,7 +103,6 @@ def show(self) -> None: """ with self.spi_device as spi: - image_buffer = bytearray() # toggle the VCOM bit self._buf[0] = _SHARPMEM_BIT_WRITECMD From 39b83e04ef5daf5951de77d571151ba8e5af4358 Mon Sep 17 00:00:00 2001 From: Tekktrik Date: Sun, 14 May 2023 13:00:32 -0400 Subject: [PATCH 10/15] Update .pylintrc, fix jQuery for docs Signed-off-by: Tekktrik --- .pylintrc | 2 +- docs/conf.py | 1 + docs/requirements.txt | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 40208c3..f945e92 100644 --- a/.pylintrc +++ b/.pylintrc @@ -396,4 +396,4 @@ min-public-methods=1 # Exceptions that will emit a warning when being caught. Defaults to # "Exception" -overgeneral-exceptions=Exception +overgeneral-exceptions=builtins.Exception diff --git a/docs/conf.py b/docs/conf.py index 8093484..b6a34fc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,6 +17,7 @@ # ones. extensions = [ "sphinx.ext.autodoc", + "sphinxcontrib.jquery", "sphinx.ext.intersphinx", "sphinx.ext.napoleon", "sphinx.ext.todo", diff --git a/docs/requirements.txt b/docs/requirements.txt index 88e6733..797aa04 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -3,3 +3,4 @@ # SPDX-License-Identifier: Unlicense sphinx>=4.0.0 +sphinxcontrib-jquery From ae0f74d1b5c36a39ad71a2a4b01914cdca196ab5 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 18 Sep 2023 16:21:26 -0500 Subject: [PATCH 11/15] "fix rtd theme " --- docs/conf.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b6a34fc..8e184f4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -101,19 +101,10 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -on_rtd = os.environ.get("READTHEDOCS", None) == "True" - -if not on_rtd: # only import and set the theme if we're building docs locally - try: - import sphinx_rtd_theme - - html_theme = "sphinx_rtd_theme" - html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] - except: - html_theme = "default" - html_theme_path = ["."] -else: - html_theme_path = ["."] +import sphinx_rtd_theme + +html_theme = "sphinx_rtd_theme" +html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, From 404a6f5d5d59c8a1ab11d4dd8c3b91c187a0b2e8 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Oct 2023 14:30:31 -0500 Subject: [PATCH 12/15] unpin sphinx and add sphinx-rtd-theme to docs reqs Signed-off-by: foamyguy --- docs/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 797aa04..979f568 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,5 +2,6 @@ # # SPDX-License-Identifier: Unlicense -sphinx>=4.0.0 +sphinx sphinxcontrib-jquery +sphinx-rtd-theme From dda5d65d8edc270537174a38c3b8fb3a3b4a4ac6 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 26 Mar 2024 10:50:34 -0700 Subject: [PATCH 13/15] Update Pillow Demo forlatest version --- examples/sharpmemorydisplay_pillow_demo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/sharpmemorydisplay_pillow_demo.py b/examples/sharpmemorydisplay_pillow_demo.py index edc007e..4201580 100644 --- a/examples/sharpmemorydisplay_pillow_demo.py +++ b/examples/sharpmemorydisplay_pillow_demo.py @@ -28,6 +28,7 @@ scs = digitalio.DigitalInOut(board.D6) # inverted chip select # display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96) +# display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 400, 240) display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 144, 168) # Clear display. @@ -56,7 +57,8 @@ # Draw Some Text text = "Hello World!" -(font_width, font_height) = font.getsize(text) +bbox = font.getbbox(text) +(font_width, font_height) = bbox[2] - bbox[0], bbox[3] - bbox[1] draw.text( (display.width // 2 - font_width // 2, display.height // 2 - font_height // 2), text, From f85e1658973872fcc8f5d13192e703a3b5c907e4 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 7 Oct 2024 09:24:05 -0500 Subject: [PATCH 14/15] remove deprecated get_html_theme_path() call Signed-off-by: foamyguy --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 8e184f4..bc1ce7e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -104,7 +104,6 @@ import sphinx_rtd_theme html_theme = "sphinx_rtd_theme" -html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, From cd021269456044a2bb4d9e8068d4114afc6bc859 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 14 Jan 2025 11:32:34 -0600 Subject: [PATCH 15/15] add sphinx configuration to rtd.yaml Signed-off-by: foamyguy --- .readthedocs.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 33c2a61..88bca9f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,6 +8,9 @@ # Required version: 2 +sphinx: + configuration: docs/conf.py + build: os: ubuntu-20.04 tools: