From 6cd328c5a3bfe4c6df89d04fcc68623b116aa02d Mon Sep 17 00:00:00 2001 From: dherrada Date: Wed, 3 Feb 2021 16:38:51 -0500 Subject: [PATCH 01/83] Hardcoded Black and REUSE versions Signed-off-by: dherrada --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aab5f1c..07f886c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,11 +4,11 @@ repos: - repo: https://github.com/python/black - rev: stable + rev: 20.8b1 hooks: - id: black - repo: https://github.com/fsfe/reuse-tool - rev: latest + rev: v0.12.1 hooks: - id: reuse - repo: https://github.com/pre-commit/pre-commit-hooks From 28bbc74d8fd295cc7d890520ff55e9cc0a2063fc Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 23 Feb 2021 13:50:57 -0800 Subject: [PATCH 02/83] Fix pylint failing --- .pylintrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pylintrc b/.pylintrc index 5c31f66..256ac2f 100644 --- a/.pylintrc +++ b/.pylintrc @@ -22,8 +22,8 @@ ignore-patterns= #init-hook= # Use multiple processes to speed up Pylint. -# jobs=1 -jobs=2 +jobs=1 +# jobs=2 # List of plugins (as comma separated values of python modules names) to load, # usually to register additional checkers. @@ -253,7 +253,7 @@ ignore-docstrings=yes ignore-imports=no # Minimum lines number of a similarity. -min-similarity-lines=4 +min-similarity-lines=50 [BASIC] From a6b1843baad66ade869a1d8eb6842fc5a1bbcc5e Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 23 Feb 2021 13:59:17 -0800 Subject: [PATCH 03/83] Disable new generator check in example --- examples/rgb_display_pillow_bonnet_buttons.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/rgb_display_pillow_bonnet_buttons.py b/examples/rgb_display_pillow_bonnet_buttons.py index b6f1913..eed6ba5 100644 --- a/examples/rgb_display_pillow_bonnet_buttons.py +++ b/examples/rgb_display_pillow_bonnet_buttons.py @@ -156,6 +156,7 @@ draw.ellipse((190, 40, 230, 80), outline=button_outline, fill=B_fill) # B button # make a random color and print text + # pylint: disable=consider-using-generator rcolor = tuple([int(x * 255) for x in hsv_to_rgb(random.random(), 1, 1)]) draw.text((20, 150), "Hello World", font=fnt, fill=rcolor) rcolor = tuple([int(x * 255) for x in hsv_to_rgb(random.random(), 1, 1)]) From 1654795ff06b520b0752619eca4d1e12ab761fdc Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 23 Feb 2021 14:05:00 -0800 Subject: [PATCH 04/83] Use generator instead of disabling message --- examples/rgb_display_pillow_bonnet_buttons.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/rgb_display_pillow_bonnet_buttons.py b/examples/rgb_display_pillow_bonnet_buttons.py index eed6ba5..4c2cdc0 100644 --- a/examples/rgb_display_pillow_bonnet_buttons.py +++ b/examples/rgb_display_pillow_bonnet_buttons.py @@ -156,12 +156,11 @@ draw.ellipse((190, 40, 230, 80), outline=button_outline, fill=B_fill) # B button # make a random color and print text - # pylint: disable=consider-using-generator - rcolor = tuple([int(x * 255) for x in hsv_to_rgb(random.random(), 1, 1)]) + rcolor = tuple(int(x * 255) for x in hsv_to_rgb(random.random(), 1, 1)) draw.text((20, 150), "Hello World", font=fnt, fill=rcolor) - rcolor = tuple([int(x * 255) for x in hsv_to_rgb(random.random(), 1, 1)]) + rcolor = tuple(int(x * 255) for x in hsv_to_rgb(random.random(), 1, 1)) draw.text((20, 180), "Hello World", font=fnt, fill=rcolor) - rcolor = tuple([int(x * 255) for x in hsv_to_rgb(random.random(), 1, 1)]) + rcolor = tuple(int(x * 255) for x in hsv_to_rgb(random.random(), 1, 1)) draw.text((20, 210), "Hello World", font=fnt, fill=rcolor) # Display the Image From 8261d34539b578094e28eecbb58c5b69542edf33 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 2 Mar 2021 19:37:56 -0600 Subject: [PATCH 05/83] pylint to precommit --- .github/workflows/build.yml | 4 ---- .pre-commit-config.yaml | 15 +++++++++++++++ .pylintrc | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59baa53..3baf502 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,10 +50,6 @@ jobs: - name: Pre-commit hooks run: | pre-commit run --all-files - - name: PyLint - run: | - pylint $( find . -path './adafruit*.py' ) - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*.py" )) - name: Build assets run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location . - name: Archive bundles diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 07f886c..354c761 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,3 +17,18 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace +- repo: https://github.com/pycqa/pylint + rev: pylint-2.7.1 + hooks: + - id: pylint + name: pylint (library code) + types: [python] + exclude: "^(docs/|examples/|setup.py$)" +- repo: local + hooks: + - id: pylint_examples + name: pylint (examples code) + description: Run pylint rules on "examples/*.py" files + entry: /usr/bin/env bash -c + args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)'] + language: system diff --git a/.pylintrc b/.pylintrc index 256ac2f..d5f9279 100644 --- a/.pylintrc +++ b/.pylintrc @@ -250,7 +250,7 @@ ignore-comments=yes ignore-docstrings=yes # Ignore imports when computing similarities. -ignore-imports=no +ignore-imports=yes # Minimum lines number of a similarity. min-similarity-lines=50 From a36926481e4029f60bda33704af2f351e4d02964 Mon Sep 17 00:00:00 2001 From: Micha <2231puppy@gmail.com> Date: Wed, 5 May 2021 20:39:31 -0400 Subject: [PATCH 06/83] Update rgb.py --- adafruit_rgb_display/rgb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index caf9b65..4a5ab2c 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -188,7 +188,7 @@ def image(self, img, rotation=None, x=0, y=0): ) ) if numpy: - pixels = list(image_to_data(img)) + pixels = bytes(image_to_data(img)) else: # Slower but doesn't require numpy pixels = bytearray(imwidth * imheight * 2) From c035724631127135b23cd4c584b8655086244d05 Mon Sep 17 00:00:00 2001 From: dherrada Date: Wed, 19 May 2021 13:32:42 -0400 Subject: [PATCH 07/83] Added pull request template Signed-off-by: dherrada --- .../adafruit_circuitpython_pr.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md diff --git a/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md b/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md new file mode 100644 index 0000000..71ef8f8 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: 2021 Adafruit Industries +# +# SPDX-License-Identifier: MIT + +Thank you for contributing! Before you submit a pull request, please read the following. + +Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://circuitpython.readthedocs.io/en/latest/docs/design_guide.html + +If your changes are to documentation, please verify that the documentation builds locally by following the steps found here: https://adafru.it/build-docs + +Before submitting the pull request, make sure you've run Pylint and Black locally on your code. You can do this manually or using pre-commit. Instructions are available here: https://adafru.it/check-your-code + +Please remove all of this text before submitting. Include an explanation or list of changes included in your PR, as well as, if applicable, a link to any related issues. From c988877c09bdb5431045db1725eb78021818f390 Mon Sep 17 00:00:00 2001 From: dherrada Date: Wed, 19 May 2021 13:35:18 -0400 Subject: [PATCH 08/83] Added help text and problem matcher Signed-off-by: dherrada --- .github/workflows/build.yml | 2 ++ .github/workflows/failure-help-text.yml | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 .github/workflows/failure-help-text.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3baf502..0ab7182 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,3 +71,5 @@ jobs: python setup.py sdist python setup.py bdist_wheel --universal twine check dist/* + - name: Setup problem matchers + uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1 diff --git a/.github/workflows/failure-help-text.yml b/.github/workflows/failure-help-text.yml new file mode 100644 index 0000000..0b1194f --- /dev/null +++ b/.github/workflows/failure-help-text.yml @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2021 Scott Shawcroft for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +name: Failure help text + +on: + workflow_run: + workflows: ["Build CI"] + types: + - completed + +jobs: + post-help: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'pull_request' }} + steps: + - name: Post comment to help + uses: adafruit/circuitpython-action-library-ci-failed@v1 From 8cc8413a72f99d53a66d271456befbfd402d2b66 Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 24 May 2021 09:54:31 -0400 Subject: [PATCH 09/83] Moved CI to Python 3.7 Signed-off-by: dherrada --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0ab7182..c4c975d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,10 +22,10 @@ jobs: awk -F '\/' '{ print tolower($2) }' | tr '_' '-' ) - - name: Set up Python 3.6 + - name: Set up Python 3.7 uses: actions/setup-python@v1 with: - python-version: 3.6 + python-version: 3.7 - name: Versions run: | python3 --version From 1ffa1f9021cef0872a5b78689528b5db8240db74 Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 7 Jun 2021 11:50:50 -0400 Subject: [PATCH 10/83] Moved default branch to main --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 2b1f223..c820c00 100644 --- a/README.rst +++ b/README.rst @@ -159,7 +159,7 @@ Contributing ============ Contributions are welcome! Please read our `Code of Conduct -`_ +`_ before contributing to help this project stay welcoming. Documentation From 362c6f70f9020780a1be194ab6734223e07d0774 Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 23 Sep 2021 17:52:55 -0400 Subject: [PATCH 11/83] Globally disabled consider-using-f-string pylint check Signed-off-by: dherrada --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 354c761..8810708 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,5 +30,5 @@ repos: name: pylint (examples code) description: Run pylint rules on "examples/*.py" files entry: /usr/bin/env bash -c - args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)'] + args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name,consider-using-f-string $example; done)'] language: system From 9a4e6b8388206fb720d7c250475c786dee97216e Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 27 Sep 2021 15:42:19 -0400 Subject: [PATCH 12/83] Linted --- examples/rgb_display_hx8357test.py | 2 +- examples/rgb_display_ili9341test.py | 2 +- examples/rgb_display_pillow_animated_gif.py | 12 ++++++------ examples/rgb_display_pillow_bonnet_buttons.py | 2 +- examples/rgb_display_simpletest.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/rgb_display_hx8357test.py b/examples/rgb_display_hx8357test.py index 2004252..83036c8 100644 --- a/examples/rgb_display_hx8357test.py +++ b/examples/rgb_display_hx8357test.py @@ -10,7 +10,7 @@ import board from adafruit_rgb_display.rgb import color565 -import adafruit_rgb_display.hx8357 as hx8357 +from adafruit_rgb_display import hx8357 # Configuration for CS and DC pins (these are TFT FeatherWing defaults): cs_pin = digitalio.DigitalInOut(board.D9) diff --git a/examples/rgb_display_ili9341test.py b/examples/rgb_display_ili9341test.py index dc23ac0..38ba796 100644 --- a/examples/rgb_display_ili9341test.py +++ b/examples/rgb_display_ili9341test.py @@ -11,7 +11,7 @@ import board from adafruit_rgb_display.rgb import color565 -import adafruit_rgb_display.ili9341 as ili9341 +from adafruit_rgb_display import ili9341 # Configuratoin for CS and DC pins (these are FeatherWing defaults on M0/M4): diff --git a/examples/rgb_display_pillow_animated_gif.py b/examples/rgb_display_pillow_animated_gif.py index c014c4e..4ccf419 100644 --- a/examples/rgb_display_pillow_animated_gif.py +++ b/examples/rgb_display_pillow_animated_gif.py @@ -20,12 +20,12 @@ import board from PIL import Image, ImageOps import numpy # pylint: disable=unused-import -import adafruit_rgb_display.ili9341 as ili9341 -import adafruit_rgb_display.st7789 as st7789 # pylint: disable=unused-import -import adafruit_rgb_display.hx8357 as hx8357 # pylint: disable=unused-import -import adafruit_rgb_display.st7735 as st7735 # pylint: disable=unused-import -import adafruit_rgb_display.ssd1351 as ssd1351 # pylint: disable=unused-import -import adafruit_rgb_display.ssd1331 as ssd1331 # pylint: disable=unused-import +from adafruit_rgb_display import ili9341 +from adafruit_rgb_display import st7789 # pylint: disable=unused-import +from adafruit_rgb_display import hx8357 # pylint: disable=unused-import +from adafruit_rgb_display import st7735 # pylint: disable=unused-import +from adafruit_rgb_display import ssd1351 # pylint: disable=unused-import +from adafruit_rgb_display import ssd1331 # pylint: disable=unused-import # Change to match your display BUTTON_NEXT = board.D17 diff --git a/examples/rgb_display_pillow_bonnet_buttons.py b/examples/rgb_display_pillow_bonnet_buttons.py index 4c2cdc0..91bb656 100644 --- a/examples/rgb_display_pillow_bonnet_buttons.py +++ b/examples/rgb_display_pillow_bonnet_buttons.py @@ -38,7 +38,7 @@ import board from digitalio import DigitalInOut, Direction from PIL import Image, ImageDraw, ImageFont -import adafruit_rgb_display.st7789 as st7789 +from adafruit_rgb_display import st7789 # Create the display cs_pin = DigitalInOut(board.CE0) diff --git a/examples/rgb_display_simpletest.py b/examples/rgb_display_simpletest.py index d066019..8f7f7f0 100644 --- a/examples/rgb_display_simpletest.py +++ b/examples/rgb_display_simpletest.py @@ -11,7 +11,7 @@ import board from adafruit_rgb_display.rgb import color565 -import adafruit_rgb_display.st7789 as st7789 +from adafruit_rgb_display import st7789 # Configuratoin for CS and DC pins (these are FeatherWing defaults on M0/M4): cs_pin = digitalio.DigitalInOut(board.D5) From 3939e2a7dbbb2686fb74fe8db461517f03a75b99 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 25 Oct 2021 11:21:26 -0500 Subject: [PATCH 13/83] add docs link to readme --- README.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.rst b/README.rst index c820c00..463d5b2 100644 --- a/README.rst +++ b/README.rst @@ -155,6 +155,11 @@ With 1.14" `wiring `_. + Contributing ============ From 665251de08a196e8252ba3356c5de6b330f355c4 Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 5 Nov 2021 14:49:30 -0400 Subject: [PATCH 14/83] Disabled unspecified-encoding pylint check Signed-off-by: dherrada --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index d5f9279..eee47e3 100644 --- a/.pylintrc +++ b/.pylintrc @@ -56,7 +56,7 @@ confidence= # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" # disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call -disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation +disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation,unspecified-encoding # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option From 4c4a7dce76a2fa6bca63a6bd25117fbfbdd3f012 Mon Sep 17 00:00:00 2001 From: Dylan Herrada <33632497+dherrada@users.noreply.github.com> Date: Mon, 8 Nov 2021 16:26:03 -0500 Subject: [PATCH 15/83] Updated readthedocs requirements path --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index ffa84c4..49dcab3 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -4,4 +4,4 @@ python: version: 3 -requirements_file: requirements.txt +requirements_file: docs/requirements.txt From 0c0b58ebefde35435aad9a60a59fa03a3f61e1fe Mon Sep 17 00:00:00 2001 From: dherrada Date: Tue, 9 Nov 2021 13:31:14 -0500 Subject: [PATCH 16/83] Updated readthedocs file Signed-off-by: dherrada --- .readthedocs.yaml | 15 +++++++++++++++ .readthedocs.yml | 7 ------- 2 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 .readthedocs.yaml delete mode 100644 .readthedocs.yml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..95ec218 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense + +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +python: + version: "3.6" + install: + - requirements: docs/requirements.txt + - requirements: requirements.txt diff --git a/.readthedocs.yml b/.readthedocs.yml deleted file mode 100644 index 49dcab3..0000000 --- a/.readthedocs.yml +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries -# -# SPDX-License-Identifier: Unlicense - -python: - version: 3 -requirements_file: docs/requirements.txt From 82ec6a8ed73cce056e99994ab2052a2bf7c7de72 Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 11 Nov 2021 13:57:25 -0500 Subject: [PATCH 17/83] Pylint and RTD update patch, and other fixes --- .github/workflows/build.yml | 4 ++-- .pre-commit-config.yaml | 26 +++++++++++++++++--------- .pylintrc | 2 +- adafruit_rgb_display/rgb.py | 2 +- adafruit_rgb_display/ssd1351.py | 4 ++-- docs/requirements.txt | 5 +++++ examples/rgb_display_fbcp.py | 2 +- examples/rgb_display_minipitftstats.py | 2 +- examples/rgb_display_minipitfttest.py | 2 +- examples/rgb_display_pillow_demo.py | 12 ++++++------ examples/rgb_display_pillow_image.py | 12 ++++++------ examples/rgb_display_pillow_stats.py | 12 ++++++------ 12 files changed, 49 insertions(+), 36 deletions(-) create mode 100644 docs/requirements.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c4c975d..ca35544 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,9 +42,9 @@ jobs: # (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.) run: | source actions-ci/install.sh - - name: Pip install pylint, Sphinx, pre-commit + - name: Pip install Sphinx, pre-commit run: | - pip install --force-reinstall pylint Sphinx sphinx-rtd-theme pre-commit + pip install --force-reinstall Sphinx sphinx-rtd-theme pre-commit - name: Library version run: git describe --dirty --always --tags - name: Pre-commit hooks diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8810708..43d1385 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,17 +18,25 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/pycqa/pylint - rev: pylint-2.7.1 + rev: v2.11.1 hooks: - id: pylint name: pylint (library code) types: [python] - exclude: "^(docs/|examples/|setup.py$)" -- repo: local - hooks: - - id: pylint_examples - name: pylint (examples code) + args: + - --disable=consider-using-f-string,duplicate-code + exclude: "^(docs/|examples/|tests/|setup.py$)" + - id: pylint + name: pylint (example code) description: Run pylint rules on "examples/*.py" files - entry: /usr/bin/env bash -c - args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name,consider-using-f-string $example; done)'] - language: system + types: [python] + files: "^examples/" + args: + - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code + - id: pylint + name: pylint (test code) + description: Run pylint rules on "tests/*.py" files + types: [python] + files: "^tests/" + args: + - --disable=missing-docstring,consider-using-f-string,duplicate-code diff --git a/.pylintrc b/.pylintrc index eee47e3..8d537b3 100644 --- a/.pylintrc +++ b/.pylintrc @@ -253,7 +253,7 @@ ignore-docstrings=yes ignore-imports=yes # Minimum lines number of a similarity. -min-similarity-lines=50 +min-similarity-lines=12 [BASIC] diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index 4a5ab2c..50e9e63 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -22,7 +22,7 @@ except ImportError: import ustruct as struct -import adafruit_bus_device.spi_device as spi_device +from adafruit_bus_device import spi_device __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" diff --git a/adafruit_rgb_display/ssd1351.py b/adafruit_rgb_display/ssd1351.py index 50f062d..9ae2cb1 100644 --- a/adafruit_rgb_display/ssd1351.py +++ b/adafruit_rgb_display/ssd1351.py @@ -113,8 +113,8 @@ def __init__( y_offset=0, rotation=0 ): - if baudrate > 16000000: # Limit to Display Max Baudrate - baudrate = 16000000 + baudrate = min(baudrate, 16000000) # Limit to Display Max Baudrate + super().__init__( spi, dc, diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..88e6733 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense + +sphinx>=4.0.0 diff --git a/examples/rgb_display_fbcp.py b/examples/rgb_display_fbcp.py index 540ec40..63b210e 100644 --- a/examples/rgb_display_fbcp.py +++ b/examples/rgb_display_fbcp.py @@ -9,7 +9,7 @@ import digitalio import board from PIL import Image, ImageDraw -import adafruit_rgb_display.st7789 as st7789 +from adafruit_rgb_display import st7789 # definitions from linux/fb.h FBIOGET_VSCREENINFO = 0x4600 diff --git a/examples/rgb_display_minipitftstats.py b/examples/rgb_display_minipitftstats.py index a3ad651..1f625ed 100644 --- a/examples/rgb_display_minipitftstats.py +++ b/examples/rgb_display_minipitftstats.py @@ -8,7 +8,7 @@ import digitalio import board from PIL import Image, ImageDraw, ImageFont -import adafruit_rgb_display.st7789 as st7789 +from adafruit_rgb_display import st7789 # Configuration for CS and DC pins (these are FeatherWing defaults on M0/M4): diff --git a/examples/rgb_display_minipitfttest.py b/examples/rgb_display_minipitfttest.py index 32771a9..c418229 100644 --- a/examples/rgb_display_minipitfttest.py +++ b/examples/rgb_display_minipitfttest.py @@ -5,7 +5,7 @@ import board from adafruit_rgb_display.rgb import color565 -import adafruit_rgb_display.st7789 as st7789 +from adafruit_rgb_display import st7789 # Configuration for CS and DC pins for Raspberry Pi cs_pin = digitalio.DigitalInOut(board.CE0) diff --git a/examples/rgb_display_pillow_demo.py b/examples/rgb_display_pillow_demo.py index 1e1ab76..f2ce7cf 100644 --- a/examples/rgb_display_pillow_demo.py +++ b/examples/rgb_display_pillow_demo.py @@ -15,12 +15,12 @@ import digitalio import board from PIL import Image, ImageDraw, ImageFont -import adafruit_rgb_display.ili9341 as ili9341 -import adafruit_rgb_display.st7789 as st7789 # pylint: disable=unused-import -import adafruit_rgb_display.hx8357 as hx8357 # pylint: disable=unused-import -import adafruit_rgb_display.st7735 as st7735 # pylint: disable=unused-import -import adafruit_rgb_display.ssd1351 as ssd1351 # pylint: disable=unused-import -import adafruit_rgb_display.ssd1331 as ssd1331 # pylint: disable=unused-import +from adafruit_rgb_display import ili9341 +from adafruit_rgb_display import st7789 # pylint: disable=unused-import +from adafruit_rgb_display import hx8357 # pylint: disable=unused-import +from adafruit_rgb_display import st7735 # pylint: disable=unused-import +from adafruit_rgb_display import ssd1351 # pylint: disable=unused-import +from adafruit_rgb_display import ssd1331 # pylint: disable=unused-import # First define some constants to allow easy resizing of shapes. BORDER = 20 diff --git a/examples/rgb_display_pillow_image.py b/examples/rgb_display_pillow_image.py index 38eb063..2bfff48 100644 --- a/examples/rgb_display_pillow_image.py +++ b/examples/rgb_display_pillow_image.py @@ -14,12 +14,12 @@ import digitalio import board from PIL import Image, ImageDraw -import adafruit_rgb_display.ili9341 as ili9341 -import adafruit_rgb_display.st7789 as st7789 # pylint: disable=unused-import -import adafruit_rgb_display.hx8357 as hx8357 # pylint: disable=unused-import -import adafruit_rgb_display.st7735 as st7735 # pylint: disable=unused-import -import adafruit_rgb_display.ssd1351 as ssd1351 # pylint: disable=unused-import -import adafruit_rgb_display.ssd1331 as ssd1331 # pylint: disable=unused-import +from adafruit_rgb_display import ili9341 +from adafruit_rgb_display import st7789 # pylint: disable=unused-import +from adafruit_rgb_display import hx8357 # pylint: disable=unused-import +from adafruit_rgb_display import st7735 # pylint: disable=unused-import +from adafruit_rgb_display import ssd1351 # pylint: disable=unused-import +from adafruit_rgb_display import ssd1331 # pylint: disable=unused-import # Configuration for CS and DC pins (these are PiTFT defaults): cs_pin = digitalio.DigitalInOut(board.CE0) diff --git a/examples/rgb_display_pillow_stats.py b/examples/rgb_display_pillow_stats.py index 9ed6db1..e7716c9 100644 --- a/examples/rgb_display_pillow_stats.py +++ b/examples/rgb_display_pillow_stats.py @@ -16,12 +16,12 @@ import digitalio import board from PIL import Image, ImageDraw, ImageFont -import adafruit_rgb_display.ili9341 as ili9341 -import adafruit_rgb_display.st7789 as st7789 # pylint: disable=unused-import -import adafruit_rgb_display.hx8357 as hx8357 # pylint: disable=unused-import -import adafruit_rgb_display.st7735 as st7735 # pylint: disable=unused-import -import adafruit_rgb_display.ssd1351 as ssd1351 # pylint: disable=unused-import -import adafruit_rgb_display.ssd1331 as ssd1331 # pylint: disable=unused-import +from adafruit_rgb_display import ili9341 +from adafruit_rgb_display import st7789 # pylint: disable=unused-import +from adafruit_rgb_display import hx8357 # pylint: disable=unused-import +from adafruit_rgb_display import st7735 # pylint: disable=unused-import +from adafruit_rgb_display import ssd1351 # pylint: disable=unused-import +from adafruit_rgb_display import ssd1331 # pylint: disable=unused-import # Configuration for CS and DC pins (these are PiTFT defaults): cs_pin = digitalio.DigitalInOut(board.CE0) From 4f3637d15654b45151ad2ead4a3c81a9328471d6 Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 12 Nov 2021 14:03:55 -0500 Subject: [PATCH 18/83] Changed min-similarity-lines to 4 --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 8d537b3..61d81fb 100644 --- a/.pylintrc +++ b/.pylintrc @@ -253,7 +253,7 @@ ignore-docstrings=yes ignore-imports=yes # Minimum lines number of a similarity. -min-similarity-lines=12 +min-similarity-lines=4 [BASIC] From a802c9d81e804db4495769547865a68f2c1ff15e Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 23 Nov 2021 13:07:09 -0600 Subject: [PATCH 19/83] update rtd py version --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 95ec218..1335112 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,7 +9,7 @@ version: 2 python: - version: "3.6" + version: "3.7" install: - requirements: docs/requirements.txt - requirements: requirements.txt From 600c443c92d57a648f779b0569357b2f7b9529e3 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 22 Dec 2021 09:59:09 -0500 Subject: [PATCH 20/83] Remove obsolete references to ustruct --- adafruit_rgb_display/ili9341.py | 6 +----- adafruit_rgb_display/rgb.py | 5 +---- adafruit_rgb_display/st7735.py | 5 +---- adafruit_rgb_display/st7789.py | 6 ++---- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/adafruit_rgb_display/ili9341.py b/adafruit_rgb_display/ili9341.py index d2d78aa..b29b3f2 100644 --- a/adafruit_rgb_display/ili9341.py +++ b/adafruit_rgb_display/ili9341.py @@ -10,11 +10,7 @@ * Author(s): Radomir Dopieralski, Michael McWethy """ - -try: - import struct -except ImportError: - import ustruct as struct +import struct from adafruit_rgb_display.rgb import DisplaySPI diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index 50e9e63..8d92fb8 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -11,16 +11,13 @@ * Author(s): Radomir Dopieralski, Michael McWethy """ +import struct import time try: import numpy except ImportError: numpy = None -try: - import struct -except ImportError: - import ustruct as struct from adafruit_bus_device import spi_device diff --git a/adafruit_rgb_display/st7735.py b/adafruit_rgb_display/st7735.py index f3070d5..b1686bb 100644 --- a/adafruit_rgb_display/st7735.py +++ b/adafruit_rgb_display/st7735.py @@ -10,11 +10,8 @@ * Author(s): Radomir Dopieralski, Michael McWethy """ +import struct -try: - import struct -except ImportError: - import ustruct as struct from micropython import const from adafruit_rgb_display.rgb import DisplaySPI diff --git a/adafruit_rgb_display/st7789.py b/adafruit_rgb_display/st7789.py index 8eca18d..05133d1 100644 --- a/adafruit_rgb_display/st7789.py +++ b/adafruit_rgb_display/st7789.py @@ -11,10 +11,8 @@ * Author(s): Melissa LeBlanc-Williams """ -try: - import struct -except ImportError: - import ustruct as struct +import struct + from micropython import const from adafruit_rgb_display.rgb import DisplaySPI From 4ad5e3d83ce09d76ceb70f662d963ba37a741ff9 Mon Sep 17 00:00:00 2001 From: dherrada Date: Thu, 13 Jan 2022 16:27:30 -0500 Subject: [PATCH 21/83] First part of patch Signed-off-by: dherrada --- .../PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md | 2 +- .github/workflows/build.yml | 6 +++--- .github/workflows/release.yml | 8 ++++---- .readthedocs.yaml | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md b/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md index 71ef8f8..8de294e 100644 --- a/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md +++ b/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md @@ -4,7 +4,7 @@ Thank you for contributing! Before you submit a pull request, please read the following. -Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://circuitpython.readthedocs.io/en/latest/docs/design_guide.html +Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://docs.circuitpython.org/en/latest/docs/design_guide.html If your changes are to documentation, please verify that the documentation builds locally by following the steps found here: https://adafru.it/build-docs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca35544..474520d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,10 +22,10 @@ jobs: awk -F '\/' '{ print tolower($2) }' | tr '_' '-' ) - - name: Set up Python 3.7 - uses: actions/setup-python@v1 + - name: Set up Python 3.x + uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: "3.x" - name: Versions run: | python3 --version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6d0015a..a65e5de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,10 +24,10 @@ jobs: awk -F '\/' '{ print tolower($2) }' | tr '_' '-' ) - - name: Set up Python 3.6 - uses: actions/setup-python@v1 + - name: Set up Python 3.x + uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: "3.x" - name: Versions run: | python3 --version @@ -67,7 +67,7 @@ jobs: echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) - name: Set up Python if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: '3.x' - name: Install dependencies diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 1335112..f8b2891 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,7 +9,7 @@ version: 2 python: - version: "3.7" + version: "3.x" install: - requirements: docs/requirements.txt - requirements: requirements.txt From 78965ac356e9785759f25a8cfb14af6161f84d9f Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 24 Jan 2022 16:46:17 -0500 Subject: [PATCH 22/83] Updated docs link, updated python docs link, updated setup.py --- README.rst | 4 ++-- docs/conf.py | 6 +++--- docs/index.rst | 2 +- setup.py | 2 -- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 463d5b2..d771de8 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ Introduction ============ .. image:: https://readthedocs.org/projects/adafruit-circuitpython-rgb_display/badge/?version=latest - :target: https://circuitpython.readthedocs.io/projects/rgb_display/en/latest/ + :target: https://docs.circuitpython.org/projects/rgb_display/en/latest/ :alt: Documentation Status .. image :: https://img.shields.io/discord/327254708534116352.svg @@ -158,7 +158,7 @@ With 1.14" `wiring `_. +API documentation for this library can be found on `Read the Docs `_. Contributing ============ diff --git a/docs/conf.py b/docs/conf.py index c62199c..2034c78 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -26,12 +26,12 @@ # autodoc_mock_imports = ["adafruit_bus_device", "micropython"] intersphinx_mapping = { - "python": ("https://docs.python.org/3.4", None), + "python": ("https://docs.python.org/3", None), "BusDevice": ( - "https://circuitpython.readthedocs.io/projects/busdevice/en/latest/", + "https://docs.circuitpython.org/projects/busdevice/en/latest/", None, ), - "CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None), + "CircuitPython": ("https://docs.circuitpython.org/en/latest/", None), } # Add any paths that contain templates here, relative to this directory. diff --git a/docs/index.rst b/docs/index.rst index 985c9f3..1bc6082 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -36,7 +36,7 @@ Table of Contents :caption: Other Links Download - CircuitPython Reference Documentation + CircuitPython Reference Documentation CircuitPython Support Forum Discord Chat Adafruit Learning System diff --git a/setup.py b/setup.py index 5b57862..ea44357 100644 --- a/setup.py +++ b/setup.py @@ -45,8 +45,6 @@ "Topic :: System :: Hardware", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", ], # What does your project relate to? keywords="adafruit rgb display hx8353 ili9341 s6d02A1 ssd1331 ssd1351 st7735" From 5ed3c9781e26b913b7d147c4030e94b1be65f7ca Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Wed, 9 Feb 2022 13:05:22 -0500 Subject: [PATCH 23/83] Consolidate Documentation sections of README --- README.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index d771de8..e370f6f 100644 --- a/README.rst +++ b/README.rst @@ -160,14 +160,11 @@ Documentation API documentation for this library can be found on `Read the Docs `_. +For information on building library documentation, please check out `this guide `_. + Contributing ============ Contributions are welcome! Please read our `Code of Conduct `_ before contributing to help this project stay welcoming. - -Documentation -============= - -For information on building library documentation, please check out `this guide `_. From 281c014aa87798a829770db888ca47123966db07 Mon Sep 17 00:00:00 2001 From: dherrada Date: Mon, 14 Feb 2022 15:35:02 -0500 Subject: [PATCH 24/83] Fixed readthedocs build Signed-off-by: dherrada --- .readthedocs.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index f8b2891..33c2a61 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,8 +8,12 @@ # Required version: 2 +build: + os: ubuntu-20.04 + tools: + python: "3" + python: - version: "3.x" install: - requirements: docs/requirements.txt - requirements: requirements.txt From 16a044ed3f47c551e44b1ab34bead053db542efd Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 16 Mar 2022 14:08:50 -0700 Subject: [PATCH 25/83] Update Pillow Examples to include 1.47 and 1.9 inch displays --- examples/rgb_display_pillow_animated_gif.py | 2 ++ examples/rgb_display_pillow_demo.py | 2 ++ examples/rgb_display_pillow_image.py | 2 ++ examples/rgb_display_pillow_stats.py | 2 ++ 4 files changed, 8 insertions(+) diff --git a/examples/rgb_display_pillow_animated_gif.py b/examples/rgb_display_pillow_animated_gif.py index 4ccf419..92254ee 100644 --- a/examples/rgb_display_pillow_animated_gif.py +++ b/examples/rgb_display_pillow_animated_gif.py @@ -171,6 +171,8 @@ def run(self): # disp = st7789.ST7789(spi, rotation=90, # 2.0" ST7789 # disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180, # 1.3", 1.54" ST7789 # disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789 +# disp = st7789.ST7789(spi, rotation=90, width=172, height=320, x_offset=34, # 1.47" ST7789 +# disp = st7789.ST7789(spi, rotation=270, width=170, height=320, x_offset=35, # 1.9" ST7789 # disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357 # disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R # disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R diff --git a/examples/rgb_display_pillow_demo.py b/examples/rgb_display_pillow_demo.py index f2ce7cf..d5440bd 100644 --- a/examples/rgb_display_pillow_demo.py +++ b/examples/rgb_display_pillow_demo.py @@ -42,6 +42,8 @@ # disp = st7789.ST7789(spi, rotation=90, # 2.0" ST7789 # disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180, # 1.3", 1.54" ST7789 # disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789 +# disp = st7789.ST7789(spi, rotation=90, width=172, height=320, x_offset=34, # 1.47" ST7789 +# disp = st7789.ST7789(spi, rotation=270, width=170, height=320, x_offset=35, # 1.9" ST7789 # disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357 # disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R # disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R diff --git a/examples/rgb_display_pillow_image.py b/examples/rgb_display_pillow_image.py index 2bfff48..d05dd92 100644 --- a/examples/rgb_display_pillow_image.py +++ b/examples/rgb_display_pillow_image.py @@ -37,6 +37,8 @@ # disp = st7789.ST7789(spi, rotation=90, # 2.0" ST7789 # disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180, # 1.3", 1.54" ST7789 # disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789 +# disp = st7789.ST7789(spi, rotation=90, width=172, height=320, x_offset=34, # 1.47" ST7789 +# disp = st7789.ST7789(spi, rotation=270, width=170, height=320, x_offset=35, # 1.9" ST7789 # disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357 # disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R # disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R diff --git a/examples/rgb_display_pillow_stats.py b/examples/rgb_display_pillow_stats.py index e7716c9..577a5ec 100644 --- a/examples/rgb_display_pillow_stats.py +++ b/examples/rgb_display_pillow_stats.py @@ -39,6 +39,8 @@ # disp = st7789.ST7789(spi, rotation=90, # 2.0" ST7789 # disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180, # 1.3", 1.54" ST7789 # disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789 +# disp = st7789.ST7789(spi, rotation=90, width=172, height=320, x_offset=34, # 1.47" ST7789 +# disp = st7789.ST7789(spi, rotation=270, width=170, height=320, x_offset=35, # 1.9" ST7789 # disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357 # disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R # disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R From 16873ee220133c043f8f51c0d0050db93782d098 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Mon, 28 Mar 2022 15:52:04 -0400 Subject: [PATCH 26/83] Update Black to latest. Signed-off-by: Kattni Rembor --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 43d1385..29230db 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/python/black - rev: 20.8b1 + rev: 22.3.0 hooks: - id: black - repo: https://github.com/fsfe/reuse-tool From f6640555bcc8e579f414f59b3acecf7746a03abe Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 19 Apr 2022 17:19:26 -0400 Subject: [PATCH 27/83] Allow for other paths in rgb_display_pillow_animated_gif.py --- examples/rgb_display_pillow_animated_gif.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/rgb_display_pillow_animated_gif.py b/examples/rgb_display_pillow_animated_gif.py index 92254ee..1d42cec 100644 --- a/examples/rgb_display_pillow_animated_gif.py +++ b/examples/rgb_display_pillow_animated_gif.py @@ -89,6 +89,7 @@ def back(self): def load_files(self, folder): gif_files = [f for f in os.listdir(folder) if f.endswith(".gif")] for gif_file in gif_files: + gif_file = os.path.join(folder, gif_file) image = Image.open(gif_file) # Only add animated Gifs if image.is_animated: From 72a2bb5bebfd326dd9b105264be8de53b5678aa7 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 19 Apr 2022 17:45:16 -0400 Subject: [PATCH 28/83] Fix Pillow resampling change in rgb_display_pillow_animated_gif.py --- examples/rgb_display_pillow_animated_gif.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/rgb_display_pillow_animated_gif.py b/examples/rgb_display_pillow_animated_gif.py index 92254ee..6b872f0 100644 --- a/examples/rgb_display_pillow_animated_gif.py +++ b/examples/rgb_display_pillow_animated_gif.py @@ -13,6 +13,7 @@ not support PIL/pillow (python imaging library)! Author(s): Melissa LeBlanc-Williams for Adafruit Industries + Mike Mallett """ import os import time @@ -122,7 +123,7 @@ def preload(self): frame_object.image = ImageOps.pad( # pylint: disable=no-member image.convert("RGB"), (self._width, self._height), - method=Image.NEAREST, + method=Image.Resampling.NEAREST, color=(0, 0, 0), centering=(0.5, 0.5), ) From eb1495bb6317238ac71391263dba8458411d6f29 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 19 Apr 2022 18:08:33 -0400 Subject: [PATCH 29/83] Update resampling method used in rgb_display_pillow_image.py --- examples/rgb_display_pillow_image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rgb_display_pillow_image.py b/examples/rgb_display_pillow_image.py index d05dd92..f814f35 100644 --- a/examples/rgb_display_pillow_image.py +++ b/examples/rgb_display_pillow_image.py @@ -84,7 +84,7 @@ else: scaled_width = width scaled_height = image.height * width // image.width -image = image.resize((scaled_width, scaled_height), Image.BICUBIC) +image = image.resize((scaled_width, scaled_height), Image..Resampling.BICUBIC) # Crop and center the image x = scaled_width // 2 - width // 2 From d5e12098ea7a2216e2e7032cb342b6e189d17d34 Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 21 Apr 2022 11:16:47 -0400 Subject: [PATCH 30/83] Fix syntax error from last commit --- examples/rgb_display_pillow_image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rgb_display_pillow_image.py b/examples/rgb_display_pillow_image.py index f814f35..04c40cc 100644 --- a/examples/rgb_display_pillow_image.py +++ b/examples/rgb_display_pillow_image.py @@ -84,7 +84,7 @@ else: scaled_width = width scaled_height = image.height * width // image.width -image = image.resize((scaled_width, scaled_height), Image..Resampling.BICUBIC) +image = image.resize((scaled_width, scaled_height), Image.Resampling.BICUBIC) # Crop and center the image x = scaled_width // 2 - width // 2 From 98b829e0491fcd3407c6052113e726052316f228 Mon Sep 17 00:00:00 2001 From: Eva Herrada <33632497+evaherrada@users.noreply.github.com> Date: Thu, 21 Apr 2022 18:54:05 -0400 Subject: [PATCH 31/83] Update .gitignore --- .gitignore | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 597d08d..544ec4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,47 @@ -# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-FileCopyrightText: 2022 Kattni Rembor, written for Adafruit Industries # -# SPDX-License-Identifier: Unlicense +# SPDX-License-Identifier: MIT +# Do not include files and directories created by your personal work environment, such as the IDE +# you use, except for those already listed here. Pull requests including changes to this file will +# not be accepted. + +# This .gitignore file contains rules for files generated by working with CircuitPython libraries, +# including building Sphinx, testing with pip, and creating a virual environment, as well as the +# MacOS and IDE-specific files generated by using MacOS in general, or the PyCharm or VSCode IDEs. + +# If you find that there are files being generated on your machine that should not be included in +# your git commit, you should create a .gitignore_global file on your computer to include the +# files created by your personal setup. To do so, follow the two steps below. + +# First, create a file called .gitignore_global somewhere convenient for you, and add rules for +# the files you want to exclude from git commits. + +# Second, configure Git to use the exclude file for all Git repositories by running the +# following via commandline, replacing "path/to/your/" with the actual path to your newly created +# .gitignore_global file: +# git config --global core.excludesfile path/to/your/.gitignore_global + +# CircuitPython-specific files *.mpy -.idea + +# Python-specific files __pycache__ -_build *.pyc + +# Sphinx build-specific files +_build + +# This file results from running `pip -e install .` in a local repository +*.egg-info + +# Virtual environment-specific files .env -bundles + +# MacOS-specific files *.DS_Store -.eggs -dist -**/*.egg-info -venv + +# IDE-specific files +.idea +.vscode +*~ From bfcaa29f2c22b7f301a755fbceedf9657a7702e3 Mon Sep 17 00:00:00 2001 From: evaherrada Date: Fri, 22 Apr 2022 15:59:13 -0400 Subject: [PATCH 32/83] Patch: Replaced discord badge image --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index e370f6f..25ce4d8 100644 --- a/README.rst +++ b/README.rst @@ -5,7 +5,7 @@ Introduction :target: https://docs.circuitpython.org/projects/rgb_display/en/latest/ :alt: Documentation Status -.. image :: https://img.shields.io/discord/327254708534116352.svg +.. image:: https://github.com/adafruit/Adafruit_CircuitPython_Bundle/blob/main/badges/adafruit_discord.svg :target: https://adafru.it/discord :alt: Discord From 41cc29e4b95e1123e80f7ce9f59055f8dd681460 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sun, 24 Apr 2022 13:56:49 -0500 Subject: [PATCH 33/83] change discord badge --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 25ce4d8..21c3437 100644 --- a/README.rst +++ b/README.rst @@ -5,7 +5,7 @@ Introduction :target: https://docs.circuitpython.org/projects/rgb_display/en/latest/ :alt: Documentation Status -.. image:: https://github.com/adafruit/Adafruit_CircuitPython_Bundle/blob/main/badges/adafruit_discord.svg +.. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg :target: https://adafru.it/discord :alt: Discord From 33a9e6b93221de5137c6afd8b5e357c6256c7422 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 2 May 2022 12:27:34 -0500 Subject: [PATCH 34/83] button debouncing in the gif example --- examples/rgb_display_pillow_animated_gif.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/rgb_display_pillow_animated_gif.py b/examples/rgb_display_pillow_animated_gif.py index d4e5a6d..7fca4ce 100644 --- a/examples/rgb_display_pillow_animated_gif.py +++ b/examples/rgb_display_pillow_animated_gif.py @@ -133,6 +133,8 @@ def preload(self): def play(self): self.preload() + _prev_advance_btn_val = self.advance_button.value + _prev_back_btn_val = self.back_button.value # Check if we have loaded any files first if not self._gif_files: print("There are no Gif Images loaded to Play") @@ -141,12 +143,17 @@ def play(self): for frame_object in self._frames: start_time = time.monotonic() self.display.image(frame_object.image) - if not self.advance_button.value: + _cur_advance_btn_val = self.advance_button.value + _cur_back_btn_val = self.back_button.value + if not _cur_advance_btn_val and _prev_advance_btn_val: self.advance() return False - if not self.back_button.value: + if not _cur_back_btn_val and _prev_back_btn_val: self.back() return False + + _prev_back_btn_val = _cur_back_btn_val + _prev_advance_btn_val = _cur_advance_btn_val while time.monotonic() < (start_time + frame_object.duration / 1000): pass From 148c08332ddcee03fc146965e044bd3cf5022545 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Sun, 15 May 2022 12:21:22 -0400 Subject: [PATCH 35/83] Patch .pre-commit-config.yaml --- .pre-commit-config.yaml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 29230db..0a91a11 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,40 +3,40 @@ # SPDX-License-Identifier: Unlicense repos: -- repo: https://github.com/python/black + - repo: https://github.com/python/black rev: 22.3.0 hooks: - - id: black -- repo: https://github.com/fsfe/reuse-tool - rev: v0.12.1 + - id: black + - repo: https://github.com/fsfe/reuse-tool + rev: v0.14.0 hooks: - - id: reuse -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + - id: reuse + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.2.0 hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace -- repo: https://github.com/pycqa/pylint + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/pycqa/pylint rev: v2.11.1 hooks: - - id: pylint + - id: pylint name: pylint (library code) types: [python] args: - --disable=consider-using-f-string,duplicate-code exclude: "^(docs/|examples/|tests/|setup.py$)" - - id: pylint + - id: pylint name: pylint (example code) description: Run pylint rules on "examples/*.py" files types: [python] files: "^examples/" args: - - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code - - id: pylint + - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code + - id: pylint name: pylint (test code) description: Run pylint rules on "tests/*.py" files types: [python] files: "^tests/" args: - - --disable=missing-docstring,consider-using-f-string,duplicate-code + - --disable=missing-docstring,consider-using-f-string,duplicate-code From a85056d95914a9f226f9f1ee98446a24453fe380 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Sun, 22 May 2022 00:18:55 -0400 Subject: [PATCH 36/83] Increase min lines similarity Signed-off-by: Alec Delaney --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 61d81fb..8d537b3 100644 --- a/.pylintrc +++ b/.pylintrc @@ -253,7 +253,7 @@ ignore-docstrings=yes ignore-imports=yes # Minimum lines number of a similarity. -min-similarity-lines=4 +min-similarity-lines=12 [BASIC] From 2f7a44b957356246ab76c4e7c36f3c859cc64425 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Sun, 22 May 2022 00:18:23 -0400 Subject: [PATCH 37/83] Switch to inclusive terminology Signed-off-by: Alec Delaney --- .pylintrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pylintrc b/.pylintrc index 8d537b3..0bc0c7b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -9,11 +9,11 @@ # run arbitrary code extension-pkg-whitelist= -# Add files or directories to the blacklist. They should be base names, not +# Add files or directories to the ignore-list. They should be base names, not # paths. ignore=CVS -# Add files or directories matching the regex patterns to the blacklist. The +# Add files or directories matching the regex patterns to the ignore-list. The # regex matches against base names, not paths. ignore-patterns= From 9b64adaa4972141fa8a8d9e5c6bf9fd59562db34 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Mon, 30 May 2022 14:25:04 -0400 Subject: [PATCH 38/83] Set language to "en" for documentation Signed-off-by: Alec Delaney --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 2034c78..3572909 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -61,7 +61,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. From 2980a3f4efb4ea0894928826342942b6677ab006 Mon Sep 17 00:00:00 2001 From: evaherrada Date: Tue, 7 Jun 2022 15:34:53 -0400 Subject: [PATCH 39/83] Added cp.org link to index.rst --- docs/index.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 1bc6082..ef52631 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -35,7 +35,8 @@ Table of Contents .. toctree:: :caption: Other Links - Download + Download from GitHub + Download Library Bundle CircuitPython Reference Documentation CircuitPython Support Forum Discord Chat From a14d6e01a0f3b4dc68a869f62008a3fb4fb3533c Mon Sep 17 00:00:00 2001 From: evaherrada Date: Fri, 22 Jul 2022 13:59:15 -0400 Subject: [PATCH 40/83] Changed .env to .venv in README.rst --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 21c3437..8377ca2 100644 --- a/README.rst +++ b/README.rst @@ -57,8 +57,8 @@ To install in a virtual environment in your current project: .. code-block:: shell mkdir project-name && cd project-name - python3 -m venv .env - source .env/bin/activate + python3 -m venv .venv + source .venv/bin/activate pip3 install adafruit-circuitpython-rgb-display Usage Example From 3f7cd6d8b6d000aaff8f787c418f882f9fc68910 Mon Sep 17 00:00:00 2001 From: evaherrada Date: Tue, 2 Aug 2022 17:01:00 -0400 Subject: [PATCH 41/83] Added Black formatting badge --- README.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.rst b/README.rst index 8377ca2..9a7c211 100644 --- a/README.rst +++ b/README.rst @@ -13,6 +13,10 @@ Introduction :target: https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/actions/ :alt: Build Status +.. image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black + :alt: Code Style: Black + Port of display drivers from https://github.com/adafruit/micropython-adafruit-rgb-display to Adafruit CircuitPython for use on Adafruit's SAMD21-based and other CircuitPython boards. .. note:: This driver currently won't work on micropython.org firmware, instead you want the micropython-adafruit-rgb-display driver linked above! From 910fab603b7732018a20f3b482169f67b19039cc Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Mon, 8 Aug 2022 22:05:53 -0400 Subject: [PATCH 42/83] Switched to pyproject.toml --- .github/workflows/build.yml | 18 +++++++----- .github/workflows/release.yml | 17 ++++++----- optional_requirements.txt | 3 ++ pyproject.toml | 49 +++++++++++++++++++++++++++++++ requirements.txt | 2 +- setup.py | 55 ----------------------------------- 6 files changed, 73 insertions(+), 71 deletions(-) create mode 100644 optional_requirements.txt create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 474520d..22f6582 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,6 +47,8 @@ jobs: pip install --force-reinstall Sphinx sphinx-rtd-theme pre-commit - name: Library version run: git describe --dirty --always --tags + - name: Setup problem matchers + uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1 - name: Pre-commit hooks run: | pre-commit run --all-files @@ -60,16 +62,16 @@ jobs: - name: Build docs working-directory: docs run: sphinx-build -E -W -b html . _build/html - - name: Check For setup.py + - name: Check For pyproject.toml id: need-pypi run: | - echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) + echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' ) - name: Build Python package - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') run: | - pip install --upgrade setuptools wheel twine readme_renderer testresources - python setup.py sdist - python setup.py bdist_wheel --universal + pip install --upgrade build twine + for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do + sed -i -e "s/0.0.0-auto.0/1.2.3/" $file; + done; + python -m build twine check dist/* - - name: Setup problem matchers - uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a65e5de..d1b4f8d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,25 +61,28 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Check For setup.py + - name: Check For pyproject.toml id: need-pypi run: | - echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) + echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' ) - name: Set up Python - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') uses: actions/setup-python@v2 with: python-version: '3.x' - name: Install dependencies - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install --upgrade build twine - name: Build and publish - if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') env: TWINE_USERNAME: ${{ secrets.pypi_username }} TWINE_PASSWORD: ${{ secrets.pypi_password }} run: | - python setup.py sdist + for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do + sed -i -e "s/0.0.0-auto.0/${{github.event.release.tag_name}}/" $file; + done; + python -m build twine upload dist/* diff --git a/optional_requirements.txt b/optional_requirements.txt new file mode 100644 index 0000000..d4e27c4 --- /dev/null +++ b/optional_requirements.txt @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7cf4a71 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,49 @@ +# SPDX-FileCopyrightText: 2022 Alec Delaney for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +[build-system] +requires = [ + "setuptools", + "wheel", +] + +[project] +name = "adafruit-circuitpython-rgb-display" +description = "CircuitPython library for RGB displays." +version = "0.0.0-auto.0" +readme = "README.rst" +authors = [ + {name = "Adafruit Industries", email = "circuitpython@adafruit.com"} +] +urls = {Homepage = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display"} +keywords = [ + "adafruit", + "rgb", + "display", + "hx8353", + "ili9341", + "s6d02A1", + "ssd1331", + "ssd1351", + "st7735hardware", + "micropython", + "circuitpython", +] +license = {text = "MIT"} +classifiers = [ + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Embedded Systems", + "Topic :: System :: Hardware", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", +] +dynamic = ["dependencies", "optional-dependencies"] + +[tool.setuptools] +packages = ["adafruit_rgb_display"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} +optional-dependencies = {optional = {file = ["optional_requirements.txt"]}} diff --git a/requirements.txt b/requirements.txt index f675e3b..a45c547 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries # # SPDX-License-Identifier: Unlicense diff --git a/setup.py b/setup.py deleted file mode 100644 index ea44357..0000000 --- a/setup.py +++ /dev/null @@ -1,55 +0,0 @@ -# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries -# -# SPDX-License-Identifier: MIT - -"""A setuptools based setup module. - -See: -https://packaging.python.org/en/latest/distributing.html -https://github.com/pypa/sampleproject -""" - -# Always prefer setuptools over distutils -from setuptools import setup, find_packages - -# To use a consistent encoding -from codecs import open -from os import path - -here = path.abspath(path.dirname(__file__)) - -# Get the long description from the README file -with open(path.join(here, "README.rst"), encoding="utf-8") as f: - long_description = f.read() - -setup( - name="adafruit-circuitpython-rgb-display", - use_scm_version=True, - setup_requires=["setuptools_scm"], - description="CircuitPython library for RGB displays.", - long_description=long_description, - long_description_content_type="text/x-rst", - # The project's main homepage. - url="https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display", - # Author details - author="Radomir Dopieralski, Michael McWethy", - author_email="circuitpython@adafruit.com", - install_requires=["Adafruit-Blinka", "adafruit-circuitpython-busdevice"], - # Choose your license - license="MIT", - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "Topic :: Software Development :: Libraries", - "Topic :: System :: Hardware", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3", - ], - # What does your project relate to? - keywords="adafruit rgb display hx8353 ili9341 s6d02A1 ssd1331 ssd1351 st7735" - "hardware micropython circuitpython", - # You can just specify the packages manually here if your project is - # simple. Or you can use find_packages(). - packages=["adafruit_rgb_display"], -) From 29794092ff84fee8114e92022f2167a44526bd12 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 9 Aug 2022 12:03:54 -0400 Subject: [PATCH 43/83] Add setuptools-scm to build system requirements Signed-off-by: Alec Delaney --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 7cf4a71..d85bc62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ requires = [ "setuptools", "wheel", + "setuptools-scm", ] [project] From 27a6db9d1cbb4f4a6a1c8d7a43ca3da0a8ecc266 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 16 Aug 2022 18:09:14 -0400 Subject: [PATCH 44/83] Update version string --- adafruit_rgb_display/hx8353.py | 2 +- adafruit_rgb_display/hx8357.py | 2 +- adafruit_rgb_display/ili9341.py | 2 +- adafruit_rgb_display/rgb.py | 2 +- adafruit_rgb_display/s6d02a1.py | 2 +- adafruit_rgb_display/ssd1331.py | 2 +- adafruit_rgb_display/ssd1351.py | 2 +- adafruit_rgb_display/st7735.py | 2 +- adafruit_rgb_display/st7789.py | 2 +- pyproject.toml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/adafruit_rgb_display/hx8353.py b/adafruit_rgb_display/hx8353.py index 2c44124..69819a8 100644 --- a/adafruit_rgb_display/hx8353.py +++ b/adafruit_rgb_display/hx8353.py @@ -14,7 +14,7 @@ from adafruit_rgb_display.rgb import DisplaySPI -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" _SWRESET = const(0x01) diff --git a/adafruit_rgb_display/hx8357.py b/adafruit_rgb_display/hx8357.py index e0898d9..556f107 100755 --- a/adafruit_rgb_display/hx8357.py +++ b/adafruit_rgb_display/hx8357.py @@ -13,7 +13,7 @@ from micropython import const from adafruit_rgb_display.rgb import DisplaySPI -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" _SWRESET = const(0x01) diff --git a/adafruit_rgb_display/ili9341.py b/adafruit_rgb_display/ili9341.py index b29b3f2..a01c38b 100644 --- a/adafruit_rgb_display/ili9341.py +++ b/adafruit_rgb_display/ili9341.py @@ -14,7 +14,7 @@ from adafruit_rgb_display.rgb import DisplaySPI -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index 8d92fb8..1486203 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -21,7 +21,7 @@ from adafruit_bus_device import spi_device -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" # This is the size of the buffer to be used for fill operations, in 16-bit diff --git a/adafruit_rgb_display/s6d02a1.py b/adafruit_rgb_display/s6d02a1.py index 34fea6c..92cd2d1 100644 --- a/adafruit_rgb_display/s6d02a1.py +++ b/adafruit_rgb_display/s6d02a1.py @@ -14,7 +14,7 @@ from micropython import const from adafruit_rgb_display.rgb import DisplaySPI -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" _SWRESET = const(0x01) diff --git a/adafruit_rgb_display/ssd1331.py b/adafruit_rgb_display/ssd1331.py index c3f347d..6fd0e90 100644 --- a/adafruit_rgb_display/ssd1331.py +++ b/adafruit_rgb_display/ssd1331.py @@ -14,7 +14,7 @@ from micropython import const from adafruit_rgb_display.rgb import DisplaySPI -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" diff --git a/adafruit_rgb_display/ssd1351.py b/adafruit_rgb_display/ssd1351.py index 9ae2cb1..cc5e5b8 100644 --- a/adafruit_rgb_display/ssd1351.py +++ b/adafruit_rgb_display/ssd1351.py @@ -13,7 +13,7 @@ from micropython import const from adafruit_rgb_display.rgb import DisplaySPI -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" _SETCOLUMN = const(0x15) diff --git a/adafruit_rgb_display/st7735.py b/adafruit_rgb_display/st7735.py index b1686bb..3be6446 100644 --- a/adafruit_rgb_display/st7735.py +++ b/adafruit_rgb_display/st7735.py @@ -15,7 +15,7 @@ from micropython import const from adafruit_rgb_display.rgb import DisplaySPI -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" _NOP = const(0x00) diff --git a/adafruit_rgb_display/st7789.py b/adafruit_rgb_display/st7789.py index 05133d1..af57686 100644 --- a/adafruit_rgb_display/st7789.py +++ b/adafruit_rgb_display/st7789.py @@ -16,7 +16,7 @@ from micropython import const from adafruit_rgb_display.rgb import DisplaySPI -__version__ = "0.0.0-auto.0" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" _NOP = const(0x00) diff --git a/pyproject.toml b/pyproject.toml index d85bc62..bb09061 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ requires = [ [project] name = "adafruit-circuitpython-rgb-display" description = "CircuitPython library for RGB displays." -version = "0.0.0-auto.0" +version = "0.0.0+auto.0" readme = "README.rst" authors = [ {name = "Adafruit Industries", email = "circuitpython@adafruit.com"} From 9e544eebef2950ba695012c1f574ad4b5d8acc31 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 16 Aug 2022 21:09:14 -0400 Subject: [PATCH 45/83] Fix version strings in workflow files --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 22f6582..cb2f60e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,7 +71,7 @@ jobs: run: | pip install --upgrade build twine for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do - sed -i -e "s/0.0.0-auto.0/1.2.3/" $file; + sed -i -e "s/0.0.0+auto.0/1.2.3/" $file; done; python -m build twine check dist/* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d1b4f8d..f3a0325 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,7 +82,7 @@ jobs: TWINE_PASSWORD: ${{ secrets.pypi_password }} run: | for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do - sed -i -e "s/0.0.0-auto.0/${{github.event.release.tag_name}}/" $file; + sed -i -e "s/0.0.0+auto.0/${{github.event.release.tag_name}}/" $file; done; python -m build twine upload dist/* From e8341abe275fa95f036a3741b9a9d567268b3be6 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Mon, 22 Aug 2022 21:36:31 -0400 Subject: [PATCH 46/83] Keep copyright up to date in documentation --- docs/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 3572909..8ba7c47 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -6,6 +6,7 @@ import os import sys +import datetime sys.path.insert(0, os.path.abspath("..")) @@ -44,7 +45,8 @@ # General information about the project. project = "Adafruit RGB_Display Library" -copyright = "2017 Michale McWethy" +current_year = str(datetime.datetime.now().year) +copyright = current_year + " Michale McWethy" author = "Michale McWethy" # The version info for the project you're documenting, acts as replacement for From 65cb921c4b028652da5ed5d58d2690b78f3a27c5 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 23 Aug 2022 17:26:21 -0400 Subject: [PATCH 47/83] Use year duration range for copyright attribution --- docs/conf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 8ba7c47..33a0204 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -45,8 +45,14 @@ # General information about the project. project = "Adafruit RGB_Display Library" +creation_year = "2017" current_year = str(datetime.datetime.now().year) -copyright = current_year + " Michale McWethy" +year_duration = ( + current_year + if current_year == creation_year + else creation_year + " - " + current_year +) +copyright = year_duration + " Michale McWethy" author = "Michale McWethy" # The version info for the project you're documenting, acts as replacement for From ca54137f2a7d0f443b5d212c32ecf85fe77e3f3c Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 4 Nov 2022 00:02:49 -0400 Subject: [PATCH 48/83] Switching to composite actions --- .github/workflows/build.yml | 67 +---------------------- .github/workflows/release.yml | 88 ------------------------------ .github/workflows/release_gh.yml | 14 +++++ .github/workflows/release_pypi.yml | 14 +++++ 4 files changed, 30 insertions(+), 153 deletions(-) delete mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/release_gh.yml create mode 100644 .github/workflows/release_pypi.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb2f60e..041a337 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,68 +10,5 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - name: Translate Repo Name For Build Tools filename_prefix - id: repo-name - run: | - echo ::set-output name=repo-name::$( - echo ${{ github.repository }} | - awk -F '\/' '{ print tolower($2) }' | - tr '_' '-' - ) - - name: Set up Python 3.x - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - name: Versions - run: | - python3 --version - - name: Checkout Current Repo - uses: actions/checkout@v1 - with: - submodules: true - - name: Checkout tools repo - uses: actions/checkout@v2 - with: - repository: adafruit/actions-ci-circuitpython-libs - path: actions-ci - - name: Install dependencies - # (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.) - run: | - source actions-ci/install.sh - - name: Pip install Sphinx, pre-commit - run: | - pip install --force-reinstall Sphinx sphinx-rtd-theme pre-commit - - name: Library version - run: git describe --dirty --always --tags - - name: Setup problem matchers - uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1 - - name: Pre-commit hooks - run: | - pre-commit run --all-files - - name: Build assets - run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location . - - name: Archive bundles - uses: actions/upload-artifact@v2 - with: - name: bundles - path: ${{ github.workspace }}/bundles/ - - name: Build docs - working-directory: docs - run: sphinx-build -E -W -b html . _build/html - - name: Check For pyproject.toml - id: need-pypi - run: | - echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' ) - - name: Build Python package - if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') - run: | - pip install --upgrade build twine - for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do - sed -i -e "s/0.0.0+auto.0/1.2.3/" $file; - done; - python -m build - twine check dist/* + - name: Run Build CI workflow + uses: adafruit/workflows-circuitpython-libs/build@main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index f3a0325..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,88 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries -# -# SPDX-License-Identifier: MIT - -name: Release Actions - -on: - release: - types: [published] - -jobs: - upload-release-assets: - runs-on: ubuntu-latest - steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - name: Translate Repo Name For Build Tools filename_prefix - id: repo-name - run: | - echo ::set-output name=repo-name::$( - echo ${{ github.repository }} | - awk -F '\/' '{ print tolower($2) }' | - tr '_' '-' - ) - - name: Set up Python 3.x - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - name: Versions - run: | - python3 --version - - name: Checkout Current Repo - uses: actions/checkout@v1 - with: - submodules: true - - name: Checkout tools repo - uses: actions/checkout@v2 - with: - repository: adafruit/actions-ci-circuitpython-libs - path: actions-ci - - name: Install deps - run: | - source actions-ci/install.sh - - name: Build assets - run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location . - - name: Upload Release Assets - # the 'official' actions version does not yet support dynamically - # supplying asset names to upload. @csexton's version chosen based on - # discussion in the issue below, as its the simplest to implement and - # allows for selecting files with a pattern. - # https://github.com/actions/upload-release-asset/issues/4 - #uses: actions/upload-release-asset@v1.0.1 - uses: csexton/release-asset-action@master - with: - pattern: "bundles/*" - github-token: ${{ secrets.GITHUB_TOKEN }} - - upload-pypi: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Check For pyproject.toml - id: need-pypi - run: | - echo ::set-output name=pyproject-toml::$( find . -wholename './pyproject.toml' ) - - name: Set up Python - if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - name: Install dependencies - if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') - run: | - python -m pip install --upgrade pip - pip install --upgrade build twine - - name: Build and publish - if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml') - env: - TWINE_USERNAME: ${{ secrets.pypi_username }} - TWINE_PASSWORD: ${{ secrets.pypi_password }} - run: | - for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do - sed -i -e "s/0.0.0+auto.0/${{github.event.release.tag_name}}/" $file; - done; - python -m build - twine upload dist/* diff --git a/.github/workflows/release_gh.yml b/.github/workflows/release_gh.yml new file mode 100644 index 0000000..041a337 --- /dev/null +++ b/.github/workflows/release_gh.yml @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +name: Build CI + +on: [pull_request, push] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Run Build CI workflow + uses: adafruit/workflows-circuitpython-libs/build@main diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml new file mode 100644 index 0000000..041a337 --- /dev/null +++ b/.github/workflows/release_pypi.yml @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +name: Build CI + +on: [pull_request, push] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Run Build CI workflow + uses: adafruit/workflows-circuitpython-libs/build@main From c48f578198bdf5d1d9ca560d8a7bfb0f428e347f Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 4 Nov 2022 00:46:59 -0400 Subject: [PATCH 49/83] Updated pylint version to 2.13.0 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0a91a11..e6ddf7c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/pycqa/pylint - rev: v2.11.1 + rev: v2.13.0 hooks: - id: pylint name: pylint (library code) From 0b7af566d295076b9b454aa3861bca2c219eb034 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 4 Nov 2022 08:15:20 -0400 Subject: [PATCH 50/83] Update pylint to 2.15.5 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e6ddf7c..6996f9c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/pycqa/pylint - rev: v2.13.0 + rev: v2.15.5 hooks: - id: pylint name: pylint (library code) From 35d6d7ed59134ec0eb4145d94b9cc331204c23ca Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 4 Nov 2022 09:12:44 -0400 Subject: [PATCH 51/83] Fix release CI files --- .github/workflows/release_gh.yml | 14 +++++++++----- .github/workflows/release_pypi.yml | 15 ++++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release_gh.yml b/.github/workflows/release_gh.yml index 041a337..b8aa8d6 100644 --- a/.github/workflows/release_gh.yml +++ b/.github/workflows/release_gh.yml @@ -2,13 +2,17 @@ # # SPDX-License-Identifier: MIT -name: Build CI +name: GitHub Release Actions -on: [pull_request, push] +on: + release: + types: [published] jobs: - test: + upload-release-assets: runs-on: ubuntu-latest steps: - - name: Run Build CI workflow - uses: adafruit/workflows-circuitpython-libs/build@main + - name: Run GitHub Release CI workflow + uses: adafruit/workflows-circuitpython-libs/release-gh@main + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index 041a337..65775b7 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -2,13 +2,18 @@ # # SPDX-License-Identifier: MIT -name: Build CI +name: PyPI Release Actions -on: [pull_request, push] +on: + release: + types: [published] jobs: - test: + upload-release-assets: runs-on: ubuntu-latest steps: - - name: Run Build CI workflow - uses: adafruit/workflows-circuitpython-libs/build@main + - name: Run PyPI Release CI workflow + uses: adafruit/workflows-circuitpython-libs/release-pypi@main + with: + pypi-username: ${{ secrets.pypi_username }} + pypi-password: ${{ secrets.pypi_password }} From 998002dd0875260008457179b1567ad1b526dc85 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 4 Nov 2022 18:34:33 -0400 Subject: [PATCH 52/83] Update .pylintrc for v2.15.5 --- .pylintrc | 46 ++++------------------------------------------ 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/.pylintrc b/.pylintrc index 0bc0c7b..40208c3 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense @@ -23,11 +23,10 @@ ignore-patterns= # Use multiple processes to speed up Pylint. jobs=1 -# jobs=2 # List of plugins (as comma separated values of python modules names) to load, # usually to register additional checkers. -load-plugins= +load-plugins=pylint.extensions.no_self_use # Pickle collected data for later comparisons. persistent=yes @@ -55,8 +54,8 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call -disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation,unspecified-encoding +# disable=import-error,raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,deprecated-str-translate-call +disable=raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,import-error,pointless-string-statement,unspecified-encoding # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -226,12 +225,6 @@ max-line-length=100 # Maximum number of lines in a module max-module-lines=1000 -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - # Allow the body of a class to be on the same line as the declaration if body # contains single statement. single-line-class-stmt=no @@ -258,38 +251,22 @@ min-similarity-lines=12 [BASIC] -# Naming hint for argument names -argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct argument names argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ -# Naming hint for attribute names -attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct attribute names attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ # Bad variable names which should always be refused, separated by a comma bad-names=foo,bar,baz,toto,tutu,tata -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - # Regular expression matching correct class attribute names class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ -# Naming hint for class names -# class-name-hint=[A-Z_][a-zA-Z0-9]+$ -class-name-hint=[A-Z_][a-zA-Z0-9_]+$ - # Regular expression matching correct class names # class-rgx=[A-Z_][a-zA-Z0-9]+$ class-rgx=[A-Z_][a-zA-Z0-9_]+$ -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - # Regular expression matching correct constant names const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ @@ -297,9 +274,6 @@ const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ # ones are exempt. docstring-min-length=-1 -# Naming hint for function names -function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct function names function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ @@ -310,21 +284,12 @@ good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_ # Include a hint for the correct naming format with invalid-name include-naming-hint=no -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - # Regular expression matching correct inline iteration names inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ -# Naming hint for method names -method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct method names method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - # Regular expression matching correct module names module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ @@ -340,9 +305,6 @@ no-docstring-rgx=^_ # to this list to register other decorators that produce valid properties. property-classes=abc.abstractproperty -# Naming hint for variable names -variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct variable names variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ From 4b691181e4c5f5ea1f682b3243ba7c4c5e7b2c6c 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 53/83] 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 600f288dd646688577b93ec4e75e11a372c0de79 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 54/83] 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 968a99c5069350ab7f1413f3af0f3d35d78345d9 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 3 Feb 2023 16:34:41 -0800 Subject: [PATCH 55/83] Added support for newer 0.96-inch display --- .gitignore | 1 + adafruit_rgb_display/st7735.py | 7 +++++-- examples/rgb_display_pillow_animated_gif.py | 4 +++- examples/rgb_display_pillow_demo.py | 4 +++- examples/rgb_display_pillow_image.py | 4 +++- examples/rgb_display_pillow_stats.py | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index db3d538..871d9a7 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ _build # This file results from running `pip -e install .` in a local repository *.egg-info +.eggs # Virtual environment-specific files .env diff --git a/adafruit_rgb_display/st7735.py b/adafruit_rgb_display/st7735.py index 3be6446..2ad4ddf 100644 --- a/adafruit_rgb_display/st7735.py +++ b/adafruit_rgb_display/st7735.py @@ -195,9 +195,11 @@ def __init__( x_offset=0, y_offset=0, rotation=0, - bgr=False + bgr=False, + invert=False, ): self._bgr = bgr + self._invert = invert super().__init__( spi, dc, @@ -227,7 +229,8 @@ def init(self): self.write(command, data) if self._bgr: self.write(_MADCTL, b"\xc0") - + if self._invert: + self.write(_INVON, None) class ST7735S(ST7735): """A simple driver for the ST7735S-based displays.""" diff --git a/examples/rgb_display_pillow_animated_gif.py b/examples/rgb_display_pillow_animated_gif.py index 7fca4ce..a268a2b 100644 --- a/examples/rgb_display_pillow_animated_gif.py +++ b/examples/rgb_display_pillow_animated_gif.py @@ -185,7 +185,9 @@ def run(self): # disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357 # disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R # disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R -# disp = st7735.ST7735R(spi, rotation=90, bgr=True, # 0.96" MiniTFT ST7735R +# disp = st7735.ST7735R(spi, rotation=90, bgr=True, width=80, # 0.96" MiniTFT Rev A ST7735R +# disp = st7735.ST7735R(spi, rotation=90, invert=True, width=80, # 0.96" MiniTFT Rev B ST7735R +# x_offset=26, y_offset=1, # disp = ssd1351.SSD1351(spi, rotation=180, # 1.5" SSD1351 # disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351 # disp = ssd1331.SSD1331(spi, rotation=180, # 0.96" SSD1331 diff --git a/examples/rgb_display_pillow_demo.py b/examples/rgb_display_pillow_demo.py index d5440bd..dc6eb56 100644 --- a/examples/rgb_display_pillow_demo.py +++ b/examples/rgb_display_pillow_demo.py @@ -47,7 +47,9 @@ # disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357 # disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R # disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R -# disp = st7735.ST7735R(spi, rotation=90, bgr=True, # 0.96" MiniTFT ST7735R +# disp = st7735.ST7735R(spi, rotation=90, bgr=True, width=80, # 0.96" MiniTFT Rev A ST7735R +# disp = st7735.ST7735R(spi, rotation=90, invert=True, width=80, # 0.96" MiniTFT Rev B ST7735R +# x_offset=26, y_offset=1, # disp = ssd1351.SSD1351(spi, rotation=180, # 1.5" SSD1351 # disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351 # disp = ssd1331.SSD1331(spi, rotation=180, # 0.96" SSD1331 diff --git a/examples/rgb_display_pillow_image.py b/examples/rgb_display_pillow_image.py index 04c40cc..1eb641c 100644 --- a/examples/rgb_display_pillow_image.py +++ b/examples/rgb_display_pillow_image.py @@ -42,7 +42,9 @@ # disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357 # disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R # disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R -# disp = st7735.ST7735R(spi, rotation=90, bgr=True, # 0.96" MiniTFT ST7735R +# disp = st7735.ST7735R(spi, rotation=90, bgr=True, width=80, # 0.96" MiniTFT Rev A ST7735R +# disp = st7735.ST7735R(spi, rotation=90, invert=True, width=80, # 0.96" MiniTFT Rev B ST7735R +# x_offset=26, y_offset=1, # disp = ssd1351.SSD1351(spi, rotation=180, # 1.5" SSD1351 # disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351 # disp = ssd1331.SSD1331(spi, rotation=180, # 0.96" SSD1331 diff --git a/examples/rgb_display_pillow_stats.py b/examples/rgb_display_pillow_stats.py index 577a5ec..748f2ca 100644 --- a/examples/rgb_display_pillow_stats.py +++ b/examples/rgb_display_pillow_stats.py @@ -44,7 +44,9 @@ # disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357 # disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R # disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R -# disp = st7735.ST7735R(spi, rotation=90, bgr=True, # 0.96" MiniTFT ST7735R +# disp = st7735.ST7735R(spi, rotation=90, bgr=True, width=80, # 0.96" MiniTFT Rev A ST7735R +# disp = st7735.ST7735R(spi, rotation=90, invert=True, width=80, # 0.96" MiniTFT Rev B ST7735R +# x_offset=26, y_offset=1, # disp = ssd1351.SSD1351(spi, rotation=180, # 1.5" SSD1351 # disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351 # disp = ssd1331.SSD1331(spi, rotation=180, # 0.96" SSD1331 From ee68228a2515bb886a647313f2112613ec95c495 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 3 Feb 2023 16:36:27 -0800 Subject: [PATCH 56/83] Ran pre-commit --- adafruit_rgb_display/st7735.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/adafruit_rgb_display/st7735.py b/adafruit_rgb_display/st7735.py index 2ad4ddf..ca86edc 100644 --- a/adafruit_rgb_display/st7735.py +++ b/adafruit_rgb_display/st7735.py @@ -132,7 +132,7 @@ def __init__( *, x_offset=0, y_offset=0, - rotation=0 + rotation=0, ): super().__init__( spi, @@ -232,6 +232,7 @@ def init(self): if self._invert: self.write(_INVON, None) + class ST7735S(ST7735): """A simple driver for the ST7735S-based displays.""" @@ -283,7 +284,7 @@ def __init__( *, x_offset=2, y_offset=1, - rotation=0 + rotation=0, ): self._bl = bl # Turn on backlight From 79eb6fcade1c883cf27867bc2c24a3de859087e9 Mon Sep 17 00:00:00 2001 From: Matt Land Date: Mon, 24 Apr 2023 15:43:13 -0600 Subject: [PATCH 57/83] initial typing support, mypy passes add missing copyright statements to .pre-commit-config.yaml, gitignore --- .gitignore | 3 + .pre-commit-config.yaml | 14 +++ adafruit_rgb_display/hx8353.py | 20 ++++- adafruit_rgb_display/hx8357.py | 30 ++++--- adafruit_rgb_display/ili9341.py | 34 +++++--- adafruit_rgb_display/rgb.py | 148 ++++++++++++++++++++------------ adafruit_rgb_display/s6d02a1.py | 31 ++++++- adafruit_rgb_display/ssd1331.py | 36 +++++--- adafruit_rgb_display/ssd1351.py | 38 ++++---- adafruit_rgb_display/st7735.py | 98 +++++++++++---------- adafruit_rgb_display/st7789.py | 39 +++++---- mypy.ini | 22 +++++ optional_requirements.txt | 5 ++ 13 files changed, 346 insertions(+), 172 deletions(-) create mode 100644 mypy.ini diff --git a/.gitignore b/.gitignore index 871d9a7..7d6346a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2022 Kattni Rembor, written for Adafruit Industries +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: MIT @@ -47,3 +48,5 @@ _build .idea .vscode *~ + +.mypy_cache/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6996f9c..5cedefc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2020 Diego Elio Pettenò +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: Unlicense @@ -40,3 +41,16 @@ repos: files: "^tests/" args: - --disable=missing-docstring,consider-using-f-string,duplicate-code + - repo: local + hooks: + - id: mypy + name: mypy (library code) + entry: "mypy adafruit_rgb_display" + language: python + additional_dependencies: ["mypy==1.2.0"] + types: [python] + exclude: "^(docs/|examples/|tests/|setup.py$)" + # use require_serial so that script + # is only called once per commit + require_serial: true + pass_filenames: false diff --git a/adafruit_rgb_display/hx8353.py b/adafruit_rgb_display/hx8353.py index 69819a8..2aaf712 100644 --- a/adafruit_rgb_display/hx8353.py +++ b/adafruit_rgb_display/hx8353.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2017 Radomir Dopieralski for Adafruit Industries +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: MIT @@ -8,11 +9,17 @@ A simple driver for the HX8353-based displays. -* Author(s): Radomir Dopieralski, Michael McWethy +* Author(s): Radomir Dopieralski, Michael McWethy, Matt Land """ from micropython import const from adafruit_rgb_display.rgb import DisplaySPI +try: + from typing import Optional + import digitalio + import busio +except ImportError: + pass __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" @@ -59,5 +66,14 @@ class HX8353(DisplaySPI): _ENCODE_POS = ">HH" # pylint: disable-msg=useless-super-delegation, too-many-arguments - def __init__(self, spi, dc, cs, rst=None, width=128, height=128, rotation=0): + def __init__( + self, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + rst: Optional[digitalio.DigitalInOut] = None, + width: int = 128, + height: int = 128, + rotation: int = 0, + ) -> None: super().__init__(spi, dc, cs, rst, width, height, rotation) diff --git a/adafruit_rgb_display/hx8357.py b/adafruit_rgb_display/hx8357.py index 556f107..dfb9e2f 100755 --- a/adafruit_rgb_display/hx8357.py +++ b/adafruit_rgb_display/hx8357.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2019 Melissa LeBlanc-Williams for Adafruit Industries +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: MIT @@ -8,11 +9,18 @@ A simple driver for the HX8357-based displays. -* Author(s): Melissa LeBlanc-Williams +* Author(s): Melissa LeBlanc-Williams, Matt Land """ from micropython import const from adafruit_rgb_display.rgb import DisplaySPI +try: + from typing import Optional + import digitalio + import busio +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" @@ -94,16 +102,16 @@ class HX8357(DisplaySPI): # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, - spi, - dc, - cs, - rst=None, - width=480, - height=320, - baudrate=16000000, - polarity=0, - phase=0, - rotation=0, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + rst: Optional[digitalio.DigitalInOut] = None, + width: int = 480, + height: int = 320, + baudrate: int = 16000000, + polarity: int = 0, + phase: int = 0, + rotation: int = 0, ): super().__init__( spi, diff --git a/adafruit_rgb_display/ili9341.py b/adafruit_rgb_display/ili9341.py index a01c38b..bb90093 100644 --- a/adafruit_rgb_display/ili9341.py +++ b/adafruit_rgb_display/ili9341.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2017 Radomir Dopieralski for Adafruit Industries +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: MIT @@ -8,12 +9,19 @@ A simple driver for the ILI9341/ILI9340-based displays. -* Author(s): Radomir Dopieralski, Michael McWethy +* Author(s): Radomir Dopieralski, Michael McWethy, Matt Land """ import struct from adafruit_rgb_display.rgb import DisplaySPI +try: + from typing import Optional + import digitalio + import busio +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" @@ -74,16 +82,16 @@ class ILI9341(DisplaySPI): # pylint: disable-msg=too-many-arguments def __init__( self, - spi, - dc, - cs, - rst=None, - width=240, - height=320, - baudrate=16000000, - polarity=0, - phase=0, - rotation=0, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + rst: Optional[digitalio.DigitalInOut] = None, + width: int = 240, + height: int = 320, + baudrate: int = 16000000, + polarity: int = 0, + phase: int = 0, + rotation: int = 0, ): super().__init__( spi, @@ -101,7 +109,9 @@ def __init__( # pylint: enable-msg=too-many-arguments - def scroll(self, dy=None): # pylint: disable-msg=invalid-name + def scroll( + self, dy: Optional[int] = None # pylint: disable-msg=invalid-name + ) -> Optional[int]: """Scroll the display by delta y""" if dy is None: return self._scroll diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index 1486203..c9b3233 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2017 Radomir Dopieralski for Adafruit Industries +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: MIT @@ -8,12 +9,21 @@ Base class for all RGB Display devices -* Author(s): Radomir Dopieralski, Michael McWethy +* Author(s): Radomir Dopieralski, Michael McWethy, Matt Land """ import struct import time +try: + from typing import Optional, Union, Tuple, List, Any, ByteString + import digitalio + import busio + + Image = Any # from PIL import Image +except ImportError: + pass + try: import numpy except ImportError: @@ -36,18 +46,22 @@ pass -def color565(r, g=0, b=0): +def color565( + r: Union[int, Tuple[int, int, int], List[int]], + g: int = 0, + b: int = 0, +) -> int: """Convert red, green and blue values (0-255) into a 16-bit 565 encoding. As a convenience this is also available in the parent adafruit_rgb_display package namespace.""" - try: - r, g, b = r # see if the first var is a tuple/list - except TypeError: - pass - return (r & 0xF8) << 8 | (g & 0xFC) << 3 | b >> 3 + if not isinstance(r, int): # see if the first var is a tuple/list + red, g, b = r + else: + red = r + return (red & 0xF8) << 8 | (g & 0xFC) << 3 | b >> 3 -def image_to_data(image): +def image_to_data(image: Image) -> Any: """Generator function to convert a PIL image to 16-bit 565 RGB bytes.""" # NumPy is much faster at doing this. NumPy code provided by: # Keith (https://www.blogger.com/profile/02555547344016007163) @@ -63,37 +77,39 @@ def image_to_data(image): class DummyPin: """Can be used in place of a ``DigitalInOut()`` when you don't want to skip it.""" - def deinit(self): + def deinit(self) -> None: """Dummy DigitalInOut deinit""" - def switch_to_output(self, *args, **kwargs): + def switch_to_output( + self, *, value: bool = False, drive_mode: Optional[digitalio.DriveMode] = None + ) -> None: """Dummy switch_to_output method""" - def switch_to_input(self, *args, **kwargs): + def switch_to_input(self, *, pull: Optional[digitalio.Pull] = None) -> None: """Dummy switch_to_input method""" @property - def value(self): + def value(self) -> digitalio.DigitalInOut: """Dummy value DigitalInOut property""" @value.setter - def value(self, val): + def value(self, val: digitalio.DigitalInOut) -> None: pass @property - def direction(self): + def direction(self) -> digitalio.Direction: """Dummy direction DigitalInOut property""" @direction.setter - def direction(self, val): + def direction(self, val: digitalio.Direction) -> None: pass @property - def pull(self): + def pull(self) -> digitalio.Pull: """Dummy pull DigitalInOut property""" @pull.setter - def pull(self, val): + def pull(self, val: digitalio.Pull) -> None: pass @@ -103,18 +119,18 @@ class Display: # pylint: disable-msg=no-member :param height: number of pixels high """ - _PAGE_SET = None - _COLUMN_SET = None - _RAM_WRITE = None - _RAM_READ = None + _PAGE_SET: Optional[int] = None + _COLUMN_SET: Optional[int] = None + _RAM_WRITE: Optional[int] = None + _RAM_READ: Optional[int] = None _X_START = 0 # pylint: disable=invalid-name _Y_START = 0 # pylint: disable=invalid-name - _INIT = () + _INIT: Tuple[Tuple[int, Union[ByteString, None]], ...] = () _ENCODE_PIXEL = ">H" _ENCODE_POS = ">HH" _DECODE_PIXEL = ">BBB" - def __init__(self, width, height, rotation): + def __init__(self, width: int, height: int, rotation: int) -> None: self.width = width self.height = height if rotation not in (0, 90, 180, 270): @@ -122,13 +138,25 @@ def __init__(self, width, height, rotation): self._rotation = rotation self.init() - def init(self): + def write( + self, command: Optional[int] = None, data: Optional[ByteString] = None + ) -> None: + """Abstract method""" + raise NotImplementedError() + + def read(self, command: Optional[int] = None, count: int = 0) -> ByteString: + """Abstract method""" + raise NotImplementedError() + + def init(self) -> None: """Run the initialization commands.""" for command, data in self._INIT: self.write(command, data) # pylint: disable-msg=invalid-name,too-many-arguments - def _block(self, x0, y0, x1, y1, data=None): + def _block( + self, x0: int, y0: int, x1: int, y1: int, data: Optional[ByteString] = None + ) -> Optional[ByteString]: """Read or write a block of data.""" self.write( self._COLUMN_SET, self._encode_pos(x0 + self._X_START, x1 + self._X_START) @@ -144,28 +172,34 @@ def _block(self, x0, y0, x1, y1, data=None): # pylint: enable-msg=invalid-name,too-many-arguments - def _encode_pos(self, x, y): - """Encode a postion into bytes.""" + def _encode_pos(self, x: int, y: int) -> bytes: + """Encode a position into bytes.""" return struct.pack(self._ENCODE_POS, x, y) - def _encode_pixel(self, color): + def _encode_pixel(self, color: Any) -> bytes: """Encode a pixel color into bytes.""" return struct.pack(self._ENCODE_PIXEL, color) - def _decode_pixel(self, data): + def _decode_pixel(self, data: Union[bytes, Union[bytearray, memoryview]]) -> int: """Decode bytes into a pixel color.""" return color565(*struct.unpack(self._DECODE_PIXEL, data)) - def pixel(self, x, y, color=None): + def pixel(self, x: int, y: int, color: Optional[Any] = None) -> Optional[int]: """Read or write a pixel at a given position.""" if color is None: - return self._decode_pixel(self._block(x, y, x, y)) + return self._decode_pixel(self._block(x, y, x, y)) # type: ignore[arg-type] if 0 <= x < self.width and 0 <= y < self.height: self._block(x, y, x, y, self._encode_pixel(color)) return None - def image(self, img, rotation=None, x=0, y=0): + def image( + self, + img: Image, + rotation: Optional[int] = None, + x: int = 0, + y: int = 0, + ) -> None: """Set buffer to value of Python Imaging Library image. The image should be in 1 bit mode and a size not exceeding the display size when drawn at the supplied origin.""" @@ -197,7 +231,9 @@ def image(self, img, rotation=None, x=0, y=0): self._block(x, y, x + imwidth - 1, y + imheight - 1, pixels) # pylint: disable-msg=too-many-arguments - def fill_rectangle(self, x, y, width, height, color): + def fill_rectangle( + self, x: int, y: int, width: int, height: int, color: Any + ) -> None: """Draw a rectangle at specified position with specified width and height, and fill it with the specified color.""" x = min(self.width - 1, max(0, x)) @@ -215,25 +251,25 @@ def fill_rectangle(self, x, y, width, height, color): # pylint: enable-msg=too-many-arguments - def fill(self, color=0): + def fill(self, color: Any = 0) -> None: """Fill the whole display with the specified color.""" self.fill_rectangle(0, 0, self.width, self.height, color) - def hline(self, x, y, width, color): + def hline(self, x: int, y: int, width: int, color: Any) -> None: """Draw a horizontal line.""" self.fill_rectangle(x, y, width, 1, color) - def vline(self, x, y, height, color): + def vline(self, x: int, y: int, height: int, color: Any) -> None: """Draw a vertical line.""" self.fill_rectangle(x, y, 1, height, color) @property - def rotation(self): + def rotation(self) -> int: """Set the default rotation""" return self._rotation @rotation.setter - def rotation(self, val): + def rotation(self, val: int) -> None: if val not in (0, 90, 180, 270): raise ValueError("Rotation must be 0/90/180/270") self._rotation = val @@ -245,19 +281,19 @@ class DisplaySPI(Display): # pylint: disable-msg=too-many-arguments def __init__( self, - spi, - dc, - cs, - rst=None, - width=1, - height=1, - baudrate=12000000, - polarity=0, - phase=0, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + rst: Optional[digitalio.DigitalInOut] = None, + width: int = 1, + height: int = 1, + baudrate: int = 12000000, + polarity: int = 0, + phase: int = 0, *, - x_offset=0, - y_offset=0, - rotation=0 + x_offset: int = 0, + y_offset: int = 0, + rotation: int = 0 ): self.spi_device = spi_device.SPIDevice( spi, cs, baudrate=baudrate, polarity=polarity, phase=phase @@ -274,15 +310,19 @@ def __init__( # pylint: enable-msg=too-many-arguments - def reset(self): + def reset(self) -> None: """Reset the device""" + if not self.rst: + raise RuntimeError("a reset pin was not provided") self.rst.value = 0 time.sleep(0.050) # 50 milliseconds self.rst.value = 1 time.sleep(0.050) # 50 milliseconds # pylint: disable=no-member - def write(self, command=None, data=None): + def write( + self, command: Optional[int] = None, data: Optional[ByteString] = None + ) -> None: """SPI write to the device: commands and data""" if command is not None: self.dc_pin.value = 0 @@ -293,13 +333,13 @@ def write(self, command=None, data=None): with self.spi_device as spi: spi.write(data) - def read(self, command=None, count=0): + def read(self, command: Optional[int] = None, count: int = 0) -> ByteString: """SPI read from device with optional command""" data = bytearray(count) self.dc_pin.value = 0 with self.spi_device as spi: if command is not None: - spi.write(bytearray([command])) + spi.write(bytearray([command])) # change to self.write() if count: spi.readinto(data) return data diff --git a/adafruit_rgb_display/s6d02a1.py b/adafruit_rgb_display/s6d02a1.py index 92cd2d1..568cdec 100644 --- a/adafruit_rgb_display/s6d02a1.py +++ b/adafruit_rgb_display/s6d02a1.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2017 Radomir Dopieralski for Adafruit Industries +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: MIT @@ -8,12 +9,19 @@ A simple driver for the S6D02A1-based displays. -* Author(s): Radomir Dopieralski, Michael McWethy +* Author(s): Radomir Dopieralski, Michael McWethy, Matt Land """ from micropython import const from adafruit_rgb_display.rgb import DisplaySPI +try: + from typing import Optional + import digitalio + import busio +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" @@ -59,5 +67,22 @@ class S6D02A1(DisplaySPI): _ENCODE_POS = ">HH" # pylint: disable-msg=useless-super-delegation, too-many-arguments - def __init__(self, spi, dc, cs, rst=None, width=128, height=160, rotation=0): - super().__init__(spi, dc, cs, rst, width, height, rotation) + def __init__( + self, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + rst: Optional[digitalio.DigitalInOut] = None, + width: int = 128, + height: int = 160, + rotation: int = 0, + ): + super().__init__( + spi=spi, + dc=dc, + cs=cs, + rst=rst, + width=width, + height=height, + rotation=rotation, + ) diff --git a/adafruit_rgb_display/ssd1331.py b/adafruit_rgb_display/ssd1331.py index 6fd0e90..167afe1 100644 --- a/adafruit_rgb_display/ssd1331.py +++ b/adafruit_rgb_display/ssd1331.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2017 Radomir Dopieralski for Adafruit Industries +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: MIT @@ -8,12 +9,19 @@ A simple driver for the SSD1331-based displays. -* Author(s): Radomir Dopieralski, Michael McWethy +* Author(s): Radomir Dopieralski, Michael McWethy, Matt Land """ from micropython import const from adafruit_rgb_display.rgb import DisplaySPI +try: + from typing import Optional, ByteString + import digitalio + import busio +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" @@ -107,18 +115,18 @@ class SSD1331(DisplaySPI): # super required to allow override of default values def __init__( self, - spi, - dc, - cs, - rst=None, - width=96, - height=64, - baudrate=16000000, - polarity=0, - phase=0, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + rst: Optional[digitalio.DigitalInOut] = None, + width: int = 96, + height: int = 64, + baudrate: int = 16000000, + polarity: int = 0, + phase: int = 0, *, - rotation=0 - ): + rotation: int = 0 + ) -> None: super().__init__( spi, dc, @@ -133,7 +141,9 @@ def __init__( ) # pylint: disable=no-member - def write(self, command=None, data=None): + def write( + self, command: Optional[int] = None, data: Optional[ByteString] = None + ) -> None: """write procedure specific to SSD1331""" self.dc_pin.value = command is None with self.spi_device as spi: diff --git a/adafruit_rgb_display/ssd1351.py b/adafruit_rgb_display/ssd1351.py index cc5e5b8..03e58ab 100644 --- a/adafruit_rgb_display/ssd1351.py +++ b/adafruit_rgb_display/ssd1351.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2017 Radomir Dopieralski for Adafruit Industries +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: MIT @@ -8,11 +9,18 @@ A simple driver for the SSD1351-based displays. -* Author(s): Radomir Dopieralski, Michael McWethy +* Author(s): Radomir Dopieralski, Michael McWethy, Matt Land """ from micropython import const from adafruit_rgb_display.rgb import DisplaySPI +try: + from typing import Optional + import digitalio + import busio +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" @@ -99,22 +107,20 @@ class SSD1351(DisplaySPI): # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, - spi, - dc, - cs, - rst=None, - width=128, - height=128, - baudrate=16000000, - polarity=0, - phase=0, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + rst: Optional[digitalio.DigitalInOut] = None, + width: int = 128, + height: int = 128, + baudrate: int = 16000000, + polarity: int = 0, + phase: int = 0, *, - x_offset=0, - y_offset=0, - rotation=0 + x_offset: int = 0, + y_offset: int = 0, + rotation: int = 0 ): - baudrate = min(baudrate, 16000000) # Limit to Display Max Baudrate - super().__init__( spi, dc, @@ -122,7 +128,7 @@ def __init__( rst, width, height, - baudrate=baudrate, + baudrate=min(baudrate, 16000000), # Limit to Display Max Baudrate polarity=polarity, phase=phase, x_offset=x_offset, diff --git a/adafruit_rgb_display/st7735.py b/adafruit_rgb_display/st7735.py index ca86edc..daa5020 100644 --- a/adafruit_rgb_display/st7735.py +++ b/adafruit_rgb_display/st7735.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2017 Radomir Dopieralski for Adafruit Industries +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: MIT @@ -8,13 +9,20 @@ A simple driver for the ST7735-based displays. -* Author(s): Radomir Dopieralski, Michael McWethy +* Author(s): Radomir Dopieralski, Michael McWethy, Matt Land """ import struct from micropython import const from adafruit_rgb_display.rgb import DisplaySPI +try: + from typing import Optional, Tuple, ByteString, Union + import digitalio + import busio +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" @@ -113,27 +121,27 @@ class ST7735(DisplaySPI): (_RASET, b"\x00\x02\x00\x81"), # XSTART = 2, XEND = 129 (_NORON, None), (_DISPON, None), - ) + ) # type: Tuple[Tuple[int, Union[ByteString, None]], ...] _ENCODE_PIXEL = ">H" _ENCODE_POS = ">HH" # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, - spi, - dc, - cs, - rst=None, - width=128, - height=128, - baudrate=16000000, - polarity=0, - phase=0, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + rst: Optional[digitalio.DigitalInOut] = None, + width: int = 128, + height: int = 128, + baudrate: int = 16000000, + polarity: int = 0, + phase: int = 0, *, - x_offset=0, - y_offset=0, - rotation=0, - ): + x_offset: int = 0, + y_offset: int = 0, + rotation: int = 0, + ) -> None: super().__init__( spi, dc, @@ -182,22 +190,22 @@ class ST7735R(ST7735): # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, - spi, - dc, - cs, - rst=None, - width=128, - height=160, - baudrate=16000000, - polarity=0, - phase=0, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + rst: Optional[digitalio] = None, + width: int = 128, + height: int = 160, + baudrate: int = 16000000, + polarity: int = 0, + phase: int = 0, *, - x_offset=0, - y_offset=0, - rotation=0, - bgr=False, - invert=False, - ): + x_offset: int = 0, + y_offset: int = 0, + rotation: int = 0, + bgr: bool = False, + invert: bool = False, + ) -> None: self._bgr = bgr self._invert = invert super().__init__( @@ -215,7 +223,7 @@ def __init__( rotation=rotation, ) - def init(self): + def init(self) -> None: super().init() cols = struct.pack(">HH", 0, self.width - 1) rows = struct.pack(">HH", 0, self.height - 1) @@ -271,21 +279,21 @@ class ST7735S(ST7735): # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, - spi, - dc, - cs, - bl, - rst=None, - width=128, - height=160, - baudrate=16000000, - polarity=0, - phase=0, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + bl: digitalio.DigitalInOut, # Backlight + rst: Optional[digitalio.DigitalInOut] = None, + width: int = 128, + height: int = 160, + baudrate: int = 16000000, + polarity: int = 0, + phase: int = 0, *, - x_offset=2, - y_offset=1, - rotation=0, - ): + x_offset: int = 2, + y_offset: int = 1, + rotation: int = 0, + ) -> None: self._bl = bl # Turn on backlight self._bl.switch_to_output(value=1) diff --git a/adafruit_rgb_display/st7789.py b/adafruit_rgb_display/st7789.py index af57686..3fcfc43 100644 --- a/adafruit_rgb_display/st7789.py +++ b/adafruit_rgb_display/st7789.py @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2019 Melissa LeBlanc-Williams for Adafruit Industries +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: MIT @@ -8,14 +9,21 @@ A simple driver for the ST7789-based displays. -* Author(s): Melissa LeBlanc-Williams +* Author(s): Melissa LeBlanc-Williams, Matt Land """ import struct +import busio +import digitalio from micropython import const from adafruit_rgb_display.rgb import DisplaySPI +try: + from typing import Optional +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" @@ -96,20 +104,20 @@ class ST7789(DisplaySPI): # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, - spi, - dc, - cs, - rst=None, - width=240, - height=320, - baudrate=16000000, - polarity=0, - phase=0, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + rst: Optional[digitalio.DigitalInOut] = None, + width: int = 240, + height: int = 320, + baudrate: int = 16000000, + polarity: int = 0, + phase: int = 0, *, - x_offset=0, - y_offset=0, - rotation=0 - ): + x_offset: int = 0, + y_offset: int = 0, + rotation: int = 0 + ) -> None: super().__init__( spi, dc, @@ -125,8 +133,7 @@ def __init__( rotation=rotation, ) - def init(self): - + def init(self) -> None: super().init() cols = struct.pack(">HH", self._X_START, self.width + self._X_START) rows = struct.pack(">HH", self._Y_START, self.height + self._Y_START) diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..8bf7236 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2023 Matt Land +# +# SPDX-License-Identifier: Unlicense +[mypy] +python_version = 3.7 +disallow_untyped_defs = True +exclude = (examples|tests|setup.py|docs) + +[mypy-digitalio] +ignore_missing_imports = True + +[mypy-busio] +ignore_missing_imports = True + +[mypy-numpy] +ignore_missing_imports = True + +[mypy-adafruit_bus_device] +ignore_missing_imports = True + +[mypy-micropython] +ignore_missing_imports = True diff --git a/optional_requirements.txt b/optional_requirements.txt index d4e27c4..595a870 100644 --- a/optional_requirements.txt +++ b/optional_requirements.txt @@ -1,3 +1,8 @@ # SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries +# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: Unlicense + +#adafruit_bus_device +#numpy +#PIL From 5aa898f3e0e0f5674346c81324150128a0493871 Mon Sep 17 00:00:00 2001 From: Matt Land Date: Mon, 24 Apr 2023 17:25:13 -0600 Subject: [PATCH 58/83] Add Color Type, change Image type, remove mypy pre-commit hook, remove comment --- .pre-commit-config.yaml | 14 -------------- adafruit_rgb_display/rgb.py | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5cedefc..6996f9c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,4 @@ # SPDX-FileCopyrightText: 2020 Diego Elio Pettenò -# SPDX-FileCopyrightText: 2023 Matt Land # # SPDX-License-Identifier: Unlicense @@ -41,16 +40,3 @@ repos: files: "^tests/" args: - --disable=missing-docstring,consider-using-f-string,duplicate-code - - repo: local - hooks: - - id: mypy - name: mypy (library code) - entry: "mypy adafruit_rgb_display" - language: python - additional_dependencies: ["mypy==1.2.0"] - types: [python] - exclude: "^(docs/|examples/|tests/|setup.py$)" - # use require_serial so that script - # is only called once per commit - require_serial: true - pass_filenames: false diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index c9b3233..48710e5 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -20,7 +20,7 @@ import digitalio import busio - Image = Any # from PIL import Image + from circuitpython_typing.pil import Image except ImportError: pass @@ -176,7 +176,7 @@ def _encode_pos(self, x: int, y: int) -> bytes: """Encode a position into bytes.""" return struct.pack(self._ENCODE_POS, x, y) - def _encode_pixel(self, color: Any) -> bytes: + def _encode_pixel(self, color: Union[int, Tuple]) -> bytes: """Encode a pixel color into bytes.""" return struct.pack(self._ENCODE_PIXEL, color) @@ -184,7 +184,9 @@ def _decode_pixel(self, data: Union[bytes, Union[bytearray, memoryview]]) -> int """Decode bytes into a pixel color.""" return color565(*struct.unpack(self._DECODE_PIXEL, data)) - def pixel(self, x: int, y: int, color: Optional[Any] = None) -> Optional[int]: + def pixel( + self, x: int, y: int, color: Optional[Union[int, Tuple]] = None + ) -> Optional[int]: """Read or write a pixel at a given position.""" if color is None: return self._decode_pixel(self._block(x, y, x, y)) # type: ignore[arg-type] @@ -232,7 +234,7 @@ def image( # pylint: disable-msg=too-many-arguments def fill_rectangle( - self, x: int, y: int, width: int, height: int, color: Any + self, x: int, y: int, width: int, height: int, color: Union[int, Tuple] ) -> None: """Draw a rectangle at specified position with specified width and height, and fill it with the specified color.""" @@ -251,15 +253,15 @@ def fill_rectangle( # pylint: enable-msg=too-many-arguments - def fill(self, color: Any = 0) -> None: + def fill(self, color: Union[int, Tuple] = 0) -> None: """Fill the whole display with the specified color.""" self.fill_rectangle(0, 0, self.width, self.height, color) - def hline(self, x: int, y: int, width: int, color: Any) -> None: + def hline(self, x: int, y: int, width: int, color: Union[int, Tuple]) -> None: """Draw a horizontal line.""" self.fill_rectangle(x, y, width, 1, color) - def vline(self, x: int, y: int, height: int, color: Any) -> None: + def vline(self, x: int, y: int, height: int, color: Union[int, Tuple]) -> None: """Draw a vertical line.""" self.fill_rectangle(x, y, 1, height, color) @@ -339,7 +341,7 @@ def read(self, command: Optional[int] = None, count: int = 0) -> ByteString: self.dc_pin.value = 0 with self.spi_device as spi: if command is not None: - spi.write(bytearray([command])) # change to self.write() + spi.write(bytearray([command])) if count: spi.readinto(data) return data From 2c7e95d1dd53944ff458a6246cb681e4c8f36fbb Mon Sep 17 00:00:00 2001 From: Matt Land Date: Tue, 25 Apr 2023 08:13:04 -0600 Subject: [PATCH 59/83] requested changes, fix DummyPin::value return --- adafruit_rgb_display/rgb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index 48710e5..5c906f7 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -89,7 +89,7 @@ def switch_to_input(self, *, pull: Optional[digitalio.Pull] = None) -> None: """Dummy switch_to_input method""" @property - def value(self) -> digitalio.DigitalInOut: + def value(self) -> bool: """Dummy value DigitalInOut property""" @value.setter From f29eb23984bf655900ae4a8bbcbb19cbfaffbf41 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Fri, 28 Apr 2023 08:26:43 -0400 Subject: [PATCH 60/83] Fix Optional type annotation --- adafruit_rgb_display/st7735.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_rgb_display/st7735.py b/adafruit_rgb_display/st7735.py index daa5020..0191a15 100644 --- a/adafruit_rgb_display/st7735.py +++ b/adafruit_rgb_display/st7735.py @@ -193,7 +193,7 @@ def __init__( spi: busio.SPI, dc: digitalio.DigitalInOut, cs: digitalio.DigitalInOut, - rst: Optional[digitalio] = None, + rst: Optional[digitalio.DigitalInOut] = None, width: int = 128, height: int = 160, baudrate: int = 16000000, From 46c3e46cbe9c4c6e2ea7b118be399e681ec9cb10 Mon Sep 17 00:00:00 2001 From: Tekktrik Date: Tue, 9 May 2023 20:26:25 -0400 Subject: [PATCH 61/83] 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 6996f9c..179cf07 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 3a313a3239067f9c7960d389bb21030f254e0848 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Tue, 23 May 2023 22:22:54 -0400 Subject: [PATCH 62/83] Update .pylintrc, fix jQuery for docs --- .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 33a0204..4118015 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.viewcode", ] 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 0603368370cd3c0852f39a67b5667228016ca18b Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 5 Jul 2023 11:05:37 -0700 Subject: [PATCH 63/83] Update examples to work with Pillow 10.0.0 --- examples/rgb_display_pillow_animated_gif.py | 2 +- examples/rgb_display_pillow_image.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/rgb_display_pillow_animated_gif.py b/examples/rgb_display_pillow_animated_gif.py index a268a2b..cc3a628 100644 --- a/examples/rgb_display_pillow_animated_gif.py +++ b/examples/rgb_display_pillow_animated_gif.py @@ -124,7 +124,7 @@ def preload(self): frame_object.image = ImageOps.pad( # pylint: disable=no-member image.convert("RGB"), (self._width, self._height), - method=Image.Resampling.NEAREST, + method=Image.NEAREST, color=(0, 0, 0), centering=(0.5, 0.5), ) diff --git a/examples/rgb_display_pillow_image.py b/examples/rgb_display_pillow_image.py index 1eb641c..b463106 100644 --- a/examples/rgb_display_pillow_image.py +++ b/examples/rgb_display_pillow_image.py @@ -86,7 +86,7 @@ else: scaled_width = width scaled_height = image.height * width // image.width -image = image.resize((scaled_width, scaled_height), Image.Resampling.BICUBIC) +image = image.resize((scaled_width, scaled_height), Image.BICUBIC) # Crop and center the image x = scaled_width // 2 - width // 2 From 07e240f531f038e864ff01937ba5b2eac2be8a81 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Tue, 29 Aug 2023 18:45:32 -0400 Subject: [PATCH 64/83] Add EYESPI Beret GIF player demo. --- .../rgb_display_eyespi_beret_animated_gif.py | 215 ++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 examples/rgb_display_eyespi_beret_animated_gif.py diff --git a/examples/rgb_display_eyespi_beret_animated_gif.py b/examples/rgb_display_eyespi_beret_animated_gif.py new file mode 100644 index 0000000..2ac205b --- /dev/null +++ b/examples/rgb_display_eyespi_beret_animated_gif.py @@ -0,0 +1,215 @@ +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc Williams for Adafruit Industries +# SPDX-License-Identifier: MIT + +""" +EYESPI Pi Beret GIF Player Demo + +Extracts the frames and other parameters from an animated gif +and then runs the animation on the display. + +Save this file as eyespi_beret_gif_player.py to your Raspberry Pi. + +Usage: +python3 eyespi_beret_gif_player.py + +This example is for use on Raspberry Pi that are using CPython with +Adafruit Blinka to support CircuitPython libraries. CircuitPython does +not support PIL/pillow (python imaging library)! + +Author(s): Melissa LeBlanc-Williams for Adafruit Industries + Mike Mallett +""" +import os +import time +import digitalio +import board +from PIL import Image, ImageOps +import numpy # pylint: disable=unused-import +from adafruit_rgb_display import ili9341 +from adafruit_rgb_display import st7789 # pylint: disable=unused-import +from adafruit_rgb_display import hx8357 # pylint: disable=unused-import +from adafruit_rgb_display import st7735 # pylint: disable=unused-import +from adafruit_rgb_display import ssd1351 # pylint: disable=unused-import +from adafruit_rgb_display import ssd1331 # pylint: disable=unused-import + +# Button pins for EYESPI Pi Beret +BUTTON_NEXT = board.D5 +BUTTON_PREVIOUS = board.D6 + +# CS and DC pins for EYEPSPI Pi Beret: +cs_pin = digitalio.DigitalInOut(board.CE0) +dc_pin = digitalio.DigitalInOut(board.D25) + +# Reset pin for EYESPI Pi Beret +reset_pin = digitalio.DigitalInOut(board.D27) + +# Backlight pin for Pi Beret +backlight = digitalio.DigitalInOut(board.D18) +backlight.switch_to_output() +backlight.value = True + +# Config for display baudrate (default max is 64mhz): +BAUDRATE = 64000000 + +# Setup SPI bus using hardware SPI: +spi = board.SPI() + +# pylint: disable=line-too-long +# fmt: off +# Create the display. +disp = ili9341.ILI9341(spi, rotation=90, # 2.2", 2.4", 2.8", 3.2" ILI9341 +# disp = st7789.ST7789(spi, rotation=90, # 2.0" ST7789 +# disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180, # 1.3", 1.54" ST7789 +# disp = st7789.ST7789(spi, rotation=90, width=135, height=240, x_offset=53, y_offset=40, # 1.14" ST7789 +# disp = st7789.ST7789(spi, rotation=90, width=172, height=320, x_offset=34, # 1.47" ST7789 +# disp = st7789.ST7789(spi, rotation=270, width=170, height=320, x_offset=35, # 1.9" ST7789 +# disp = hx8357.HX8357(spi, rotation=180, # 3.5" HX8357 +# disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R +# disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R +# disp = st7735.ST7735R(spi, rotation=90, bgr=True, width=80, # 0.96" MiniTFT Rev A ST7735R +# disp = st7735.ST7735R(spi, rotation=90, invert=True, width=80, x_offset=26, y_offset=1, # 0.96" MiniTFT Rev B ST7735R +# disp = ssd1351.SSD1351(spi, rotation=180, # 1.5" SSD1351 +# disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351 +# disp = ssd1331.SSD1331(spi, rotation=180, # 0.96" SSD1331 + cs=cs_pin, + dc=dc_pin, + rst=reset_pin, + baudrate=BAUDRATE, + ) +# fmt: on +# pylint: enable=line-too-long + + +def init_button(pin): + button = digitalio.DigitalInOut(pin) + button.switch_to_input() + button.pull = digitalio.Pull.UP + return button + + +class Frame: # pylint: disable=too-few-public-methods + def __init__(self, duration=0): + self.duration = duration + self.image = None + + +class AnimatedGif: + def __init__(self, display, width=None, height=None, folder=None): + self._frame_count = 0 + self._loop = 0 + self._index = 0 + self._duration = 0 + self._gif_files = [] + self._frames = [] + + if width is not None: + self._width = width + else: + self._width = display.width + if height is not None: + self._height = height + else: + self._height = display.height + self.display = display + self.advance_button = init_button(BUTTON_NEXT) + self.back_button = init_button(BUTTON_PREVIOUS) + if folder is not None: + self.load_files(folder) + self.run() + + def advance(self): + self._index = (self._index + 1) % len(self._gif_files) + + def back(self): + self._index = (self._index - 1 + len(self._gif_files)) % len(self._gif_files) + + def load_files(self, folder): + gif_files = [f for f in os.listdir(folder) if f.endswith(".gif")] + for gif_file in gif_files: + gif_file = os.path.join(folder, gif_file) + image = Image.open(gif_file) + # Only add animated Gifs + if image.is_animated: + self._gif_files.append(gif_file) + + print("Found", self._gif_files) + if not self._gif_files: + print("No Gif files found in current folder") + exit() # pylint: disable=consider-using-sys-exit + + def preload(self): + image = Image.open(self._gif_files[self._index]) + print("Loading {}...".format(self._gif_files[self._index])) + if "duration" in image.info: + self._duration = image.info["duration"] + else: + self._duration = 0 + if "loop" in image.info: + self._loop = image.info["loop"] + else: + self._loop = 1 + self._frame_count = image.n_frames + self._frames.clear() + for frame in range(self._frame_count): + image.seek(frame) + # Create blank image for drawing. + # Make sure to create image with mode 'RGB' for full color. + frame_object = Frame(duration=self._duration) + if "duration" in image.info: + frame_object.duration = image.info["duration"] + frame_object.image = ImageOps.pad( # pylint: disable=no-member + image.convert("RGB"), + (self._width, self._height), + method=Image.NEAREST, + color=(0, 0, 0), + centering=(0.5, 0.5), + ) + self._frames.append(frame_object) + + def play(self): + self.preload() + + _prev_advance_btn_val = self.advance_button.value + _prev_back_btn_val = self.back_button.value + # Check if we have loaded any files first + if not self._gif_files: + print("There are no Gif Images loaded to Play") + return False + while True: + for frame_object in self._frames: + start_time = time.monotonic() + self.display.image(frame_object.image) + _cur_advance_btn_val = self.advance_button.value + _cur_back_btn_val = self.back_button.value + if not _cur_advance_btn_val and _prev_advance_btn_val: + self.advance() + return False + if not _cur_back_btn_val and _prev_back_btn_val: + self.back() + return False + + _prev_back_btn_val = _cur_back_btn_val + _prev_advance_btn_val = _cur_advance_btn_val + while time.monotonic() < (start_time + frame_object.duration / 1000): + pass + + if self._loop == 1: + return True + if self._loop > 0: + self._loop -= 1 + + def run(self): + while True: + auto_advance = self.play() + if auto_advance: + self.advance() + + +if disp.rotation % 180 == 90: + disp_height = disp.width # we swap height/width to rotate it to landscape! + disp_width = disp.height +else: + disp_width = disp.width + disp_height = disp.height + +gif_player = AnimatedGif(disp, width=disp_width, height=disp_height, folder=".") From 8cfb0db7d36eb46ef1e2a575b03f5e630bfc2c94 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 18 Sep 2023 16:24:13 -0500 Subject: [PATCH 65/83] "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 4118015..7c87192 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 a85229e4d44541f5e46b2f385de3c82ad86cc944 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 27 Nov 2023 10:12:14 -0800 Subject: [PATCH 66/83] Fix typing for color565 function --- adafruit_rgb_display/rgb.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index 5c906f7..26b6fe0 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -47,14 +47,14 @@ def color565( - r: Union[int, Tuple[int, int, int], List[int]], - g: int = 0, - b: int = 0, + r: Union[int, Tuple[int, int, int], List[int, int, int]], + g: Optional[int] = 0, + b: Optional[int] = 0, ) -> int: """Convert red, green and blue values (0-255) into a 16-bit 565 encoding. As a convenience this is also available in the parent adafruit_rgb_display package namespace.""" - if not isinstance(r, int): # see if the first var is a tuple/list + if isinstance(r, (tuple, list)): # see if the first var is a tuple/list red, g, b = r else: red = r From c89be83fbec7fb9ab852ea45e84f6dd12eca8065 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 27 Nov 2023 10:20:15 -0800 Subject: [PATCH 67/83] Update color565 to just make sure we get what we expect --- adafruit_rgb_display/rgb.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index 26b6fe0..a874201 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -47,7 +47,7 @@ def color565( - r: Union[int, Tuple[int, int, int], List[int, int, int]], + r: Union[int, Tuple[int, int, int], List[int]], g: Optional[int] = 0, b: Optional[int] = 0, ) -> int: @@ -55,7 +55,12 @@ def color565( a convenience this is also available in the parent adafruit_rgb_display package namespace.""" if isinstance(r, (tuple, list)): # see if the first var is a tuple/list - red, g, b = r + if len(r) >= 3: + red, g, b = r + else: + raise ValueError( + "Not enough values to unpack (expected 3, got %d)" % len(r) + ) else: red = r return (red & 0xF8) << 8 | (g & 0xFC) << 3 | b >> 3 From 7ecfffe3deac982f8698e72da7033b836c07ecd5 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Oct 2023 14:30:31 -0500 Subject: [PATCH 68/83] 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 a4c6325cff64fd168738c83ae530d62c0b8d4a5d Mon Sep 17 00:00:00 2001 From: Reza Nasab <49108667+reza-n@users.noreply.github.com> Date: Wed, 27 Dec 2023 00:45:40 -0800 Subject: [PATCH 69/83] Update rgb.py fixing an issue when 4 values are returned instead of r/g/b --- adafruit_rgb_display/rgb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index a874201..c039b34 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -56,7 +56,7 @@ def color565( package namespace.""" if isinstance(r, (tuple, list)): # see if the first var is a tuple/list if len(r) >= 3: - red, g, b = r + red, g, b = r[0:3] else: raise ValueError( "Not enough values to unpack (expected 3, got %d)" % len(r) From 8bac28cc9b58a9a92609f3060da73be10e2decac Mon Sep 17 00:00:00 2001 From: Simon Ludwig Date: Wed, 31 Jul 2024 19:56:04 +0200 Subject: [PATCH 70/83] removed print calls --- adafruit_rgb_display/ssd1331.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/adafruit_rgb_display/ssd1331.py b/adafruit_rgb_display/ssd1331.py index 167afe1..86e0cca 100644 --- a/adafruit_rgb_display/ssd1331.py +++ b/adafruit_rgb_display/ssd1331.py @@ -149,7 +149,5 @@ def write( with self.spi_device as spi: if command is not None: spi.write(bytearray([command])) - print(bytearray([command])) if data is not None: spi.write(data) - print(data) From 2c4d380e552a2cd560e36a500f6ac3f51c8085b0 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 7 Oct 2024 09:24:05 -0500 Subject: [PATCH 71/83] 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 7c87192..1ec3924 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 197da2c37ed9aacfb7fc7ffae7cb84618b31fc11 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 14 Jan 2025 11:32:34 -0600 Subject: [PATCH 72/83] 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: From b55666be6d3a52aacbad9107699eb7190ccb605a Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 10 Feb 2025 11:00:31 -0500 Subject: [PATCH 73/83] Create gc9a01a.py --- adafruit_rgb_display/gc9a01a.py | 145 ++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 adafruit_rgb_display/gc9a01a.py diff --git a/adafruit_rgb_display/gc9a01a.py b/adafruit_rgb_display/gc9a01a.py new file mode 100644 index 0000000..33800f9 --- /dev/null +++ b/adafruit_rgb_display/gc9a01a.py @@ -0,0 +1,145 @@ +# SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries +# +# SPDX-License-Identifier: MIT +""" +`adafruit_rgb_display.gc9a01a` +==================================================== +A simple driver for the GC9A01A-based displays. + +* Author(s): Liz Clark + +Implementation Notes +-------------------- +Adapted from the CircuitPython GC9A01A driver for use with the RGB Display library. +""" +import struct +import busio +import digitalio +from micropython import const +from adafruit_rgb_display.rgb import DisplaySPI + +try: + from typing import Optional +except ImportError: + pass + +__version__ = "0.0.0+auto.0" +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" + +# Command constants +_NOP = const(0x00) +_SWRESET = const(0x01) +_SLPIN = const(0x10) +_SLPOUT = const(0x11) +_PTLON = const(0x12) +_NORON = const(0x13) +_INVOFF = const(0x20) +_INVON = const(0x21) +_DISPOFF = const(0x28) +_DISPON = const(0x29) +_CASET = const(0x2A) +_RASET = const(0x2B) +_RAMWR = const(0x2C) +_RAMRD = const(0x2E) +_MADCTL = const(0x36) +_COLMOD = const(0x3A) +_TEON = const(0x35) + +# Extended command constants +_PWCTR1 = const(0xC3) +_PWCTR2 = const(0xC4) +_PWCTR3 = const(0xC9) +_GMCTRP1 = const(0xF0) +_GMCTRN1 = const(0xF1) +_GMCTRP2 = const(0xF2) +_GMCTRN2 = const(0xF3) + +class GC9A01A(DisplaySPI): + """ + A simple driver for the GC9A01A-based displays. + + >>> import busio + >>> import digitalio + >>> import board + >>> from adafruit_rgb_display import color565 + >>> import adafruit_rgb_display.gc9a01a as gc9a01a + >>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO) + >>> display = gc9a01a.GC9A01A(spi, cs=digitalio.DigitalInOut(board.GPIO0), + ... dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16)) + >>> display.fill(0x7521) + >>> display.pixel(64, 64, 0) + """ + # pylint: disable=too-few-public-methods + + COLUMN_SET = _CASET + PAGE_SET = _RASET + RAM_WRITE = _RAMWR + RAM_READ = _RAMRD + + _INIT = ( + (_SWRESET, None), + (0xFE, None), # Inter Register Enable1 + (0xEF, None), # Inter Register Enable2 + (0xB6, b"\x00\x00"), # Display Function Control + (_MADCTL, b"\x48"), # Memory Access Control + (_COLMOD, b"\x05"), # Interface Pixel Format (16 bits/pixel) + (_PWCTR1, b"\x13"), # Power Control 2 + (_PWCTR2, b"\x13"), # Power Control 3 + (_PWCTR3, b"\x22"), # Power Control 4 + (_GMCTRP1, b"\x45\x09\x08\x08\x26\x2a"), # Set Gamma 1 + (_GMCTRN1, b"\x43\x70\x72\x36\x37\x6f"), # Set Gamma 2 + (_GMCTRP2, b"\x45\x09\x08\x08\x26\x2a"), # Set Gamma 3 + (_GMCTRN2, b"\x43\x70\x72\x36\x37\x6f"), # Set Gamma 4 + (0x66, b"\x3c\x00\xcd\x67\x45\x45\x10\x00\x00\x00"), + (0x67, b"\x00\x3c\x00\x00\x00\x01\x54\x10\x32\x98"), + (0x74, b"\x10\x85\x80\x00\x00\x4e\x00"), + (0x98, b"\x3e\x07"), + (_TEON, None), # Tearing Effect Line ON + (_INVON, None), # Display Inversion ON + (_SLPOUT, None), # Exit Sleep Mode + (_NORON, None), # Normal Display Mode ON + (_DISPON, None), # Display ON + ) + + def __init__( + self, + spi: busio.SPI, + dc: digitalio.DigitalInOut, + cs: digitalio.DigitalInOut, + rst: Optional[digitalio.DigitalInOut] = None, + width: int = 240, + height: int = 240, + baudrate: int = 16000000, + polarity: int = 0, + phase: int = 0, + *, + x_offset: int = 0, + y_offset: int = 0, + rotation: int = 0 + ) -> None: + super().__init__( + spi, + dc, + cs, + rst, + width, + height, + baudrate=baudrate, + polarity=polarity, + phase=phase, + x_offset=x_offset, + y_offset=y_offset, + rotation=rotation, + ) + + def init(self) -> None: + super().init() + cols = struct.pack(">HH", 0, self.width - 1) + rows = struct.pack(">HH", 0, self.height - 1) + + for command, data in ( + (_CASET, cols), + (_RASET, rows), + (_MADCTL, b"\xc0"), # Set rotation to 0 and use RGB + ): + self.write(command, data) From 7d5528f6c6aa45c9493d0c8bf65db4e33328a3e6 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 10 Feb 2025 11:23:56 -0500 Subject: [PATCH 74/83] Update gc9a01a.py --- adafruit_rgb_display/gc9a01a.py | 41 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/adafruit_rgb_display/gc9a01a.py b/adafruit_rgb_display/gc9a01a.py index 33800f9..d556911 100644 --- a/adafruit_rgb_display/gc9a01a.py +++ b/adafruit_rgb_display/gc9a01a.py @@ -77,28 +77,26 @@ class GC9A01A(DisplaySPI): RAM_READ = _RAMRD _INIT = ( - (_SWRESET, None), - (0xFE, None), # Inter Register Enable1 - (0xEF, None), # Inter Register Enable2 - (0xB6, b"\x00\x00"), # Display Function Control - (_MADCTL, b"\x48"), # Memory Access Control - (_COLMOD, b"\x05"), # Interface Pixel Format (16 bits/pixel) - (_PWCTR1, b"\x13"), # Power Control 2 - (_PWCTR2, b"\x13"), # Power Control 3 + (0xFE, b"\x00"), # Inter Register Enable1 + (0xEF, b"\x00"), # Inter Register Enable2 + (0xB6, b"\x00\x00"), # Display Function Control [S1→S360 source, G1→G32 gate] + (_MADCTL, b"\x48"), # Memory Access Control [Invert Row order, invert vertical scan order] + (_COLMOD, b"\x05"), # COLMOD: Pixel Format Set [16 bits/pixel] + (_PWCTR1, b"\x13"), # Power Control 2 [VREG1A = 5.06, VREG1B = 0.68] + (_PWCTR2, b"\x13"), # Power Control 3 [VREG2A = -3.7, VREG2B = 0.68] (_PWCTR3, b"\x22"), # Power Control 4 - (_GMCTRP1, b"\x45\x09\x08\x08\x26\x2a"), # Set Gamma 1 - (_GMCTRN1, b"\x43\x70\x72\x36\x37\x6f"), # Set Gamma 2 - (_GMCTRP2, b"\x45\x09\x08\x08\x26\x2a"), # Set Gamma 3 - (_GMCTRN2, b"\x43\x70\x72\x36\x37\x6f"), # Set Gamma 4 + (_GMCTRP1, b"\x45\x09\x08\x08\x26\x2a"), # SET_GAMMA1 + (_GMCTRN1, b"\x43\x70\x72\x36\x37\x6f"), # SET_GAMMA2 + (_GMCTRP2, b"\x45\x09\x08\x08\x26\x2a"), # SET_GAMMA3 + (_GMCTRN2, b"\x43\x70\x72\x36\x37\x6f"), # SET_GAMMA4 (0x66, b"\x3c\x00\xcd\x67\x45\x45\x10\x00\x00\x00"), (0x67, b"\x00\x3c\x00\x00\x00\x01\x54\x10\x32\x98"), (0x74, b"\x10\x85\x80\x00\x00\x4e\x00"), (0x98, b"\x3e\x07"), - (_TEON, None), # Tearing Effect Line ON - (_INVON, None), # Display Inversion ON - (_SLPOUT, None), # Exit Sleep Mode - (_NORON, None), # Normal Display Mode ON - (_DISPON, None), # Display ON + (_TEON, b"\x00"), # Tearing Effect Line ON [both V-blanking and H-blanking] + (_INVON, b"\x00"), # Display Inversion ON + (_SLPOUT, None), # Sleep Out Mode (with 120ms delay) + (_DISPON, None), # Display ON (with 20ms delay) ) def __init__( @@ -134,12 +132,13 @@ def __init__( def init(self) -> None: super().init() - cols = struct.pack(">HH", 0, self.width - 1) - rows = struct.pack(">HH", 0, self.height - 1) + # Account for offsets in the column and row addressing + cols = struct.pack(">HH", self._X_START, self.width + self._X_START - 1) + rows = struct.pack(">HH", self._Y_START, self.height + self._Y_START - 1) for command, data in ( - (_CASET, cols), - (_RASET, rows), (_MADCTL, b"\xc0"), # Set rotation to 0 and use RGB + (_CASET, b"\x00\x00\x00\xef"), # Column Address Set [Start col = 0, end col = 239] + (_RASET, b"\x00\x00\x00\xef"), # Row Address Set [Start row = 0, end row = 239] ): self.write(command, data) From 67547fadb2e197e32aeaf8dd5bcbcaa21c177baf Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 10 Feb 2025 11:32:10 -0500 Subject: [PATCH 75/83] Update gc9a01a.py --- adafruit_rgb_display/gc9a01a.py | 35 ++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/adafruit_rgb_display/gc9a01a.py b/adafruit_rgb_display/gc9a01a.py index d556911..c882a95 100644 --- a/adafruit_rgb_display/gc9a01a.py +++ b/adafruit_rgb_display/gc9a01a.py @@ -26,11 +26,14 @@ __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" -# Command constants -_NOP = const(0x00) -_SWRESET = const(0x01) -_SLPIN = const(0x10) -_SLPOUT = const(0x11) +# Constants for MADCTL +_MADCTL_MY = const(0x80) # Bottom to top +_MADCTL_MX = const(0x40) # Right to left +_MADCTL_MV = const(0x20) # Reverse Mode +_MADCTL_ML = const(0x10) # LCD refresh Bottom to top +_MADCTL_RGB = const(0x00) # Red-Green-Blue pixel order +_MADCTL_BGR = const(0x08) # Blue-Green-Red pixel order +_MADCTL_MH = const(0x04) # LCD refresh right to left _PTLON = const(0x12) _NORON = const(0x13) _INVOFF = const(0x20) @@ -136,9 +139,19 @@ def init(self) -> None: cols = struct.pack(">HH", self._X_START, self.width + self._X_START - 1) rows = struct.pack(">HH", self._Y_START, self.height + self._Y_START - 1) - for command, data in ( - (_MADCTL, b"\xc0"), # Set rotation to 0 and use RGB - (_CASET, b"\x00\x00\x00\xef"), # Column Address Set [Start col = 0, end col = 239] - (_RASET, b"\x00\x00\x00\xef"), # Row Address Set [Start row = 0, end row = 239] - ): - self.write(command, data) + def init(self) -> None: + """Initialize the display""" + super().init() + + # Initialize display + self.write(_SWRESET) + time.sleep(0.150) # 150ms delay after reset + + # Set addressing mode and color format + self.write(_MADCTL, bytes([_MADCTL_MX | _MADCTL_BGR])) + + # Set addressing windows + self.write(_CASET, b"\x00\x00\x00\xef") # Column Address Set [0-239] + self.write(_RASET, b"\x00\x00\x00\xef") # Row Address Set [0-239] + + time.sleep(0.150) # 150ms delay before turning on display \ No newline at end of file From 9f02995bbca0523adc6453aa2b547159aa262dd7 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 10 Feb 2025 12:31:41 -0500 Subject: [PATCH 76/83] pre-commit, tested --- adafruit_rgb_display/gc9a01a.py | 107 ++++++++++++-------------------- 1 file changed, 39 insertions(+), 68 deletions(-) diff --git a/adafruit_rgb_display/gc9a01a.py b/adafruit_rgb_display/gc9a01a.py index c882a95..4b95604 100644 --- a/adafruit_rgb_display/gc9a01a.py +++ b/adafruit_rgb_display/gc9a01a.py @@ -8,11 +8,10 @@ * Author(s): Liz Clark -Implementation Notes --------------------- -Adapted from the CircuitPython GC9A01A driver for use with the RGB Display library. """ + import struct +import time import busio import digitalio from micropython import const @@ -26,15 +25,9 @@ __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git" -# Constants for MADCTL -_MADCTL_MY = const(0x80) # Bottom to top -_MADCTL_MX = const(0x40) # Right to left -_MADCTL_MV = const(0x20) # Reverse Mode -_MADCTL_ML = const(0x10) # LCD refresh Bottom to top -_MADCTL_RGB = const(0x00) # Red-Green-Blue pixel order -_MADCTL_BGR = const(0x08) # Blue-Green-Red pixel order -_MADCTL_MH = const(0x04) # LCD refresh right to left -_PTLON = const(0x12) +# Command constants +_SWRESET = const(0xFE) +_SLPOUT = const(0x11) _NORON = const(0x13) _INVOFF = const(0x20) _INVON = const(0x21) @@ -46,16 +39,7 @@ _RAMRD = const(0x2E) _MADCTL = const(0x36) _COLMOD = const(0x3A) -_TEON = const(0x35) -# Extended command constants -_PWCTR1 = const(0xC3) -_PWCTR2 = const(0xC4) -_PWCTR3 = const(0xC9) -_GMCTRP1 = const(0xF0) -_GMCTRN1 = const(0xF1) -_GMCTRP2 = const(0xF2) -_GMCTRN2 = const(0xF3) class GC9A01A(DisplaySPI): """ @@ -64,42 +48,40 @@ class GC9A01A(DisplaySPI): >>> import busio >>> import digitalio >>> import board - >>> from adafruit_rgb_display import color565 - >>> import adafruit_rgb_display.gc9a01a as gc9a01a + >>> from adafruit_rgb_display import gc9a01a >>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO) - >>> display = gc9a01a.GC9A01A(spi, cs=digitalio.DigitalInOut(board.GPIO0), - ... dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16)) + >>> display = gc9a01a.GC9A01A(spi, cs=digitalio.DigitalInOut(board.CE0), + ... dc=digitalio.DigitalInOut(board.D25), rst=digitalio.DigitalInOut(board.D27)) >>> display.fill(0x7521) >>> display.pixel(64, 64, 0) """ - # pylint: disable=too-few-public-methods - - COLUMN_SET = _CASET - PAGE_SET = _RASET - RAM_WRITE = _RAMWR - RAM_READ = _RAMRD + _COLUMN_SET = _CASET + _PAGE_SET = _RASET + _RAM_WRITE = _RAMWR + _RAM_READ = _RAMRD _INIT = ( - (0xFE, b"\x00"), # Inter Register Enable1 - (0xEF, b"\x00"), # Inter Register Enable2 - (0xB6, b"\x00\x00"), # Display Function Control [S1→S360 source, G1→G32 gate] - (_MADCTL, b"\x48"), # Memory Access Control [Invert Row order, invert vertical scan order] - (_COLMOD, b"\x05"), # COLMOD: Pixel Format Set [16 bits/pixel] - (_PWCTR1, b"\x13"), # Power Control 2 [VREG1A = 5.06, VREG1B = 0.68] - (_PWCTR2, b"\x13"), # Power Control 3 [VREG2A = -3.7, VREG2B = 0.68] - (_PWCTR3, b"\x22"), # Power Control 4 - (_GMCTRP1, b"\x45\x09\x08\x08\x26\x2a"), # SET_GAMMA1 - (_GMCTRN1, b"\x43\x70\x72\x36\x37\x6f"), # SET_GAMMA2 - (_GMCTRP2, b"\x45\x09\x08\x08\x26\x2a"), # SET_GAMMA3 - (_GMCTRN2, b"\x43\x70\x72\x36\x37\x6f"), # SET_GAMMA4 + (_SWRESET, None), + (0xEF, None), # Inter Register Enable2 + (0xB6, b"\x00\x00"), # Display Function Control + (_MADCTL, b"\x48"), # Memory Access Control - Set to BGR color filter panel + (_COLMOD, b"\x05"), # Interface Pixel Format - 16 bits per pixel + (0xC3, b"\x13"), # Power Control 2 + (0xC4, b"\x13"), # Power Control 3 + (0xC9, b"\x22"), # Power Control 4 + (0xF0, b"\x45\x09\x08\x08\x26\x2a"), # SET_GAMMA1 + (0xF1, b"\x43\x70\x72\x36\x37\x6f"), # SET_GAMMA2 + (0xF2, b"\x45\x09\x08\x08\x26\x2a"), # SET_GAMMA3 + (0xF3, b"\x43\x70\x72\x36\x37\x6f"), # SET_GAMMA4 (0x66, b"\x3c\x00\xcd\x67\x45\x45\x10\x00\x00\x00"), (0x67, b"\x00\x3c\x00\x00\x00\x01\x54\x10\x32\x98"), (0x74, b"\x10\x85\x80\x00\x00\x4e\x00"), (0x98, b"\x3e\x07"), - (_TEON, b"\x00"), # Tearing Effect Line ON [both V-blanking and H-blanking] - (_INVON, b"\x00"), # Display Inversion ON - (_SLPOUT, None), # Sleep Out Mode (with 120ms delay) - (_DISPON, None), # Display ON (with 20ms delay) + (0x35, None), # Tearing Effect Line ON + (_INVON, None), # Display Inversion ON + (_SLPOUT, None), # Sleep Out Mode + (_NORON, None), # Normal Display Mode ON + (_DISPON, None), # Display ON ) def __init__( @@ -110,7 +92,7 @@ def __init__( rst: Optional[digitalio.DigitalInOut] = None, width: int = 240, height: int = 240, - baudrate: int = 16000000, + baudrate: int = 24000000, polarity: int = 0, phase: int = 0, *, @@ -134,24 +116,13 @@ def __init__( ) def init(self) -> None: + """Initialize the display.""" + if self.rst: + self.rst.value = 0 + time.sleep(0.05) + self.rst.value = 1 + time.sleep(0.05) + super().init() - # Account for offsets in the column and row addressing - cols = struct.pack(">HH", self._X_START, self.width + self._X_START - 1) - rows = struct.pack(">HH", self._Y_START, self.height + self._Y_START - 1) - - def init(self) -> None: - """Initialize the display""" - super().init() - - # Initialize display - self.write(_SWRESET) - time.sleep(0.150) # 150ms delay after reset - - # Set addressing mode and color format - self.write(_MADCTL, bytes([_MADCTL_MX | _MADCTL_BGR])) - - # Set addressing windows - self.write(_CASET, b"\x00\x00\x00\xef") # Column Address Set [0-239] - self.write(_RASET, b"\x00\x00\x00\xef") # Row Address Set [0-239] - - time.sleep(0.150) # 150ms delay before turning on display \ No newline at end of file + + self._block(0, 0, self.width - 1, self.height - 1) From 8ce10d5951aa86e722b301109c5a72c8c91075d3 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 10 Feb 2025 12:34:06 -0500 Subject: [PATCH 77/83] lint --- adafruit_rgb_display/gc9a01a.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/adafruit_rgb_display/gc9a01a.py b/adafruit_rgb_display/gc9a01a.py index 4b95604..d7b28cb 100644 --- a/adafruit_rgb_display/gc9a01a.py +++ b/adafruit_rgb_display/gc9a01a.py @@ -10,7 +10,6 @@ """ -import struct import time import busio import digitalio @@ -83,7 +82,7 @@ class GC9A01A(DisplaySPI): (_NORON, None), # Normal Display Mode ON (_DISPON, None), # Display ON ) - + # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, spi: busio.SPI, From 664dcd28144f05df5833a23003a73d2fc089b2a1 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 10 Feb 2025 12:36:42 -0500 Subject: [PATCH 78/83] oy vey, black --- adafruit_rgb_display/gc9a01a.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_rgb_display/gc9a01a.py b/adafruit_rgb_display/gc9a01a.py index d7b28cb..f360cc0 100644 --- a/adafruit_rgb_display/gc9a01a.py +++ b/adafruit_rgb_display/gc9a01a.py @@ -82,6 +82,7 @@ class GC9A01A(DisplaySPI): (_NORON, None), # Normal Display Mode ON (_DISPON, None), # Display ON ) + # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, From f56a9eeb4d7fdc42787d1ecb3882e86155ac0d02 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 10 Feb 2025 16:06:29 -0500 Subject: [PATCH 79/83] remove _block --- adafruit_rgb_display/gc9a01a.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/adafruit_rgb_display/gc9a01a.py b/adafruit_rgb_display/gc9a01a.py index f360cc0..613bc7a 100644 --- a/adafruit_rgb_display/gc9a01a.py +++ b/adafruit_rgb_display/gc9a01a.py @@ -124,5 +124,3 @@ def init(self) -> None: time.sleep(0.05) super().init() - - self._block(0, 0, self.width - 1, self.height - 1) From 8fb075c6b85699be49ab62ea8150dbd23652e420 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 29 Apr 2025 17:32:07 -0500 Subject: [PATCH 80/83] use ruff --- .gitattributes | 11 + .pre-commit-config.yaml | 43 +- .pylintrc | 399 ------------------ README.rst | 6 +- adafruit_rgb_display/__init__.py | 1 + adafruit_rgb_display/gc9a01a.py | 4 +- adafruit_rgb_display/hx8353.py | 5 +- adafruit_rgb_display/hx8357.py | 17 +- adafruit_rgb_display/ili9341.py | 7 +- adafruit_rgb_display/rgb.py | 60 +-- adafruit_rgb_display/s6d02a1.py | 4 +- adafruit_rgb_display/ssd1331.py | 12 +- adafruit_rgb_display/ssd1351.py | 7 +- adafruit_rgb_display/st7735.py | 11 +- adafruit_rgb_display/st7789.py | 3 +- docs/api.rst | 3 + docs/conf.py | 10 +- .../rgb_display_eyespi_beret_animated_gif.py | 29 +- examples/rgb_display_fbcp.py | 22 +- examples/rgb_display_hx8357test.py | 11 +- examples/rgb_display_ili9341test.py | 12 +- examples/rgb_display_minipitftstats.py | 7 +- examples/rgb_display_minipitfttest.py | 4 +- examples/rgb_display_pillow_animated_gif.py | 27 +- examples/rgb_display_pillow_bonnet_buttons.py | 20 +- examples/rgb_display_pillow_demo.py | 21 +- examples/rgb_display_pillow_image.py | 17 +- examples/rgb_display_pillow_stats.py | 20 +- examples/rgb_display_simpletest.py | 11 +- ruff.toml | 105 +++++ 30 files changed, 303 insertions(+), 606 deletions(-) create mode 100644 .gitattributes delete mode 100644 .pylintrc create mode 100644 ruff.toml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..21c125c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense + +.py text eol=lf +.rst text eol=lf +.txt text eol=lf +.yaml text eol=lf +.toml text eol=lf +.license text eol=lf +.md text eol=lf diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 179cf07..ff19dde 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,42 +1,21 @@ -# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò +# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries # # SPDX-License-Identifier: Unlicense repos: - - repo: https://github.com/python/black - rev: 23.3.0 - hooks: - - id: black - - repo: https://github.com/fsfe/reuse-tool - rev: v1.1.2 - hooks: - - id: reuse - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/pycqa/pylint - rev: v2.17.4 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.4 hooks: - - id: pylint - name: pylint (library code) - types: [python] - args: - - --disable=consider-using-f-string,duplicate-code - exclude: "^(docs/|examples/|tests/|setup.py$)" - - id: pylint - name: pylint (example code) - description: Run pylint rules on "examples/*.py" files - types: [python] - files: "^examples/" - args: - - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code - - id: pylint - name: pylint (test code) - description: Run pylint rules on "tests/*.py" files - types: [python] - files: "^tests/" - args: - - --disable=missing-docstring,consider-using-f-string,duplicate-code + - id: ruff-format + - id: ruff + args: ["--fix"] + - repo: https://github.com/fsfe/reuse-tool + rev: v3.0.1 + hooks: + - id: reuse diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index f945e92..0000000 --- a/.pylintrc +++ /dev/null @@ -1,399 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries -# -# SPDX-License-Identifier: Unlicense - -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist= - -# Add files or directories to the ignore-list. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the ignore-list. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. -jobs=1 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins=pylint.extensions.no_self_use - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -# disable=import-error,raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,deprecated-str-translate-call -disable=raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,import-error,pointless-string-statement,unspecified-encoding - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable= - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio).You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging - - -[SPELLING] - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -# notes=FIXME,XXX,TODO -notes=FIXME,XXX - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules=board - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_,_cb - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,future.builtins - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -# expected-line-ending-format= -expected-line-ending-format=LF - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=100 - -# Maximum number of lines in a module -max-module-lines=1000 - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=yes - -# Minimum lines number of a similarity. -min-similarity-lines=12 - - -[BASIC] - -# Regular expression matching correct argument names -argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct attribute names -attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Regular expression matching correct class attribute names -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Regular expression matching correct class names -# class-rgx=[A-Z_][a-zA-Z0-9]+$ -class-rgx=[A-Z_][a-zA-Z0-9_]+$ - -# Regular expression matching correct constant names -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Regular expression matching correct function names -function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Good variable names which should always be accepted, separated by a comma -# good-names=i,j,k,ex,Run,_ -good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_ - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# Regular expression matching correct inline iteration names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Regular expression matching correct method names -method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Regular expression matching correct variable names -variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=optparse,tkinter.tix - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict,_fields,_replace,_source,_make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Maximum number of attributes for a class (see R0902). -# max-attributes=7 -max-attributes=11 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of statements in function / method body -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=1 - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=builtins.Exception diff --git a/README.rst b/README.rst index 9a7c211..63ce6e5 100644 --- a/README.rst +++ b/README.rst @@ -13,9 +13,9 @@ Introduction :target: https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display/actions/ :alt: Build Status -.. image:: https://img.shields.io/badge/code%20style-black-000000.svg - :target: https://github.com/psf/black - :alt: Code Style: Black +.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json + :target: https://github.com/astral-sh/ruff + :alt: Code Style: Ruff Port of display drivers from https://github.com/adafruit/micropython-adafruit-rgb-display to Adafruit CircuitPython for use on Adafruit's SAMD21-based and other CircuitPython boards. diff --git a/adafruit_rgb_display/__init__.py b/adafruit_rgb_display/__init__.py index 825637e..c69a8da 100644 --- a/adafruit_rgb_display/__init__.py +++ b/adafruit_rgb_display/__init__.py @@ -3,4 +3,5 @@ # SPDX-License-Identifier: MIT """Auto imports for Adafruit_CircuitPython_RGB_Display""" + from adafruit_rgb_display.rgb import color565 diff --git a/adafruit_rgb_display/gc9a01a.py b/adafruit_rgb_display/gc9a01a.py index 613bc7a..e899004 100644 --- a/adafruit_rgb_display/gc9a01a.py +++ b/adafruit_rgb_display/gc9a01a.py @@ -11,9 +11,11 @@ """ import time + import busio import digitalio from micropython import const + from adafruit_rgb_display.rgb import DisplaySPI try: @@ -98,7 +100,7 @@ def __init__( *, x_offset: int = 0, y_offset: int = 0, - rotation: int = 0 + rotation: int = 0, ) -> None: super().__init__( spi, diff --git a/adafruit_rgb_display/hx8353.py b/adafruit_rgb_display/hx8353.py index 2aaf712..d1da61c 100644 --- a/adafruit_rgb_display/hx8353.py +++ b/adafruit_rgb_display/hx8353.py @@ -11,13 +11,16 @@ * Author(s): Radomir Dopieralski, Michael McWethy, Matt Land """ + from micropython import const + from adafruit_rgb_display.rgb import DisplaySPI try: from typing import Optional - import digitalio + import busio + import digitalio except ImportError: pass diff --git a/adafruit_rgb_display/hx8357.py b/adafruit_rgb_display/hx8357.py index dfb9e2f..432705e 100755 --- a/adafruit_rgb_display/hx8357.py +++ b/adafruit_rgb_display/hx8357.py @@ -11,13 +11,16 @@ * Author(s): Melissa LeBlanc-Williams, Matt Land """ + from micropython import const + from adafruit_rgb_display.rgb import DisplaySPI try: from typing import Optional - import digitalio + import busio + import digitalio except ImportError: pass @@ -72,21 +75,21 @@ class HX8357(DisplaySPI): _RAM_READ = _RAMRD _INIT = ( (_SWRESET, None), - (_SETC, b"\xFF\x83\x57"), + (_SETC, b"\xff\x83\x57"), (_SETRGB, b"\x80\x00\x06\x06"), # 0x80 enables SDO pin (0x00 disables) (_SETCOM, b"\x25"), # -1.52V (_SETOSC, b"\x68"), # Normal mode 70Hz, Idle mode 55 Hz (_SETPANEL, b"\x05"), # BGR, Gate direction swapped - (_SETPWR1, b"\x00\x15\x1C\x1C\x83\xAA"), # Not deep standby BT VSPR VSNR AP - (_SETSTBA, b"\x50\x50\x01\x3C\x1E\x08"), # OPON normal OPON idle STBA GEN + (_SETPWR1, b"\x00\x15\x1c\x1c\x83\xaa"), # Not deep standby BT VSPR VSNR AP + (_SETSTBA, b"\x50\x50\x01\x3c\x1e\x08"), # OPON normal OPON idle STBA GEN ( _SETCYC, - b"\x02\x40\x00\x2A\x2A\x0D\x78", + b"\x02\x40\x00\x2a\x2a\x0d\x78", ), # NW 0x02 RTN DIV DUM DUM GDON GDOFF ( _SETGAMMA, - b"\x02\x0A\x11\x1d\x23\x35\x41\x4b\x4b\x42\x3A\x27\x1B\x08\x09\x03\x02" - b"\x0A\x11\x1d\x23\x35\x41\x4b\x4b\x42\x3A\x27\x1B\x08\x09\x03\x00\x01", + b"\x02\x0a\x11\x1d\x23\x35\x41\x4b\x4b\x42\x3a\x27\x1b\x08\x09\x03\x02" + b"\x0a\x11\x1d\x23\x35\x41\x4b\x4b\x42\x3a\x27\x1b\x08\x09\x03\x00\x01", ), (_COLMOD, b"\x55"), # 16 bit (_MADCTL, b"\xc0"), diff --git a/adafruit_rgb_display/ili9341.py b/adafruit_rgb_display/ili9341.py index bb90093..3e79787 100644 --- a/adafruit_rgb_display/ili9341.py +++ b/adafruit_rgb_display/ili9341.py @@ -11,14 +11,16 @@ * Author(s): Radomir Dopieralski, Michael McWethy, Matt Land """ + import struct from adafruit_rgb_display.rgb import DisplaySPI try: from typing import Optional - import digitalio + import busio + import digitalio except ImportError: pass @@ -110,7 +112,8 @@ def __init__( # pylint: enable-msg=too-many-arguments def scroll( - self, dy: Optional[int] = None # pylint: disable-msg=invalid-name + self, + dy: Optional[int] = None, # pylint: disable-msg=invalid-name ) -> Optional[int]: """Scroll the display by delta y""" if dy is None: diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index c039b34..62f53e3 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -16,10 +16,10 @@ import time try: - from typing import Optional, Union, Tuple, List, Any, ByteString - import digitalio - import busio + from typing import Any, ByteString, List, Optional, Tuple, Union + import busio + import digitalio from circuitpython_typing.pil import Image except ImportError: pass @@ -58,9 +58,7 @@ def color565( if len(r) >= 3: red, g, b = r[0:3] else: - raise ValueError( - "Not enough values to unpack (expected 3, got %d)" % len(r) - ) + raise ValueError("Not enough values to unpack (expected 3, got %d)" % len(r)) else: red = r return (red & 0xF8) << 8 | (g & 0xFC) << 3 | b >> 3 @@ -71,11 +69,7 @@ def image_to_data(image: Image) -> Any: # NumPy is much faster at doing this. NumPy code provided by: # Keith (https://www.blogger.com/profile/02555547344016007163) data = numpy.array(image.convert("RGB")).astype("uint16") - color = ( - ((data[:, :, 0] & 0xF8) << 8) - | ((data[:, :, 1] & 0xFC) << 3) - | (data[:, :, 2] >> 3) - ) + color = ((data[:, :, 0] & 0xF8) << 8) | ((data[:, :, 1] & 0xFC) << 3) | (data[:, :, 2] >> 3) return numpy.dstack(((color >> 8) & 0xFF, color & 0xFF)).flatten().tolist() @@ -138,14 +132,12 @@ class Display: # pylint: disable-msg=no-member def __init__(self, width: int, height: int, rotation: int) -> None: self.width = width self.height = height - if rotation not in (0, 90, 180, 270): + if rotation not in {0, 90, 180, 270}: raise ValueError("Rotation must be 0/90/180/270") self._rotation = rotation self.init() - def write( - self, command: Optional[int] = None, data: Optional[ByteString] = None - ) -> None: + def write(self, command: Optional[int] = None, data: Optional[ByteString] = None) -> None: """Abstract method""" raise NotImplementedError() @@ -163,12 +155,8 @@ def _block( self, x0: int, y0: int, x1: int, y1: int, data: Optional[ByteString] = None ) -> Optional[ByteString]: """Read or write a block of data.""" - self.write( - self._COLUMN_SET, self._encode_pos(x0 + self._X_START, x1 + self._X_START) - ) - self.write( - self._PAGE_SET, self._encode_pos(y0 + self._Y_START, y1 + self._Y_START) - ) + self.write(self._COLUMN_SET, self._encode_pos(x0 + self._X_START, x1 + self._X_START)) + self.write(self._PAGE_SET, self._encode_pos(y0 + self._Y_START, y1 + self._Y_START)) if data is None: size = struct.calcsize(self._DECODE_PIXEL) return self.read(self._RAM_READ, (x1 - x0 + 1) * (y1 - y0 + 1) * size) @@ -189,9 +177,7 @@ def _decode_pixel(self, data: Union[bytes, Union[bytearray, memoryview]]) -> int """Decode bytes into a pixel color.""" return color565(*struct.unpack(self._DECODE_PIXEL, data)) - def pixel( - self, x: int, y: int, color: Optional[Union[int, Tuple]] = None - ) -> Optional[int]: + def pixel(self, x: int, y: int, color: Optional[Union[int, Tuple]] = None) -> Optional[int]: """Read or write a pixel at a given position.""" if color is None: return self._decode_pixel(self._block(x, y, x, y)) # type: ignore[arg-type] @@ -212,19 +198,15 @@ def image( the supplied origin.""" if rotation is None: rotation = self.rotation - if not img.mode in ("RGB", "RGBA"): + if not img.mode in {"RGB", "RGBA"}: raise ValueError("Image must be in mode RGB or RGBA") - if rotation not in (0, 90, 180, 270): + if rotation not in {0, 90, 180, 270}: raise ValueError("Rotation must be 0/90/180/270") if rotation != 0: img = img.rotate(rotation, expand=True) imwidth, imheight = img.size if x + imwidth > self.width or y + imheight > self.height: - raise ValueError( - "Image must not exceed dimensions of display ({0}x{1}).".format( - self.width, self.height - ) - ) + raise ValueError(f"Image must not exceed dimensions of display ({self.width}x{self.height}).") if numpy: pixels = bytes(image_to_data(img)) else: @@ -238,9 +220,7 @@ def image( self._block(x, y, x + imwidth - 1, y + imheight - 1, pixels) # pylint: disable-msg=too-many-arguments - def fill_rectangle( - self, x: int, y: int, width: int, height: int, color: Union[int, Tuple] - ) -> None: + def fill_rectangle(self, x: int, y: int, width: int, height: int, color: Union[int, Tuple]) -> None: """Draw a rectangle at specified position with specified width and height, and fill it with the specified color.""" x = min(self.width - 1, max(0, x)) @@ -277,7 +257,7 @@ def rotation(self) -> int: @rotation.setter def rotation(self, val: int) -> None: - if val not in (0, 90, 180, 270): + if val not in {0, 90, 180, 270}: raise ValueError("Rotation must be 0/90/180/270") self._rotation = val @@ -300,11 +280,9 @@ def __init__( *, x_offset: int = 0, y_offset: int = 0, - rotation: int = 0 + rotation: int = 0, ): - self.spi_device = spi_device.SPIDevice( - spi, cs, baudrate=baudrate, polarity=polarity, phase=phase - ) + self.spi_device = spi_device.SPIDevice(spi, cs, baudrate=baudrate, polarity=polarity, phase=phase) self.dc_pin = dc self.rst = rst self.dc_pin.switch_to_output(value=0) @@ -327,9 +305,7 @@ def reset(self) -> None: time.sleep(0.050) # 50 milliseconds # pylint: disable=no-member - def write( - self, command: Optional[int] = None, data: Optional[ByteString] = None - ) -> None: + def write(self, command: Optional[int] = None, data: Optional[ByteString] = None) -> None: """SPI write to the device: commands and data""" if command is not None: self.dc_pin.value = 0 diff --git a/adafruit_rgb_display/s6d02a1.py b/adafruit_rgb_display/s6d02a1.py index 568cdec..06b1c3d 100644 --- a/adafruit_rgb_display/s6d02a1.py +++ b/adafruit_rgb_display/s6d02a1.py @@ -13,12 +13,14 @@ """ from micropython import const + from adafruit_rgb_display.rgb import DisplaySPI try: from typing import Optional - import digitalio + import busio + import digitalio except ImportError: pass diff --git a/adafruit_rgb_display/ssd1331.py b/adafruit_rgb_display/ssd1331.py index 86e0cca..8f90848 100644 --- a/adafruit_rgb_display/ssd1331.py +++ b/adafruit_rgb_display/ssd1331.py @@ -13,12 +13,14 @@ """ from micropython import const + from adafruit_rgb_display.rgb import DisplaySPI try: - from typing import Optional, ByteString - import digitalio + from typing import ByteString, Optional + import busio + import digitalio except ImportError: pass @@ -125,7 +127,7 @@ def __init__( polarity: int = 0, phase: int = 0, *, - rotation: int = 0 + rotation: int = 0, ) -> None: super().__init__( spi, @@ -141,9 +143,7 @@ def __init__( ) # pylint: disable=no-member - def write( - self, command: Optional[int] = None, data: Optional[ByteString] = None - ) -> None: + def write(self, command: Optional[int] = None, data: Optional[ByteString] = None) -> None: """write procedure specific to SSD1331""" self.dc_pin.value = command is None with self.spi_device as spi: diff --git a/adafruit_rgb_display/ssd1351.py b/adafruit_rgb_display/ssd1351.py index 03e58ab..3208289 100644 --- a/adafruit_rgb_display/ssd1351.py +++ b/adafruit_rgb_display/ssd1351.py @@ -11,13 +11,16 @@ * Author(s): Radomir Dopieralski, Michael McWethy, Matt Land """ + from micropython import const + from adafruit_rgb_display.rgb import DisplaySPI try: from typing import Optional - import digitalio + import busio + import digitalio except ImportError: pass @@ -119,7 +122,7 @@ def __init__( *, x_offset: int = 0, y_offset: int = 0, - rotation: int = 0 + rotation: int = 0, ): super().__init__( spi, diff --git a/adafruit_rgb_display/st7735.py b/adafruit_rgb_display/st7735.py index 0191a15..4582f91 100644 --- a/adafruit_rgb_display/st7735.py +++ b/adafruit_rgb_display/st7735.py @@ -11,15 +11,18 @@ * Author(s): Radomir Dopieralski, Michael McWethy, Matt Land """ + import struct from micropython import const + from adafruit_rgb_display.rgb import DisplaySPI try: - from typing import Optional, Tuple, ByteString, Union - import digitalio + from typing import ByteString, Optional, Tuple, Union + import busio + import digitalio except ImportError: pass @@ -179,11 +182,11 @@ class ST7735R(ST7735): (_INVOFF, None), ( _GMCTRP1, - b"\x02\x1c\x07\x12\x37\x32\x29\x2d" b"\x29\x25\x2B\x39\x00\x01\x03\x10", + b"\x02\x1c\x07\x12\x37\x32\x29\x2d" b"\x29\x25\x2b\x39\x00\x01\x03\x10", ), # Gamma ( _GMCTRN1, - b"\x03\x1d\x07\x06\x2E\x2C\x29\x2D" b"\x2E\x2E\x37\x3F\x00\x00\x02\x10", + b"\x03\x1d\x07\x06\x2e\x2c\x29\x2d" b"\x2e\x2e\x37\x3f\x00\x00\x02\x10", ), ) diff --git a/adafruit_rgb_display/st7789.py b/adafruit_rgb_display/st7789.py index 3fcfc43..75f300e 100644 --- a/adafruit_rgb_display/st7789.py +++ b/adafruit_rgb_display/st7789.py @@ -17,6 +17,7 @@ import busio import digitalio from micropython import const + from adafruit_rgb_display.rgb import DisplaySPI try: @@ -116,7 +117,7 @@ def __init__( *, x_offset: int = 0, y_offset: int = 0, - rotation: int = 0 + rotation: int = 0, ) -> None: super().__init__( spi, diff --git a/docs/api.rst b/docs/api.rst index f5219f6..0303cb6 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1,6 +1,9 @@ .. If you created a package, create one automodule per module in the package. +API Reference +############# + .. automodule:: adafruit_rgb_display.rgb :members: diff --git a/docs/conf.py b/docs/conf.py index 1ec3924..6ad6c55 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,12 +1,10 @@ -# -*- coding: utf-8 -*- - # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # # SPDX-License-Identifier: MIT +import datetime import os import sys -import datetime sys.path.insert(0, os.path.abspath("..")) @@ -48,11 +46,7 @@ project = "Adafruit RGB_Display Library" creation_year = "2017" current_year = str(datetime.datetime.now().year) -year_duration = ( - current_year - if current_year == creation_year - else creation_year + " - " + current_year -) +year_duration = current_year if current_year == creation_year else creation_year + " - " + current_year copyright = year_duration + " Michale McWethy" author = "Michale McWethy" diff --git a/examples/rgb_display_eyespi_beret_animated_gif.py b/examples/rgb_display_eyespi_beret_animated_gif.py index 2ac205b..b5cab34 100644 --- a/examples/rgb_display_eyespi_beret_animated_gif.py +++ b/examples/rgb_display_eyespi_beret_animated_gif.py @@ -19,18 +19,23 @@ Author(s): Melissa LeBlanc-Williams for Adafruit Industries Mike Mallett """ + import os import time -import digitalio + import board -from PIL import Image, ImageOps +import digitalio import numpy # pylint: disable=unused-import -from adafruit_rgb_display import ili9341 -from adafruit_rgb_display import st7789 # pylint: disable=unused-import -from adafruit_rgb_display import hx8357 # pylint: disable=unused-import -from adafruit_rgb_display import st7735 # pylint: disable=unused-import -from adafruit_rgb_display import ssd1351 # pylint: disable=unused-import -from adafruit_rgb_display import ssd1331 # pylint: disable=unused-import +from PIL import Image, ImageOps + +from adafruit_rgb_display import ( + hx8357, # pylint: disable=unused-import + ili9341, + ssd1331, # pylint: disable=unused-import + ssd1351, # pylint: disable=unused-import + st7735, # pylint: disable=unused-import + st7789, # pylint: disable=unused-import +) # Button pins for EYESPI Pi Beret BUTTON_NEXT = board.D5 @@ -67,7 +72,7 @@ # disp = st7735.ST7735R(spi, rotation=90, # 1.8" ST7735R # disp = st7735.ST7735R(spi, rotation=270, height=128, x_offset=2, y_offset=3, # 1.44" ST7735R # disp = st7735.ST7735R(spi, rotation=90, bgr=True, width=80, # 0.96" MiniTFT Rev A ST7735R -# disp = st7735.ST7735R(spi, rotation=90, invert=True, width=80, x_offset=26, y_offset=1, # 0.96" MiniTFT Rev B ST7735R +# disp = st7735.ST7735R(spi, rotation=90, invert=True, width=80, x_offset=26, y_offset=1, # 0.96" MiniTFT Rev B ST7735R # noqa: E501 # disp = ssd1351.SSD1351(spi, rotation=180, # 1.5" SSD1351 # disp = ssd1351.SSD1351(spi, height=96, y_offset=32, rotation=180, # 1.27" SSD1351 # disp = ssd1331.SSD1331(spi, rotation=180, # 0.96" SSD1331 @@ -126,7 +131,7 @@ def back(self): def load_files(self, folder): gif_files = [f for f in os.listdir(folder) if f.endswith(".gif")] for gif_file in gif_files: - gif_file = os.path.join(folder, gif_file) + gif_file = os.path.join(folder, gif_file) # noqa: PLW2901, loop var overwrite image = Image.open(gif_file) # Only add animated Gifs if image.is_animated: @@ -135,11 +140,11 @@ def load_files(self, folder): print("Found", self._gif_files) if not self._gif_files: print("No Gif files found in current folder") - exit() # pylint: disable=consider-using-sys-exit + exit() # noqa: PLR1722, use sys.exit def preload(self): image = Image.open(self._gif_files[self._index]) - print("Loading {}...".format(self._gif_files[self._index])) + print(f"Loading {self._gif_files[self._index]}...") if "duration" in image.info: self._duration = image.info["duration"] else: diff --git a/examples/rgb_display_fbcp.py b/examples/rgb_display_fbcp.py index 63b210e..910d31b 100644 --- a/examples/rgb_display_fbcp.py +++ b/examples/rgb_display_fbcp.py @@ -1,14 +1,16 @@ # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT -import time -import os import fcntl import mmap +import os import struct -import digitalio +import time + import board +import digitalio from PIL import Image, ImageDraw + from adafruit_rgb_display import st7789 # definitions from linux/fb.h @@ -52,16 +54,12 @@ def __init__(self, dev): "8I12I16I4I", fcntl.ioctl(self.fbfd, FBIOGET_VSCREENINFO, " " * ((8 + 12 + 16 + 4) * 4)), ) - finfo = struct.unpack( - "16cL4I3HI", fcntl.ioctl(self.fbfd, FBIOGET_FSCREENINFO, " " * 48) - ) + finfo = struct.unpack("16cL4I3HI", fcntl.ioctl(self.fbfd, FBIOGET_FSCREENINFO, " " * 48)) bytes_per_pixel = (vinfo[6] + 7) // 8 screensize = vinfo[0] * vinfo[1] * bytes_per_pixel - fbp = mmap.mmap( - self.fbfd, screensize, flags=mmap.MAP_SHARED, prot=mmap.PROT_READ - ) + fbp = mmap.mmap(self.fbfd, screensize, flags=mmap.MAP_SHARED, prot=mmap.PROT_READ) self.fbp = fbp self.xres = vinfo[0] @@ -93,7 +91,7 @@ def blank(self, blank): fcntl.ioctl(self.fbfd, FBIOBLANK, FB_BLANK_POWERDOWN) else: fcntl.ioctl(self.fbfd, FBIOBLANK, FB_BLANK_UNBLANK) - except IOError: + except OSError: pass def __str__(self): @@ -122,9 +120,9 @@ def __str__(self): type_name = type_list[self.type] return ( - 'mode "%sx%s"\n' % (self.xres, self.yres) + 'mode "%sx%s"\n' % (self.xres, self.yres) # noqa: UP031 + " nonstd %s\n" % self.nonstd - + " rgba %s/%s,%s/%s,%s/%s,%s/%s\n" + + " rgba %s/%s,%s/%s,%s/%s,%s/%s\n" # noqa: UP031 % ( self.red.length, self.red.offset, diff --git a/examples/rgb_display_hx8357test.py b/examples/rgb_display_hx8357test.py index 83036c8..12eca84 100644 --- a/examples/rgb_display_hx8357test.py +++ b/examples/rgb_display_hx8357test.py @@ -4,13 +4,14 @@ # Quick test of 3.5" TFT FeatherWing (HX8357) with Feather M0 or M4 # Will fill the TFT black and put a red pixel in the center, wait 2 seconds, # then fill the screen blue (with no pixel), wait 2 seconds, and repeat. -import time import random -import digitalio +import time + import board +import digitalio -from adafruit_rgb_display.rgb import color565 from adafruit_rgb_display import hx8357 +from adafruit_rgb_display.rgb import color565 # Configuration for CS and DC pins (these are TFT FeatherWing defaults): cs_pin = digitalio.DigitalInOut(board.D9) @@ -37,8 +38,6 @@ # Pause 2 seconds. time.sleep(2) # Clear the screen a random color - display.fill( - color565(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) - ) + display.fill(color565(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))) # Pause 2 seconds. time.sleep(2) diff --git a/examples/rgb_display_ili9341test.py b/examples/rgb_display_ili9341test.py index 38ba796..2fe3f0f 100644 --- a/examples/rgb_display_ili9341test.py +++ b/examples/rgb_display_ili9341test.py @@ -4,15 +4,15 @@ # Quick test of TFT FeatherWing (ILI9341) with Feather M0 or M4 # Will fill the TFT black and put a red pixel in the center, wait 2 seconds, # then fill the screen blue (with no pixel), wait 2 seconds, and repeat. -import time import random +import time + +import board import busio import digitalio -import board -from adafruit_rgb_display.rgb import color565 from adafruit_rgb_display import ili9341 - +from adafruit_rgb_display.rgb import color565 # Configuratoin for CS and DC pins (these are FeatherWing defaults on M0/M4): cs_pin = digitalio.DigitalInOut(board.D9) @@ -39,8 +39,6 @@ # Pause 2 seconds. time.sleep(2) # Clear the screen a random color - display.fill( - color565(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) - ) + display.fill(color565(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))) # Pause 2 seconds. time.sleep(2) diff --git a/examples/rgb_display_minipitftstats.py b/examples/rgb_display_minipitftstats.py index 1f625ed..48c480f 100644 --- a/examples/rgb_display_minipitftstats.py +++ b/examples/rgb_display_minipitftstats.py @@ -3,13 +3,14 @@ # -*- coding: utf-8 -*- -import time import subprocess -import digitalio +import time + import board +import digitalio from PIL import Image, ImageDraw, ImageFont -from adafruit_rgb_display import st7789 +from adafruit_rgb_display import st7789 # Configuration for CS and DC pins (these are FeatherWing defaults on M0/M4): cs_pin = digitalio.DigitalInOut(board.CE0) diff --git a/examples/rgb_display_minipitfttest.py b/examples/rgb_display_minipitfttest.py index c418229..eeaab5d 100644 --- a/examples/rgb_display_minipitfttest.py +++ b/examples/rgb_display_minipitfttest.py @@ -1,11 +1,11 @@ # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT -import digitalio import board +import digitalio -from adafruit_rgb_display.rgb import color565 from adafruit_rgb_display import st7789 +from adafruit_rgb_display.rgb import color565 # Configuration for CS and DC pins for Raspberry Pi cs_pin = digitalio.DigitalInOut(board.CE0) diff --git a/examples/rgb_display_pillow_animated_gif.py b/examples/rgb_display_pillow_animated_gif.py index cc3a628..701d762 100644 --- a/examples/rgb_display_pillow_animated_gif.py +++ b/examples/rgb_display_pillow_animated_gif.py @@ -15,18 +15,23 @@ Author(s): Melissa LeBlanc-Williams for Adafruit Industries Mike Mallett """ + import os import time -import digitalio + import board -from PIL import Image, ImageOps +import digitalio import numpy # pylint: disable=unused-import -from adafruit_rgb_display import ili9341 -from adafruit_rgb_display import st7789 # pylint: disable=unused-import -from adafruit_rgb_display import hx8357 # pylint: disable=unused-import -from adafruit_rgb_display import st7735 # pylint: disable=unused-import -from adafruit_rgb_display import ssd1351 # pylint: disable=unused-import -from adafruit_rgb_display import ssd1331 # pylint: disable=unused-import +from PIL import Image, ImageOps + +from adafruit_rgb_display import ( + hx8357, # pylint: disable=unused-import + ili9341, + ssd1331, # pylint: disable=unused-import + ssd1351, # pylint: disable=unused-import + st7735, # pylint: disable=unused-import + st7789, # pylint: disable=unused-import +) # Change to match your display BUTTON_NEXT = board.D17 @@ -90,7 +95,7 @@ def back(self): def load_files(self, folder): gif_files = [f for f in os.listdir(folder) if f.endswith(".gif")] for gif_file in gif_files: - gif_file = os.path.join(folder, gif_file) + gif_file = os.path.join(folder, gif_file) # noqa: PLW2901, loop var overwrite image = Image.open(gif_file) # Only add animated Gifs if image.is_animated: @@ -99,11 +104,11 @@ def load_files(self, folder): print("Found", self._gif_files) if not self._gif_files: print("No Gif files found in current folder") - exit() # pylint: disable=consider-using-sys-exit + exit() # noqa: PLR1722, sys.exit def preload(self): image = Image.open(self._gif_files[self._index]) - print("Loading {}...".format(self._gif_files[self._index])) + print(f"Loading {self._gif_files[self._index]}...") if "duration" in image.info: self._duration = image.info["duration"] else: diff --git a/examples/rgb_display_pillow_bonnet_buttons.py b/examples/rgb_display_pillow_bonnet_buttons.py index 91bb656..cac9d7e 100644 --- a/examples/rgb_display_pillow_bonnet_buttons.py +++ b/examples/rgb_display_pillow_bonnet_buttons.py @@ -32,12 +32,14 @@ not support PIL/pillow (python imaging library)! """ -import time import random +import time from colorsys import hsv_to_rgb + import board from digitalio import DigitalInOut, Direction from PIL import Image, ImageDraw, ImageFont + from adafruit_rgb_display import st7789 # Create the display @@ -115,30 +117,22 @@ up_fill = 0 if not button_U.value: # up pressed up_fill = udlr_fill - draw.polygon( - [(40, 40), (60, 4), (80, 40)], outline=udlr_outline, fill=up_fill - ) # Up + draw.polygon([(40, 40), (60, 4), (80, 40)], outline=udlr_outline, fill=up_fill) # Up down_fill = 0 if not button_D.value: # down pressed down_fill = udlr_fill - draw.polygon( - [(60, 120), (80, 84), (40, 84)], outline=udlr_outline, fill=down_fill - ) # down + draw.polygon([(60, 120), (80, 84), (40, 84)], outline=udlr_outline, fill=down_fill) # down left_fill = 0 if not button_L.value: # left pressed left_fill = udlr_fill - draw.polygon( - [(0, 60), (36, 42), (36, 81)], outline=udlr_outline, fill=left_fill - ) # left + draw.polygon([(0, 60), (36, 42), (36, 81)], outline=udlr_outline, fill=left_fill) # left right_fill = 0 if not button_R.value: # right pressed right_fill = udlr_fill - draw.polygon( - [(120, 60), (84, 42), (84, 82)], outline=udlr_outline, fill=right_fill - ) # right + draw.polygon([(120, 60), (84, 42), (84, 82)], outline=udlr_outline, fill=right_fill) # right center_fill = 0 if not button_C.value: # center pressed diff --git a/examples/rgb_display_pillow_demo.py b/examples/rgb_display_pillow_demo.py index dc6eb56..e85691b 100644 --- a/examples/rgb_display_pillow_demo.py +++ b/examples/rgb_display_pillow_demo.py @@ -12,15 +12,18 @@ Author(s): Melissa LeBlanc-Williams for Adafruit Industries """ -import digitalio import board +import digitalio from PIL import Image, ImageDraw, ImageFont -from adafruit_rgb_display import ili9341 -from adafruit_rgb_display import st7789 # pylint: disable=unused-import -from adafruit_rgb_display import hx8357 # pylint: disable=unused-import -from adafruit_rgb_display import st7735 # pylint: disable=unused-import -from adafruit_rgb_display import ssd1351 # pylint: disable=unused-import -from adafruit_rgb_display import ssd1331 # pylint: disable=unused-import + +from adafruit_rgb_display import ( + hx8357, # pylint: disable=unused-import + ili9341, + ssd1331, # pylint: disable=unused-import + ssd1351, # pylint: disable=unused-import + st7735, # pylint: disable=unused-import + st7789, # pylint: disable=unused-import +) # First define some constants to allow easy resizing of shapes. BORDER = 20 @@ -82,9 +85,7 @@ disp.image(image) # Draw a smaller inner purple rectangle -draw.rectangle( - (BORDER, BORDER, width - BORDER - 1, height - BORDER - 1), fill=(170, 0, 136) -) +draw.rectangle((BORDER, BORDER, width - BORDER - 1, height - BORDER - 1), fill=(170, 0, 136)) # Load a TTF Font font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", FONTSIZE) diff --git a/examples/rgb_display_pillow_image.py b/examples/rgb_display_pillow_image.py index b463106..61e7f13 100644 --- a/examples/rgb_display_pillow_image.py +++ b/examples/rgb_display_pillow_image.py @@ -11,15 +11,18 @@ Author(s): Melissa LeBlanc-Williams for Adafruit Industries """ -import digitalio import board +import digitalio from PIL import Image, ImageDraw -from adafruit_rgb_display import ili9341 -from adafruit_rgb_display import st7789 # pylint: disable=unused-import -from adafruit_rgb_display import hx8357 # pylint: disable=unused-import -from adafruit_rgb_display import st7735 # pylint: disable=unused-import -from adafruit_rgb_display import ssd1351 # pylint: disable=unused-import -from adafruit_rgb_display import ssd1331 # pylint: disable=unused-import + +from adafruit_rgb_display import ( + hx8357, # pylint: disable=unused-import + ili9341, + ssd1331, # pylint: disable=unused-import + ssd1351, # pylint: disable=unused-import + st7735, # pylint: disable=unused-import + st7789, # pylint: disable=unused-import +) # Configuration for CS and DC pins (these are PiTFT defaults): cs_pin = digitalio.DigitalInOut(board.CE0) diff --git a/examples/rgb_display_pillow_stats.py b/examples/rgb_display_pillow_stats.py index 748f2ca..4a6d668 100644 --- a/examples/rgb_display_pillow_stats.py +++ b/examples/rgb_display_pillow_stats.py @@ -11,17 +11,21 @@ not support PIL/pillow (python imaging library)! """ -import time import subprocess -import digitalio +import time + import board +import digitalio from PIL import Image, ImageDraw, ImageFont -from adafruit_rgb_display import ili9341 -from adafruit_rgb_display import st7789 # pylint: disable=unused-import -from adafruit_rgb_display import hx8357 # pylint: disable=unused-import -from adafruit_rgb_display import st7735 # pylint: disable=unused-import -from adafruit_rgb_display import ssd1351 # pylint: disable=unused-import -from adafruit_rgb_display import ssd1331 # pylint: disable=unused-import + +from adafruit_rgb_display import ( + hx8357, # pylint: disable=unused-import + ili9341, + ssd1331, # pylint: disable=unused-import + ssd1351, # pylint: disable=unused-import + st7735, # pylint: disable=unused-import + st7789, # pylint: disable=unused-import +) # Configuration for CS and DC pins (these are PiTFT defaults): cs_pin = digitalio.DigitalInOut(board.CE0) diff --git a/examples/rgb_display_simpletest.py b/examples/rgb_display_simpletest.py index 8f7f7f0..0546972 100644 --- a/examples/rgb_display_simpletest.py +++ b/examples/rgb_display_simpletest.py @@ -5,13 +5,14 @@ # This will work even on a device running displayio # Will fill the TFT black and put a red pixel in the center, wait 2 seconds, # then fill the screen blue (with no pixel), wait 2 seconds, and repeat. -import time import random -import digitalio +import time + import board +import digitalio -from adafruit_rgb_display.rgb import color565 from adafruit_rgb_display import st7789 +from adafruit_rgb_display.rgb import color565 # Configuratoin for CS and DC pins (these are FeatherWing defaults on M0/M4): cs_pin = digitalio.DigitalInOut(board.D5) @@ -39,8 +40,6 @@ # Pause 2 seconds. time.sleep(2) # Clear the screen a random color - display.fill( - color565(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) - ) + display.fill(color565(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))) # Pause 2 seconds. time.sleep(2) diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..04e88ad --- /dev/null +++ b/ruff.toml @@ -0,0 +1,105 @@ +# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +target-version = "py38" +line-length = 110 + +[lint] +preview = true +select = ["I", "PL", "UP"] + +extend-select = [ + "D419", # empty-docstring + "E501", # line-too-long + "W291", # trailing-whitespace + "PLC0414", # useless-import-alias + "PLC2401", # non-ascii-name + "PLC2801", # unnecessary-dunder-call + "PLC3002", # unnecessary-direct-lambda-call + "E999", # syntax-error + "PLE0101", # return-in-init + "F706", # return-outside-function + "F704", # yield-outside-function + "PLE0116", # continue-in-finally + "PLE0117", # nonlocal-without-binding + "PLE0241", # duplicate-bases + "PLE0302", # unexpected-special-method-signature + "PLE0604", # invalid-all-object + "PLE0605", # invalid-all-format + "PLE0643", # potential-index-error + "PLE0704", # misplaced-bare-raise + "PLE1141", # dict-iter-missing-items + "PLE1142", # await-outside-async + "PLE1205", # logging-too-many-args + "PLE1206", # logging-too-few-args + "PLE1307", # bad-string-format-type + "PLE1310", # bad-str-strip-call + "PLE1507", # invalid-envvar-value + "PLE2502", # bidirectional-unicode + "PLE2510", # invalid-character-backspace + "PLE2512", # invalid-character-sub + "PLE2513", # invalid-character-esc + "PLE2514", # invalid-character-nul + "PLE2515", # invalid-character-zero-width-space + "PLR0124", # comparison-with-itself + "PLR0202", # no-classmethod-decorator + "PLR0203", # no-staticmethod-decorator + "UP004", # useless-object-inheritance + "PLR0206", # property-with-parameters + "PLR0904", # too-many-public-methods + "PLR0911", # too-many-return-statements + "PLR0912", # too-many-branches + "PLR0913", # too-many-arguments + "PLR0914", # too-many-locals + "PLR0915", # too-many-statements + "PLR0916", # too-many-boolean-expressions + "PLR1702", # too-many-nested-blocks + "PLR1704", # redefined-argument-from-local + "PLR1711", # useless-return + "C416", # unnecessary-comprehension + "PLR1733", # unnecessary-dict-index-lookup + "PLR1736", # unnecessary-list-index-lookup + + # ruff reports this rule is unstable + #"PLR6301", # no-self-use + + "PLW0108", # unnecessary-lambda + "PLW0120", # useless-else-on-loop + "PLW0127", # self-assigning-variable + "PLW0129", # assert-on-string-literal + "B033", # duplicate-value + "PLW0131", # named-expr-without-context + "PLW0245", # super-without-brackets + "PLW0406", # import-self + "PLW0602", # global-variable-not-assigned + "PLW0603", # global-statement + "PLW0604", # global-at-module-level + + # fails on the try: import typing used by libraries + #"F401", # unused-import + + "F841", # unused-variable + "E722", # bare-except + "PLW0711", # binary-op-exception + "PLW1501", # bad-open-mode + "PLW1508", # invalid-envvar-default + "PLW1509", # subprocess-popen-preexec-fn + "PLW2101", # useless-with-lock + "PLW3301", # nested-min-max +] + +ignore = [ + "PLR2004", # magic-value-comparison + "UP030", # format literals + "PLW1514", # unspecified-encoding + "PLR0913", # too many arguments + "PLR0917", # too many positional arguments +# "", +# "", +# "", +# "", +] + +[format] +line-ending = "lf" From 864f1cf1ede975daad5e95fd3d95c1d101834cde Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 29 Apr 2025 17:39:11 -0500 Subject: [PATCH 81/83] remove pylint disable comments --- adafruit_rgb_display/gc9a01a.py | 1 - adafruit_rgb_display/hx8353.py | 1 - adafruit_rgb_display/hx8357.py | 1 - adafruit_rgb_display/ili9341.py | 5 +---- adafruit_rgb_display/rgb.py | 20 +++++-------------- adafruit_rgb_display/s6d02a1.py | 1 - adafruit_rgb_display/ssd1331.py | 3 --- adafruit_rgb_display/ssd1351.py | 1 - adafruit_rgb_display/st7735.py | 3 --- adafruit_rgb_display/st7789.py | 1 - .../rgb_display_eyespi_beret_animated_gif.py | 18 ++++++++--------- examples/rgb_display_fbcp.py | 4 ++-- examples/rgb_display_minipitftstats.py | 2 +- examples/rgb_display_pillow_animated_gif.py | 20 +++++++------------ examples/rgb_display_pillow_demo.py | 12 +++++------ examples/rgb_display_pillow_image.py | 13 ++++++------ examples/rgb_display_pillow_stats.py | 14 ++++++------- 17 files changed, 41 insertions(+), 79 deletions(-) diff --git a/adafruit_rgb_display/gc9a01a.py b/adafruit_rgb_display/gc9a01a.py index e899004..18f5809 100644 --- a/adafruit_rgb_display/gc9a01a.py +++ b/adafruit_rgb_display/gc9a01a.py @@ -85,7 +85,6 @@ class GC9A01A(DisplaySPI): (_DISPON, None), # Display ON ) - # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, spi: busio.SPI, diff --git a/adafruit_rgb_display/hx8353.py b/adafruit_rgb_display/hx8353.py index d1da61c..2c7c8dc 100644 --- a/adafruit_rgb_display/hx8353.py +++ b/adafruit_rgb_display/hx8353.py @@ -68,7 +68,6 @@ class HX8353(DisplaySPI): _ENCODE_PIXEL = ">H" _ENCODE_POS = ">HH" - # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, spi: busio.SPI, diff --git a/adafruit_rgb_display/hx8357.py b/adafruit_rgb_display/hx8357.py index 432705e..1a0feea 100755 --- a/adafruit_rgb_display/hx8357.py +++ b/adafruit_rgb_display/hx8357.py @@ -102,7 +102,6 @@ class HX8357(DisplaySPI): _ENCODE_PIXEL = ">H" _ENCODE_POS = ">HH" - # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, spi: busio.SPI, diff --git a/adafruit_rgb_display/ili9341.py b/adafruit_rgb_display/ili9341.py index 3e79787..018b87d 100644 --- a/adafruit_rgb_display/ili9341.py +++ b/adafruit_rgb_display/ili9341.py @@ -81,7 +81,6 @@ class ILI9341(DisplaySPI): _ENCODE_POS = ">HH" _DECODE_PIXEL = ">BBB" - # pylint: disable-msg=too-many-arguments def __init__( self, spi: busio.SPI, @@ -109,11 +108,9 @@ def __init__( ) self._scroll = 0 - # pylint: enable-msg=too-many-arguments - def scroll( self, - dy: Optional[int] = None, # pylint: disable-msg=invalid-name + dy: Optional[int] = None, ) -> Optional[int]: """Scroll the display by delta y""" if dy is None: diff --git a/adafruit_rgb_display/rgb.py b/adafruit_rgb_display/rgb.py index 62f53e3..8cfa5c9 100644 --- a/adafruit_rgb_display/rgb.py +++ b/adafruit_rgb_display/rgb.py @@ -112,7 +112,7 @@ def pull(self, val: digitalio.Pull) -> None: pass -class Display: # pylint: disable-msg=no-member +class Display: """Base class for all RGB display devices :param width: number of pixels wide :param height: number of pixels high @@ -122,8 +122,8 @@ class Display: # pylint: disable-msg=no-member _COLUMN_SET: Optional[int] = None _RAM_WRITE: Optional[int] = None _RAM_READ: Optional[int] = None - _X_START = 0 # pylint: disable=invalid-name - _Y_START = 0 # pylint: disable=invalid-name + _X_START = 0 + _Y_START = 0 _INIT: Tuple[Tuple[int, Union[ByteString, None]], ...] = () _ENCODE_PIXEL = ">H" _ENCODE_POS = ">HH" @@ -150,7 +150,6 @@ def init(self) -> None: for command, data in self._INIT: self.write(command, data) - # pylint: disable-msg=invalid-name,too-many-arguments def _block( self, x0: int, y0: int, x1: int, y1: int, data: Optional[ByteString] = None ) -> Optional[ByteString]: @@ -163,8 +162,6 @@ def _block( self.write(self._RAM_WRITE, data) return None - # pylint: enable-msg=invalid-name,too-many-arguments - def _encode_pos(self, x: int, y: int) -> bytes: """Encode a position into bytes.""" return struct.pack(self._ENCODE_POS, x, y) @@ -219,7 +216,6 @@ def image( pixels[2 * (j * imwidth + i) + 1] = pix & 0xFF self._block(x, y, x + imwidth - 1, y + imheight - 1, pixels) - # pylint: disable-msg=too-many-arguments def fill_rectangle(self, x: int, y: int, width: int, height: int, color: Union[int, Tuple]) -> None: """Draw a rectangle at specified position with specified width and height, and fill it with the specified color.""" @@ -236,8 +232,6 @@ def fill_rectangle(self, x: int, y: int, width: int, height: int, color: Union[i self.write(None, data) self.write(None, pixel * rest) - # pylint: enable-msg=too-many-arguments - def fill(self, color: Union[int, Tuple] = 0) -> None: """Fill the whole display with the specified color.""" self.fill_rectangle(0, 0, self.width, self.height, color) @@ -265,7 +259,6 @@ def rotation(self, val: int) -> None: class DisplaySPI(Display): """Base class for SPI type devices""" - # pylint: disable-msg=too-many-arguments def __init__( self, spi: busio.SPI, @@ -289,12 +282,10 @@ def __init__( if self.rst: self.rst.switch_to_output(value=0) self.reset() - self._X_START = x_offset # pylint: disable=invalid-name - self._Y_START = y_offset # pylint: disable=invalid-name + self._X_START = x_offset + self._Y_START = y_offset super().__init__(width, height, rotation) - # pylint: enable-msg=too-many-arguments - def reset(self) -> None: """Reset the device""" if not self.rst: @@ -304,7 +295,6 @@ def reset(self) -> None: self.rst.value = 1 time.sleep(0.050) # 50 milliseconds - # pylint: disable=no-member def write(self, command: Optional[int] = None, data: Optional[ByteString] = None) -> None: """SPI write to the device: commands and data""" if command is not None: diff --git a/adafruit_rgb_display/s6d02a1.py b/adafruit_rgb_display/s6d02a1.py index 06b1c3d..9382988 100644 --- a/adafruit_rgb_display/s6d02a1.py +++ b/adafruit_rgb_display/s6d02a1.py @@ -68,7 +68,6 @@ class S6D02A1(DisplaySPI): _ENCODE_PIXEL = ">H" _ENCODE_POS = ">HH" - # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, spi: busio.SPI, diff --git a/adafruit_rgb_display/ssd1331.py b/adafruit_rgb_display/ssd1331.py index 8f90848..6947c13 100644 --- a/adafruit_rgb_display/ssd1331.py +++ b/adafruit_rgb_display/ssd1331.py @@ -113,8 +113,6 @@ class SSD1331(DisplaySPI): _ENCODE_PIXEL = ">H" _ENCODE_POS = ">BB" - # pylint: disable-msg=useless-super-delegation, too-many-arguments - # super required to allow override of default values def __init__( self, spi: busio.SPI, @@ -142,7 +140,6 @@ def __init__( rotation=rotation, ) - # pylint: disable=no-member def write(self, command: Optional[int] = None, data: Optional[ByteString] = None) -> None: """write procedure specific to SSD1331""" self.dc_pin.value = command is None diff --git a/adafruit_rgb_display/ssd1351.py b/adafruit_rgb_display/ssd1351.py index 3208289..e2416a7 100644 --- a/adafruit_rgb_display/ssd1351.py +++ b/adafruit_rgb_display/ssd1351.py @@ -107,7 +107,6 @@ class SSD1351(DisplaySPI): _ENCODE_PIXEL = ">H" _ENCODE_POS = ">BB" - # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, spi: busio.SPI, diff --git a/adafruit_rgb_display/st7735.py b/adafruit_rgb_display/st7735.py index 4582f91..e623a5d 100644 --- a/adafruit_rgb_display/st7735.py +++ b/adafruit_rgb_display/st7735.py @@ -128,7 +128,6 @@ class ST7735(DisplaySPI): _ENCODE_PIXEL = ">H" _ENCODE_POS = ">HH" - # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, spi: busio.SPI, @@ -190,7 +189,6 @@ class ST7735R(ST7735): ), ) - # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, spi: busio.SPI, @@ -279,7 +277,6 @@ class ST7735S(ST7735): (_DISPON, None), ) - # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, spi: busio.SPI, diff --git a/adafruit_rgb_display/st7789.py b/adafruit_rgb_display/st7789.py index 75f300e..2148789 100644 --- a/adafruit_rgb_display/st7789.py +++ b/adafruit_rgb_display/st7789.py @@ -102,7 +102,6 @@ class ST7789(DisplaySPI): (_MADCTL, b"\x08"), ) - # pylint: disable-msg=useless-super-delegation, too-many-arguments def __init__( self, spi: busio.SPI, diff --git a/examples/rgb_display_eyespi_beret_animated_gif.py b/examples/rgb_display_eyespi_beret_animated_gif.py index b5cab34..92b354a 100644 --- a/examples/rgb_display_eyespi_beret_animated_gif.py +++ b/examples/rgb_display_eyespi_beret_animated_gif.py @@ -25,16 +25,16 @@ import board import digitalio -import numpy # pylint: disable=unused-import +import numpy from PIL import Image, ImageOps from adafruit_rgb_display import ( - hx8357, # pylint: disable=unused-import + hx8357, ili9341, - ssd1331, # pylint: disable=unused-import - ssd1351, # pylint: disable=unused-import - st7735, # pylint: disable=unused-import - st7789, # pylint: disable=unused-import + ssd1331, + ssd1351, + st7735, + st7789, ) # Button pins for EYESPI Pi Beret @@ -59,7 +59,6 @@ # Setup SPI bus using hardware SPI: spi = board.SPI() -# pylint: disable=line-too-long # fmt: off # Create the display. disp = ili9341.ILI9341(spi, rotation=90, # 2.2", 2.4", 2.8", 3.2" ILI9341 @@ -82,7 +81,6 @@ baudrate=BAUDRATE, ) # fmt: on -# pylint: enable=line-too-long def init_button(pin): @@ -92,7 +90,7 @@ def init_button(pin): return button -class Frame: # pylint: disable=too-few-public-methods +class Frame: def __init__(self, duration=0): self.duration = duration self.image = None @@ -162,7 +160,7 @@ def preload(self): frame_object = Frame(duration=self._duration) if "duration" in image.info: frame_object.duration = image.info["duration"] - frame_object.image = ImageOps.pad( # pylint: disable=no-member + frame_object.image = ImageOps.pad( image.convert("RGB"), (self._width, self._height), method=Image.NEAREST, diff --git a/examples/rgb_display_fbcp.py b/examples/rgb_display_fbcp.py index 910d31b..6e5f220 100644 --- a/examples/rgb_display_fbcp.py +++ b/examples/rgb_display_fbcp.py @@ -37,7 +37,7 @@ FB_BLANK_POWERDOWN = 4 -class Bitfield: # pylint: disable=too-few-public-methods +class Bitfield: def __init__(self, offset, length, msb_right): self.offset = offset self.length = length @@ -46,7 +46,7 @@ def __init__(self, offset, length, msb_right): # Kind of like a pygame Surface object, or not! # http://www.pygame.org/docs/ref/surface.html -class Framebuffer: # pylint: disable=too-many-instance-attributes +class Framebuffer: def __init__(self, dev): self.dev = dev self.fbfd = os.open(dev, os.O_RDWR) diff --git a/examples/rgb_display_minipitftstats.py b/examples/rgb_display_minipitftstats.py index 48c480f..b096c31 100644 --- a/examples/rgb_display_minipitftstats.py +++ b/examples/rgb_display_minipitftstats.py @@ -82,7 +82,7 @@ MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8") cmd = 'df -h | awk \'$NF=="/"{printf "Disk: %d/%d GB %s", $3,$2,$5}\'' Disk = subprocess.check_output(cmd, shell=True).decode("utf-8") - cmd = "cat /sys/class/thermal/thermal_zone0/temp | awk '{printf \"CPU Temp: %.1f C\", $(NF-0) / 1000}'" # pylint: disable=line-too-long + cmd = "cat /sys/class/thermal/thermal_zone0/temp | awk '{printf \"CPU Temp: %.1f C\", $(NF-0) / 1000}'" Temp = subprocess.check_output(cmd, shell=True).decode("utf-8") # Write four lines of text. diff --git a/examples/rgb_display_pillow_animated_gif.py b/examples/rgb_display_pillow_animated_gif.py index 701d762..b65361c 100644 --- a/examples/rgb_display_pillow_animated_gif.py +++ b/examples/rgb_display_pillow_animated_gif.py @@ -21,16 +21,16 @@ import board import digitalio -import numpy # pylint: disable=unused-import +import numpy from PIL import Image, ImageOps from adafruit_rgb_display import ( - hx8357, # pylint: disable=unused-import + hx8357, ili9341, - ssd1331, # pylint: disable=unused-import - ssd1351, # pylint: disable=unused-import - st7735, # pylint: disable=unused-import - st7789, # pylint: disable=unused-import + ssd1331, + ssd1351, + st7735, + st7789, ) # Change to match your display @@ -52,16 +52,12 @@ def init_button(pin): return button -# pylint: disable=too-few-public-methods class Frame: def __init__(self, duration=0): self.duration = duration self.image = None -# pylint: enable=too-few-public-methods - - class AnimatedGif: def __init__(self, display, width=None, height=None, folder=None): self._frame_count = 0 @@ -126,7 +122,7 @@ def preload(self): frame_object = Frame(duration=self._duration) if "duration" in image.info: frame_object.duration = image.info["duration"] - frame_object.image = ImageOps.pad( # pylint: disable=no-member + frame_object.image = ImageOps.pad( image.convert("RGB"), (self._width, self._height), method=Image.NEAREST, @@ -180,7 +176,6 @@ def run(self): # Setup SPI bus using hardware SPI: spi = board.SPI() -# pylint: disable=line-too-long # Create the display: # disp = st7789.ST7789(spi, rotation=90, # 2.0" ST7789 # disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180, # 1.3", 1.54" ST7789 @@ -204,7 +199,6 @@ def run(self): rst=reset_pin, baudrate=BAUDRATE, ) -# pylint: enable=line-too-long if disp.rotation % 180 == 90: disp_height = disp.width # we swap height/width to rotate it to landscape! diff --git a/examples/rgb_display_pillow_demo.py b/examples/rgb_display_pillow_demo.py index e85691b..36f3961 100644 --- a/examples/rgb_display_pillow_demo.py +++ b/examples/rgb_display_pillow_demo.py @@ -17,12 +17,12 @@ from PIL import Image, ImageDraw, ImageFont from adafruit_rgb_display import ( - hx8357, # pylint: disable=unused-import + hx8357, ili9341, - ssd1331, # pylint: disable=unused-import - ssd1351, # pylint: disable=unused-import - st7735, # pylint: disable=unused-import - st7789, # pylint: disable=unused-import + ssd1331, + ssd1351, + st7735, + st7789, ) # First define some constants to allow easy resizing of shapes. @@ -40,7 +40,6 @@ # Setup SPI bus using hardware SPI: spi = board.SPI() -# pylint: disable=line-too-long # Create the display: # disp = st7789.ST7789(spi, rotation=90, # 2.0" ST7789 # disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180, # 1.3", 1.54" ST7789 @@ -64,7 +63,6 @@ rst=reset_pin, baudrate=BAUDRATE, ) -# pylint: enable=line-too-long # Create blank image for drawing. # Make sure to create image with mode 'RGB' for full color. diff --git a/examples/rgb_display_pillow_image.py b/examples/rgb_display_pillow_image.py index 61e7f13..c90f5e7 100644 --- a/examples/rgb_display_pillow_image.py +++ b/examples/rgb_display_pillow_image.py @@ -16,12 +16,12 @@ from PIL import Image, ImageDraw from adafruit_rgb_display import ( - hx8357, # pylint: disable=unused-import + hx8357, ili9341, - ssd1331, # pylint: disable=unused-import - ssd1351, # pylint: disable=unused-import - st7735, # pylint: disable=unused-import - st7789, # pylint: disable=unused-import + ssd1331, + ssd1351, + st7735, + st7789, ) # Configuration for CS and DC pins (these are PiTFT defaults): @@ -35,7 +35,7 @@ # Setup SPI bus using hardware SPI: spi = board.SPI() -# pylint: disable=line-too-long + # Create the display: # disp = st7789.ST7789(spi, rotation=90, # 2.0" ST7789 # disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180, # 1.3", 1.54" ST7789 @@ -59,7 +59,6 @@ rst=reset_pin, baudrate=BAUDRATE, ) -# pylint: enable=line-too-long # Create blank image for drawing. # Make sure to create image with mode 'RGB' for full color. diff --git a/examples/rgb_display_pillow_stats.py b/examples/rgb_display_pillow_stats.py index 4a6d668..673a032 100644 --- a/examples/rgb_display_pillow_stats.py +++ b/examples/rgb_display_pillow_stats.py @@ -19,12 +19,12 @@ from PIL import Image, ImageDraw, ImageFont from adafruit_rgb_display import ( - hx8357, # pylint: disable=unused-import + hx8357, ili9341, - ssd1331, # pylint: disable=unused-import - ssd1351, # pylint: disable=unused-import - st7735, # pylint: disable=unused-import - st7789, # pylint: disable=unused-import + ssd1331, + ssd1351, + st7735, + st7789, ) # Configuration for CS and DC pins (these are PiTFT defaults): @@ -38,7 +38,6 @@ # Setup SPI bus using hardware SPI: spi = board.SPI() -# pylint: disable=line-too-long # Create the display: # disp = st7789.ST7789(spi, rotation=90, # 2.0" ST7789 # disp = st7789.ST7789(spi, height=240, y_offset=80, rotation=180, # 1.3", 1.54" ST7789 @@ -62,7 +61,6 @@ rst=reset_pin, baudrate=BAUDRATE, ) -# pylint: enable=line-too-long # Create blank image for drawing. # Make sure to create image with mode 'RGB' for full color. @@ -105,7 +103,7 @@ MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8") cmd = 'df -h | awk \'$NF=="/"{printf "Disk: %d/%d GB %s", $3,$2,$5}\'' Disk = subprocess.check_output(cmd, shell=True).decode("utf-8") - cmd = "cat /sys/class/thermal/thermal_zone0/temp | awk '{printf \"CPU Temp: %.1f C\", $(NF-0) / 1000}'" # pylint: disable=line-too-long + cmd = "cat /sys/class/thermal/thermal_zone0/temp | awk '{printf \"CPU Temp: %.1f C\", $(NF-0) / 1000}'" Temp = subprocess.check_output(cmd, shell=True).decode("utf-8") # Write four lines of text. From c3c8bc658204f8a558d072f3a392b756fa3bee76 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 29 Apr 2025 17:40:07 -0500 Subject: [PATCH 82/83] remove unused string comments --- ruff.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ruff.toml b/ruff.toml index 04e88ad..6818392 100644 --- a/ruff.toml +++ b/ruff.toml @@ -95,10 +95,6 @@ ignore = [ "PLW1514", # unspecified-encoding "PLR0913", # too many arguments "PLR0917", # too many positional arguments -# "", -# "", -# "", -# "", ] [format] From b089f40c360af158c409f38e46b3e55c7c1de7ee Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 4 Jun 2025 10:00:20 -0500 Subject: [PATCH 83/83] update rtd.yml file Signed-off-by: foamyguy --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 88bca9f..255dafd 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -12,7 +12,7 @@ sphinx: configuration: docs/conf.py build: - os: ubuntu-20.04 + os: ubuntu-lts-latest tools: python: "3"