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..041a337 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,66 +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.7
- uses: actions/setup-python@v1
- with:
- python-version: 3.7
- - 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: 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 setup.py
- id: need-pypi
- run: |
- echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
- - name: Build Python package
- if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
- run: |
- pip install --upgrade setuptools wheel twine readme_renderer testresources
- 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
+ - 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 6d0015a..0000000
--- a/.github/workflows/release.yml
+++ /dev/null
@@ -1,85 +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.6
- uses: actions/setup-python@v1
- with:
- python-version: 3.6
- - 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 setup.py
- id: need-pypi
- run: |
- 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
- with:
- python-version: '3.x'
- - name: Install dependencies
- if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
- run: |
- python -m pip install --upgrade pip
- pip install setuptools wheel twine
- - name: Build and publish
- if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
- env:
- TWINE_USERNAME: ${{ secrets.pypi_username }}
- TWINE_PASSWORD: ${{ secrets.pypi_password }}
- run: |
- python setup.py sdist
- twine upload dist/*
diff --git a/.github/workflows/release_gh.yml b/.github/workflows/release_gh.yml
new file mode 100644
index 0000000..9acec60
--- /dev/null
+++ b/.github/workflows/release_gh.yml
@@ -0,0 +1,19 @@
+# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+
+name: GitHub Release Actions
+
+on:
+ release:
+ types: [published]
+
+jobs:
+ upload-release-assets:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Run GitHub Release CI workflow
+ uses: adafruit/workflows-circuitpython-libs/release-gh@main
+ with:
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ upload-url: ${{ github.event.release.upload_url }}
diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml
new file mode 100644
index 0000000..65775b7
--- /dev/null
+++ b/.github/workflows/release_pypi.yml
@@ -0,0 +1,19 @@
+# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+
+name: PyPI Release Actions
+
+on:
+ release:
+ types: [published]
+
+jobs:
+ upload-release-assets:
+ runs-on: ubuntu-latest
+ steps:
+ - 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 }}
diff --git a/.gitignore b/.gitignore
index 2c6ddfd..db3d538 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,18 +1,48 @@
-# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written 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
-.python-version
-build*/
-bundles
+.venv
+
+# MacOS-specific files
*.DS_Store
-.eggs
-dist
-**/*.egg-info
+
+# IDE-specific files
+.idea
.vscode
+*~
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 1b9fadc..70ade69 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
- rev: 20.8b1
+ - repo: https://github.com/python/black
+ rev: 23.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: v1.1.2
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.4.0
hooks:
- - id: check-yaml
- - id: end-of-file-fixer
- - id: trailing-whitespace
-- repo: https://github.com/pycqa/pylint
- rev: v2.11.1
+ - id: check-yaml
+ - id: end-of-file-fixer
+ - id: trailing-whitespace
+ - repo: https://github.com/pycqa/pylint
+ rev: v2.17.4
hooks:
- - id: pylint
+ - id: pylint
name: pylint (library code)
types: [python]
args:
- --disable=consider-using-f-string
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
diff --git a/.pylintrc b/.pylintrc
index 37fda44..f945e92 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=
@@ -26,7 +26,7 @@ jobs=1
# 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
@@ -54,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
+# 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
@@ -225,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
@@ -252,43 +246,27 @@ ignore-docstrings=yes
ignore-imports=yes
# Minimum lines number of a similarity.
-min-similarity-lines=4
+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_]*)|(__.*__))$
@@ -296,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_]*))$
@@ -309,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]+))$
@@ -339,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_]*))$
@@ -433,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/.readthedocs.yaml b/.readthedocs.yaml
new file mode 100644
index 0000000..88bca9f
--- /dev/null
+++ b/.readthedocs.yaml
@@ -0,0 +1,22 @@
+# 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
+
+sphinx:
+ configuration: docs/conf.py
+
+build:
+ os: ubuntu-20.04
+ tools:
+ python: "3"
+
+python:
+ install:
+ - requirements: docs/requirements.txt
+ - requirements: requirements.txt
diff --git a/.readthedocs.yml b/.readthedocs.yml
deleted file mode 100644
index 338427a..0000000
--- a/.readthedocs.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
-#
-# SPDX-License-Identifier: Unlicense
-
-python:
- version: 3
-requirements_file: docs/requirements.txt
diff --git a/LICENSES/CC-BY-SA-4.0.txt b/LICENSES/CC-BY-SA-4.0.txt
new file mode 100644
index 0000000..0000c85
--- /dev/null
+++ b/LICENSES/CC-BY-SA-4.0.txt
@@ -0,0 +1,107 @@
+Creative Commons Attribution-ShareAlike 4.0 International
+
+Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
+
+Using Creative Commons Public Licenses
+
+Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
+
+Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors
+
+Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described.
+
+Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public : wiki.creativecommons.org/Considerations_for_licensees
+
+Creative Commons Attribution-ShareAlike 4.0 International Public License
+
+By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
+
+Section 1 – Definitions.
+
+a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
+b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
+c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.
+d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
+e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
+f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
+g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike.
+h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
+i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
+j. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
+k. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
+l. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
+m. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
+Section 2 – Scope.
+
+a. License grant.
+1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
+A. reproduce and Share the Licensed Material, in whole or in part; and
+B. produce, reproduce, and Share Adapted Material.
+2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
+3. Term. The term of this Public License is specified in Section 6(a).
+4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
+5. Downstream recipients.
+A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
+B. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter's License You apply.
+C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
+6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
+b. Other rights.
+1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
+2. Patent and trademark rights are not licensed under this Public License.
+3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
+Section 3 – License Conditions.
+
+Your exercise of the Licensed Rights is expressly made subject to the following conditions.
+
+a. Attribution.
+1. If You Share the Licensed Material (including in modified form), You must:
+A. retain the following if it is supplied by the Licensor with the Licensed Material:
+i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
+ii. a copyright notice;
+iii. a notice that refers to this Public License;
+iv. a notice that refers to the disclaimer of warranties;
+v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
+
+B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
+C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
+2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
+3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
+b. ShareAlike.In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
+1. The Adapter's License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.
+2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
+3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
+Section 4 – Sui Generis Database Rights.
+
+Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
+
+a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
+b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
+c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
+For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
+Section 5 – Disclaimer of Warranties and Limitation of Liability.
+
+a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
+b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
+c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
+Section 6 – Term and Termination.
+
+a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
+b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
+1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
+2. upon express reinstatement by the Licensor.
+c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
+d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
+e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
+Section 7 – Other Terms and Conditions.
+
+a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
+b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
+Section 8 – Interpretation.
+
+a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
+b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
+c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
+d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
+Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the "Licensor." The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
+
+Creative Commons may be contacted at creativecommons.org.
diff --git a/README.rst b/README.rst
index 13619c0..00c1d16 100644
--- a/README.rst
+++ b/README.rst
@@ -2,10 +2,10 @@ Introduction
============
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-clue/badge/?version=latest
- :target: https://circuitpython.readthedocs.io/projects/clue/en/latest/
+ :target: https://docs.circuitpython.org/projects/clue/en/latest/
:alt: Documentation Status
-.. image:: https://img.shields.io/discord/327254708534116352.svg
+.. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg
:target: https://adafru.it/discord
:alt: Discord
@@ -75,7 +75,9 @@ This example displays sensor and input data on the CLUE display.
Documentation
=============
-API documentation for this library can be found on `Read the Docs `_.
+API documentation for this library can be found on `Read the Docs `_.
+
+For information on building library documentation, please check out `this guide `_.
Contributing
============
@@ -83,8 +85,3 @@ 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 `_.
diff --git a/adafruit_clue.py b/adafruit_clue.py
index 3a32eaf..33f55b7 100644
--- a/adafruit_clue.py
+++ b/adafruit_clue.py
@@ -39,23 +39,31 @@
https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel
"""
+try:
+ from typing import Union, Tuple, Optional, List
+except ImportError:
+ pass
+
import time
import array
import math
import board
+from microcontroller import Pin
import digitalio
import neopixel
import adafruit_apds9960.apds9960
import adafruit_bmp280
import adafruit_lis3mdl
import adafruit_lsm6ds.lsm6ds33
+import adafruit_lsm6ds.lsm6ds3trc
import adafruit_sht31d
import audiobusio
import audiopwmio
import audiocore
import touchio
+import displayio
-__version__ = "0.0.0-auto.0"
+__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CLUE.git"
@@ -64,15 +72,14 @@ class _ClueSimpleTextDisplay:
def __init__( # pylint: disable=too-many-arguments
self,
- title=None,
- title_color=0xFFFFFF,
- title_scale=1,
- text_scale=1,
- font=None,
- colors=None,
+ title: Optional[str] = None,
+ title_color: Union[int, Tuple[int, int, int]] = 0xFFFFFF,
+ title_scale: int = 1,
+ text_scale: int = 1,
+ font: Optional[str] = None,
+ colors: Optional[Tuple[Tuple[int, int, int], ...]] = None,
):
# pylint: disable=import-outside-toplevel
- import displayio
import terminalio
from adafruit_display_text import label
@@ -124,7 +131,7 @@ def __init__( # pylint: disable=too-many-arguments
for num in range(1):
self._lines.append(self.add_text_line(color=colors[num % len(colors)]))
- def __getitem__(self, item):
+ def __getitem__(self, item: int):
"""Fetch the Nth text line Group"""
if len(self._lines) - 1 < item:
for _ in range(item - (len(self._lines) - 1)):
@@ -133,7 +140,7 @@ def __getitem__(self, item):
)
return self._lines[item]
- def add_text_line(self, color=0xFFFFFF):
+ def add_text_line(self, color: Union[int, Tuple[int, int, int]] = 0xFFFFFF):
"""Adds a line on the display of the specified color and returns the label object."""
text_label = self._label.Label(self._font, text="", color=color)
text_label.x = 0
@@ -145,11 +152,11 @@ def add_text_line(self, color=0xFFFFFF):
def show(self):
"""Call show() to display the data list."""
- self._display.show(self.text_group)
+ self._display.root_group = self.text_group
def show_terminal(self):
"""Revert to terminalio screen."""
- self._display.show(None)
+ self._display.root_group = displayio.CIRCUITPYTHON_TERMINAL
class Clue: # pylint: disable=too-many-instance-attributes, too-many-public-methods
@@ -183,12 +190,13 @@ def __init__(self):
self._i2c = board.I2C()
# Define touch:
- # Initially, self._touches stores the pin used for a particular touch. When that touch is
- # used for the first time, the pin is replaced with the corresponding TouchIn object.
- # This saves a little RAM over using a separate read-only pin tuple.
+ # Initially, self._touches is an empty dictionary. When a touch is used
+ # for the first time, the pin is added as a key to the dictionary, with
+ # the corresponding TouchIn object added as the value. This saves a
+ # little RAM by only populating the dictionary as needed.
# For example, after `clue.touch_2`, self._touches is equivalent to:
- # [board.D0, board.D1, touchio.TouchIn(board.D2)]
- self._touches = [board.D0, board.D1, board.D2]
+ # { board.P2, touchio.TouchIn(board.P2) }
+ self._touches = {}
self._touch_threshold_adjustment = 0
# Define buttons:
@@ -211,14 +219,17 @@ def __init__(self):
sample_rate=16000,
bit_depth=16,
)
- self._sample = None
- self._samples = None
+ self._audio_out = None
self._sine_wave = None
self._sine_wave_sample = None
+ self._mic_samples = None
# Define sensors:
# Accelerometer/gyroscope:
- self._accelerometer = adafruit_lsm6ds.lsm6ds33.LSM6DS33(self._i2c)
+ try:
+ self._accelerometer = adafruit_lsm6ds.lsm6ds33.LSM6DS33(self._i2c)
+ except RuntimeError:
+ self._accelerometer = adafruit_lsm6ds.lsm6ds3trc.LSM6DS3TRC(self._i2c)
# Magnetometer:
self._magnetometer = adafruit_lis3mdl.LIS3MDL(self._i2c)
@@ -235,16 +246,17 @@ def __init__(self):
# Create displayio object for passing.
self.display = board.DISPLAY
- def _touch(self, i):
- if not isinstance(self._touches[i], touchio.TouchIn):
- # First time referenced. Get the pin from the slot for this touch
- # and replace it with a TouchIn object for the pin.
- self._touches[i] = touchio.TouchIn(self._touches[i])
- self._touches[i].threshold += self._touch_threshold_adjustment
- return self._touches[i].value
+ def _touch(self, pin: Pin) -> bool:
+ touchin = self._touches.get(pin)
+ if not touchin:
+ # First time referenced. Make TouchIn object for the pin
+ touchin = touchio.TouchIn(pin)
+ touchin.threshold += self._touch_threshold_adjustment
+ self._touches[pin] = touchin
+ return touchin.value
@property
- def touch_0(self):
+ def touch_0(self) -> bool:
"""Detect touch on capacitive touch pad 0.
.. image :: ../docs/_static/pad_0.jpg
@@ -262,10 +274,10 @@ def touch_0(self):
if clue.touch_0:
print("Touched pad 0")
"""
- return self._touch(0)
+ return self._touch(board.P0)
@property
- def touch_1(self):
+ def touch_1(self) -> bool:
"""Detect touch on capacitive touch pad 1.
.. image :: ../docs/_static/pad_1.jpg
@@ -283,10 +295,10 @@ def touch_1(self):
if clue.touch_1:
print("Touched pad 1")
"""
- return self._touch(1)
+ return self._touch(board.P1)
@property
- def touch_2(self):
+ def touch_2(self) -> bool:
"""Detect touch on capacitive touch pad 2.
.. image :: ../docs/_static/pad_2.jpg
@@ -304,10 +316,20 @@ def touch_2(self):
if clue.touch_2:
print("Touched pad 2")
"""
- return self._touch(2)
+ return self._touch(board.P2)
+
+ @property
+ def touch_pins(self) -> List[Pin]:
+ """A list of all the pins that are set up as touchpad inputs"""
+ return list(self._touches.keys())
+
+ @property
+ def touched(self):
+ """A list of all the pins that are currently registering a touch"""
+ return [pin for pin, touchpad in self._touches.items() if touchpad.value]
@property
- def button_a(self):
+ def button_a(self) -> bool:
"""``True`` when Button A is pressed. ``False`` if not.
.. image :: ../docs/_static/button_a.jpg
@@ -328,7 +350,7 @@ def button_a(self):
return not self._a.value
@property
- def button_b(self):
+ def button_b(self) -> bool:
"""``True`` when Button B is pressed. ``False`` if not.
.. image :: ../docs/_static/button_b.jpg
@@ -348,7 +370,9 @@ def button_b(self):
"""
return not self._b.value
- def shake(self, shake_threshold=30, avg_count=10, total_delay=0.1):
+ def shake(
+ self, shake_threshold: int = 30, avg_count: int = 10, total_delay: float = 0.1
+ ) -> bool:
"""
Detect when the accelerometer is shaken. Optional parameters:
@@ -380,7 +404,7 @@ def shake(self, shake_threshold=30, avg_count=10, total_delay=0.1):
return total_accel > shake_threshold
@property
- def acceleration(self):
+ def acceleration(self) -> Tuple[int, int, int]:
"""Obtain acceleration data from the x, y and z axes.
.. image :: ../docs/_static/accelerometer.jpg
@@ -400,7 +424,7 @@ def acceleration(self):
return self._accelerometer.acceleration
@property
- def gyro(self):
+ def gyro(self) -> Tuple[int, int, int]:
"""Obtain x, y, z angular velocity values in degrees/second.
.. image :: ../docs/_static/accelerometer.jpg
@@ -420,7 +444,7 @@ def gyro(self):
return self._accelerometer.gyro
@property
- def magnetic(self):
+ def magnetic(self) -> Tuple[int, int, int]:
"""Obtain x, y, z magnetic values in microteslas.
.. image :: ../docs/_static/magnetometer.jpg
@@ -440,7 +464,7 @@ def magnetic(self):
return self._magnetometer.magnetic
@property
- def proximity(self):
+ def proximity(self) -> int:
"""A relative proximity to the sensor in values from 0 - 255.
.. image :: ../docs/_static/proximity.jpg
@@ -462,7 +486,7 @@ def proximity(self):
return self._sensor.proximity
@property
- def color(self):
+ def color(self) -> Tuple[int, int, int, int]:
"""The red, green, blue, and clear light values. (r, g, b, c)
.. image :: ../docs/_static/proximity.jpg
@@ -484,7 +508,7 @@ def color(self):
return self._sensor.color_data
@property
- def gesture(self):
+ def gesture(self) -> int:
"""A gesture code if gesture is detected. Shows ``0`` if no gesture detected.
``1`` if an UP gesture is detected, ``2`` if DOWN, ``3`` if LEFT, and ``4`` if RIGHT.
@@ -512,7 +536,7 @@ def gesture(self):
return self._sensor.gesture()
@property
- def humidity(self):
+ def humidity(self) -> float:
"""The measured relative humidity in percent.
.. image :: ../docs/_static/humidity.jpg
@@ -532,7 +556,7 @@ def humidity(self):
return self._humidity.relative_humidity
@property
- def pressure(self):
+ def pressure(self) -> float:
"""The barometric pressure in hectoPascals.
.. image :: ../docs/_static/pressure.jpg
@@ -551,7 +575,7 @@ def pressure(self):
return self._pressure.pressure
@property
- def temperature(self):
+ def temperature(self) -> float:
"""The temperature in degrees Celsius.
.. image :: ../docs/_static/pressure.jpg
@@ -570,7 +594,7 @@ def temperature(self):
return self._pressure.temperature
@property
- def altitude(self):
+ def altitude(self) -> float:
"""The altitude in meters based on the sea level pressure at your location. You must set
``sea_level_pressure`` to receive an accurate reading.
@@ -590,7 +614,7 @@ def altitude(self):
return self._pressure.altitude
@property
- def sea_level_pressure(self):
+ def sea_level_pressure(self) -> float:
"""Set to the pressure at sea level at your location, before reading altitude for
the most accurate altitude measurement.
@@ -612,11 +636,11 @@ def sea_level_pressure(self):
return self._pressure.sea_level_pressure
@sea_level_pressure.setter
- def sea_level_pressure(self, value):
+ def sea_level_pressure(self, value: float):
self._pressure.sea_level_pressure = value
@property
- def white_leds(self):
+ def white_leds(self) -> bool:
"""The red led next to the USB plug labeled LED.
.. image :: ../docs/_static/white_leds.jpg
@@ -635,11 +659,11 @@ def white_leds(self):
return self._white_leds.value
@white_leds.setter
- def white_leds(self, value):
+ def white_leds(self, value: bool):
self._white_leds.value = value
@property
- def red_led(self):
+ def red_led(self) -> bool:
"""The red led next to the USB plug labeled LED.
.. image :: ../docs/_static/red_led.jpg
@@ -658,11 +682,11 @@ def red_led(self):
return self._red_led.value
@red_led.setter
- def red_led(self, value):
+ def red_led(self, value: bool):
self._red_led.value = value
@property
- def pixel(self):
+ def pixel(self) -> neopixel.NeoPixel:
"""The NeoPixel RGB LED.
.. image :: ../docs/_static/neopixel.jpg
@@ -682,20 +706,20 @@ def pixel(self):
return self._pixel
@staticmethod
- def _sine_sample(length):
- tone_volume = (2 ** 15) - 1
- shift = 2 ** 15
+ def _sine_sample(length: int):
+ tone_volume = (2**15) - 1
+ shift = 2**15
for i in range(length):
yield int(tone_volume * math.sin(2 * math.pi * (i / length)) + shift)
- def _generate_sample(self, length=100):
- if self._sample is not None:
+ def _generate_sample(self, length: int = 100):
+ if self._audio_out is not None:
return
self._sine_wave = array.array("H", self._sine_sample(length))
- self._sample = audiopwmio.PWMAudioOut(board.SPEAKER)
+ self._audio_out = audiopwmio.PWMAudioOut(board.SPEAKER)
self._sine_wave_sample = audiocore.RawSample(self._sine_wave)
- def play_tone(self, frequency, duration):
+ def play_tone(self, frequency: int, duration: float):
"""Produce a tone using the speaker. Try changing frequency to change
the pitch of the tone.
@@ -720,7 +744,7 @@ def play_tone(self, frequency, duration):
time.sleep(duration)
self.stop_tone()
- def start_tone(self, frequency):
+ def start_tone(self, frequency: int):
"""Produce a tone using the speaker. Try changing frequency to change
the pitch of the tone.
@@ -740,9 +764,9 @@ def start_tone(self, frequency):
while True:
if clue.button_a:
- clue.start_tone(523)
+ clue.start_tone(1600)
elif clue.button_b:
- clue.start_tone(587)
+ clue.start_tone(2000)
else:
clue.stop_tone()
"""
@@ -752,8 +776,8 @@ def start_tone(self, frequency):
self._generate_sample(length)
# Start playing a tone of the specified frequency (hz).
self._sine_wave_sample.sample_rate = int(len(self._sine_wave) * frequency)
- if not self._sample.playing:
- self._sample.play(self._sine_wave_sample, loop=True)
+ if not self._audio_out.playing:
+ self._audio_out.play(self._sine_wave_sample, loop=True)
def stop_tone(self):
"""Use with start_tone to stop the tone produced.
@@ -772,20 +796,20 @@ def stop_tone(self):
while True:
if clue.button_a:
- clue.start_tone(523)
+ clue.start_tone(1600)
elif clue.button_b:
- clue.start_tone(587)
+ clue.start_tone(2000)
else:
clue.stop_tone()
"""
# Stop playing any tones.
- if self._sample is not None and self._sample.playing:
- self._sample.stop()
- self._sample.deinit()
- self._sample = None
+ if self._audio_out is not None and self._audio_out.playing:
+ self._audio_out.stop()
+ self._audio_out.deinit()
+ self._audio_out = None
@staticmethod
- def _normalized_rms(values):
+ def _normalized_rms(values) -> float:
mean_values = int(sum(values) / len(values))
return math.sqrt(
sum(
@@ -796,7 +820,7 @@ def _normalized_rms(values):
)
@property
- def sound_level(self):
+ def sound_level(self) -> float:
"""Obtain the sound level from the microphone (sound sensor).
.. image :: ../docs/_static/microphone.jpg
@@ -812,12 +836,12 @@ def sound_level(self):
while True:
print(clue.sound_level)
"""
- if self._sample is None:
- self._samples = array.array("H", [0] * 160)
- self._mic.record(self._samples, len(self._samples))
- return self._normalized_rms(self._samples)
+ if self._mic_samples is None:
+ self._mic_samples = array.array("H", [0] * 160)
+ self._mic.record(self._mic_samples, len(self._mic_samples))
+ return self._normalized_rms(self._mic_samples)
- def loud_sound(self, sound_threshold=200):
+ def loud_sound(self, sound_threshold: int = 200) -> bool:
"""Utilise a loud sound as an input.
:param int sound_threshold: Threshold sound level must exceed to return true (Default: 200)
@@ -861,12 +885,12 @@ def loud_sound(self, sound_threshold=200):
@staticmethod
def simple_text_display( # pylint: disable=too-many-arguments
- title=None,
- title_color=(255, 255, 255),
- title_scale=1,
- text_scale=1,
- font=None,
- colors=None,
+ title: Optional[str] = None,
+ title_color: Tuple = (255, 255, 255),
+ title_scale: int = 1,
+ text_scale: int = 1,
+ font: Optional[str] = None,
+ colors: Optional[Tuple[Tuple[int, int, int], ...]] = None,
):
"""Display lines of text on the CLUE display. Lines of text are created in order as shown
in the example below. If you skip a number, the line will be shown blank on the display,
diff --git a/docs/conf.py b/docs/conf.py
index 2bb48ec..8546317 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(".."))
@@ -16,6 +17,7 @@
# ones.
extensions = [
"sphinx.ext.autodoc",
+ "sphinxcontrib.jquery",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
@@ -43,16 +45,16 @@
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,
),
"Register": (
- "https://circuitpython.readthedocs.io/projects/register/en/latest/",
+ "https://docs.circuitpython.org/projects/register/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.
@@ -65,7 +67,14 @@
# General information about the project.
project = "Adafruit CLUE Library"
-copyright = "2020 Kattni Rembor"
+creation_year = "2020"
+current_year = str(datetime.datetime.now().year)
+year_duration = (
+ current_year
+ if current_year == creation_year
+ else creation_year + " - " + current_year
+)
+copyright = year_duration + " Kattni Rembor"
author = "Kattni Rembor"
# The version info for the project you're documenting, acts as replacement for
@@ -82,7 +91,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.
@@ -114,19 +123,9 @@
# 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"
# 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,
diff --git a/docs/index.rst b/docs/index.rst
index 56d75d0..c3813d9 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -32,8 +32,9 @@ Table of Contents
.. toctree::
:caption: Other Links
- Download
- CircuitPython Reference Documentation
+ Download from GitHub
+ Download Library Bundle
+ CircuitPython Reference Documentation
CircuitPython Support Forum
Discord Chat
Adafruit Learning System
diff --git a/docs/requirements.txt b/docs/requirements.txt
index 88e6733..979f568 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -2,4 +2,6 @@
#
# SPDX-License-Identifier: Unlicense
-sphinx>=4.0.0
+sphinx
+sphinxcontrib-jquery
+sphinx-rtd-theme
diff --git a/examples/clue_ams_remote.py b/examples/clue_ams_remote.py
index 34aeb3f..508f2ca 100644
--- a/examples/clue_ams_remote.py
+++ b/examples/clue_ams_remote.py
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: 2020 Dylan Herrada for Adafruit Industries
+# SPDX-FileCopyrightText: 2020 Eva Herrada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
diff --git a/examples/advanced_examples/clue_ams_remote_advanced.py b/examples/clue_ams_remote_advanced.py
similarity index 98%
rename from examples/advanced_examples/clue_ams_remote_advanced.py
rename to examples/clue_ams_remote_advanced.py
index da2f727..1b21ac8 100644
--- a/examples/advanced_examples/clue_ams_remote_advanced.py
+++ b/examples/clue_ams_remote_advanced.py
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: 2020 Dylan Herrada for Adafruit Industries
+# SPDX-FileCopyrightText: 2020 Eva Herrada for Adafruit Industries
# SPDX-License-Identifier: MIT
""" This example solicits that apple devices that provide notifications connect to it, initiates
pairing, then allows the user to use a CLUE board as a media remote through both the buttons
@@ -84,7 +84,7 @@
volume_inner = Rect(15, 170, 1, 20, fill=0xFFFFFF, outline=0xFFFFFF)
group.append(volume_inner)
-display.show(group)
+display.root_group = group
time.sleep(0.01)
width1 = 1
diff --git a/examples/clue_ble_color_patchwork.py b/examples/clue_ble_color_patchwork.py
index ca5bddc..4b8a561 100644
--- a/examples/clue_ble_color_patchwork.py
+++ b/examples/clue_ble_color_patchwork.py
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
#
-# SPDX-License-Identifier: Unlicense
+# SPDX-License-Identifier: MIT
"""
Circuit Python BLE Color Patchwork
This demo uses advertising to broadcast a color of the users choice.
@@ -207,7 +207,7 @@ def change_advertisement(color):
group.append(patchwork_group)
# Add the Group to the Display
-display.show(group)
+display.root_group = group
cur_color = 0
diff --git a/examples/clue_display_sensor_data.py b/examples/clue_display_sensor_data.py
index 8a3f551..909e9ce 100644
--- a/examples/clue_display_sensor_data.py
+++ b/examples/clue_display_sensor_data.py
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
#
-# SPDX-License-Identifier: Unlicense
+# SPDX-License-Identifier: MIT
from adafruit_clue import clue
clue.sea_level_pressure = 1020
diff --git a/examples/clue_height_calculator.py b/examples/clue_height_calculator.py
index 64f0b27..360c1f6 100755
--- a/examples/clue_height_calculator.py
+++ b/examples/clue_height_calculator.py
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
#
-# SPDX-License-Identifier: Unlicense
+# SPDX-License-Identifier: MIT
"""Calculate the height of an object. Press button A to reset initial height and then lift the
CLUE to find the height."""
from adafruit_clue import clue
diff --git a/examples/clue_simpletest.py b/examples/clue_simpletest.py
index 12ec856..ac1703d 100644
--- a/examples/clue_simpletest.py
+++ b/examples/clue_simpletest.py
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
#
-# SPDX-License-Identifier: Unlicense
+# SPDX-License-Identifier: MIT
from adafruit_clue import clue
clue.sea_level_pressure = 1020
diff --git a/examples/clue_slideshow/adafruit_products_Blinka_240x240.bmp b/examples/clue_slideshow/adafruit_products_Blinka_240x240.bmp
new file mode 100644
index 0000000..8f587e7
Binary files /dev/null and b/examples/clue_slideshow/adafruit_products_Blinka_240x240.bmp differ
diff --git a/examples/clue_slideshow/adafruit_products_Blinka_240x240.bmp.license b/examples/clue_slideshow/adafruit_products_Blinka_240x240.bmp.license
new file mode 100644
index 0000000..3cf9459
--- /dev/null
+++ b/examples/clue_slideshow/adafruit_products_Blinka_240x240.bmp.license
@@ -0,0 +1,3 @@
+# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
+
+# SPDX-License-Identifier: CC-BY-SA-4.0
diff --git a/examples/clue_slideshow/adafruit_products_Blinka_Love_240x240.bmp b/examples/clue_slideshow/adafruit_products_Blinka_Love_240x240.bmp
new file mode 100644
index 0000000..95afd22
Binary files /dev/null and b/examples/clue_slideshow/adafruit_products_Blinka_Love_240x240.bmp differ
diff --git a/examples/clue_slideshow/adafruit_products_Blinka_Love_240x240.bmp.license b/examples/clue_slideshow/adafruit_products_Blinka_Love_240x240.bmp.license
new file mode 100644
index 0000000..3cf9459
--- /dev/null
+++ b/examples/clue_slideshow/adafruit_products_Blinka_Love_240x240.bmp.license
@@ -0,0 +1,3 @@
+# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
+
+# SPDX-License-Identifier: CC-BY-SA-4.0
diff --git a/examples/clue_slideshow/adafruit_products_Blinka_Ouroboros_240x240.bmp b/examples/clue_slideshow/adafruit_products_Blinka_Ouroboros_240x240.bmp
new file mode 100644
index 0000000..10106ba
Binary files /dev/null and b/examples/clue_slideshow/adafruit_products_Blinka_Ouroboros_240x240.bmp differ
diff --git a/examples/clue_slideshow/adafruit_products_Blinka_Ouroboros_240x240.bmp.license b/examples/clue_slideshow/adafruit_products_Blinka_Ouroboros_240x240.bmp.license
new file mode 100644
index 0000000..3cf9459
--- /dev/null
+++ b/examples/clue_slideshow/adafruit_products_Blinka_Ouroboros_240x240.bmp.license
@@ -0,0 +1,3 @@
+# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
+
+# SPDX-License-Identifier: CC-BY-SA-4.0
diff --git a/examples/clue_slideshow.py b/examples/clue_slideshow/clue_slideshow.py
similarity index 95%
rename from examples/clue_slideshow.py
rename to examples/clue_slideshow/clue_slideshow.py
index 59230b0..1185df3 100755
--- a/examples/clue_slideshow.py
+++ b/examples/clue_slideshow/clue_slideshow.py
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
#
-# SPDX-License-Identifier: Unlicense
+# SPDX-License-Identifier: MIT
"""Display a series of bitmaps using the buttons to advance through the list. To use: place
supported bitmap files on your CIRCUITPY drive, then press the buttons on your CLUE to advance
through them.
diff --git a/examples/clue_spirit_level.py b/examples/clue_spirit_level.py
index 6a24400..02d075e 100755
--- a/examples/clue_spirit_level.py
+++ b/examples/clue_spirit_level.py
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2019 Kattni Rembor, written for Adafruit Industries
#
-# SPDX-License-Identifier: Unlicense
+# SPDX-License-Identifier: MIT
"""CLUE Spirit Level Demo"""
import board
import displayio
@@ -23,7 +23,7 @@
bubble_group.append(level_bubble)
clue_group.append(bubble_group)
-display.show(clue_group)
+display.root_group = clue_group
while True:
x, y, _ = clue.acceleration
diff --git a/examples/clue_touch_all.py b/examples/clue_touch_all.py
new file mode 100644
index 0000000..d8b6099
--- /dev/null
+++ b/examples/clue_touch_all.py
@@ -0,0 +1,34 @@
+# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
+# SPDX-License-Identifier: MIT
+
+"""This example prints to the serial console when you touch the capacitive touch pads."""
+import time
+import board
+from adafruit_clue import clue
+
+
+# You'll need to first use the touchpads individually to register them as active touchpads
+# You don't have to use the result though
+is_p0_touched = clue.touch_0 # This result can be used if you want
+if is_p0_touched:
+ print("P0/D0 was touched upon startup!")
+is_p1_touched = clue.touch_1
+is_p2_touched = clue.touch_2
+
+
+print("Pads that are currently setup as touchpads:")
+print(clue.touch_pins)
+
+while True:
+ current_touched = clue.touched
+
+ if current_touched:
+ print("Touchpads currently registering a touch:")
+ print(current_touched)
+ else:
+ print("No touchpads are currently registering a touch.")
+
+ if all(pad in current_touched for pad in (board.P0, board.P1, board.P2)):
+ print("This only prints when P0, P1, and P2 are being held at the same time!")
+
+ time.sleep(0.25)
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
index f3c35ae..83e62d8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,46 @@
-# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
+# SPDX-FileCopyrightText: 2022 Alec Delaney for Adafruit Industries
#
-# SPDX-License-Identifier: Unlicense
+# SPDX-License-Identifier: MIT
-[tool.black]
-target-version = ['py35']
+[build-system]
+requires = [
+ "setuptools",
+ "wheel",
+ "setuptools-scm",
+]
+
+[project]
+name = "adafruit-circuitpython-clue"
+description = "A high-level library representing all the features of the Adafruit CLUE"
+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_CLUE"}
+keywords = [
+ "adafruit",
+ "clue",
+ "microbit",
+ "microcontroller",
+ "hardware",
+ "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]
+py-modules = ["adafruit_clue"]
+
+[tool.setuptools.dynamic]
+dependencies = {file = ["requirements.txt"]}
+optional-dependencies = {optional = {file = ["optional_requirements.txt"]}}
diff --git a/requirements.txt b/requirements.txt
index de1a06f..d18bcf3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,15 +1,14 @@
-# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
-# SPDX-FileCopyrightText: Copyright (c) 2020 Kattni Rembor for Adafruit Industries
+# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries
#
-# SPDX-License-Identifier: MIT
+# SPDX-License-Identifier: Unlicense
Adafruit-Blinka
adafruit-circuitpython-busdevice
+adafruit-circuitpython-lsm6ds
+adafruit-circuitpython-display-text
adafruit-circuitpython-register
adafruit-circuitpython-neopixel
adafruit-circuitpython-sht31d
-adafruit-circuitpython-lsm6ds
-adafruit-circuitpython-lis3mdl
-adafruit-circuitpython-display-text
adafruit-circuitpython-bmp280
+adafruit-circuitpython-lis3mdl
adafruit-circuitpython-apds9960
diff --git a/setup.py.disabled b/setup.py.disabled
deleted file mode 100644
index f9485df..0000000
--- a/setup.py.disabled
+++ /dev/null
@@ -1,8 +0,0 @@
-# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
-# SPDX-FileCopyrightText: Copyright (c) 2020 Kattni Rembor for Adafruit Industries
-#
-# SPDX-License-Identifier: MIT
-"""
-This library is not deployed to PyPI. It is either a board-specific helper library, or
-does not make sense for use on or is incompatible with single board computers and Linux.
-"""