Compare commits

...

34 commits
1.6.3 ... main

Author SHA1 Message Date
Liz
29b7197abf
Merge pull request #22 from tekktrik/doc/update-rtd-config
Update RTD configuration, add missing badge to README
2025-06-24 09:31:12 -04:00
Alec Delaney
cd864d0489 Add RTD badge to README 2025-05-31 23:35:53 -04:00
Alec Delaney
db66df931d
Fix RTD configuration file 2025-05-31 23:31:16 -04:00
foamyguy
fd1a1f4e59
Merge pull request #19 from adafruit/use_ruff
change to ruff
2025-05-17 11:48:19 -05:00
foamyguy
efd331301e update docs conf 2025-05-17 11:43:36 -05:00
foamyguy
db55d4127b change to ruff 2025-05-14 20:54:15 +00:00
Dan Halbert
dbf17dd54f
Merge pull request #11 from JohnHind/main
Add instructions for Blinka Pull
2023-11-28 13:59:08 -05:00
Dan Halbert
f668c62d3f
Merge pull request #10 from semininja/main
enable selection of polling rate
2023-11-28 13:53:42 -05:00
JohnHind
ded2c96987
Merge pull request #1 from JohnHind/JohnHind-patch-1
Update README.rst
2023-10-30 16:03:50 +00:00
JohnHind
0ec81a4f5b
Update README.rst
Add Pip instructions for Blinka
2023-10-30 16:00:56 +00:00
semininja
7c9b45ecb8
forgot a docstring 2023-08-05 23:36:05 -04:00
semininja
926ce61ab3
enable selection of polling rate 2023-08-05 23:30:06 -04:00
Alec Delaney
366845d264
Merge pull request #7 from veleek/patch-1
Adding link to adafruit device.
2023-05-22 20:17:23 -04:00
Ben Randall
32abc3e8e0
Adding link to adafruit device. 2023-05-20 14:25:18 -04:00
Kattni
e34ee0a60b
Merge pull request #6 from tekktrik/dev/update
Adafruitize
2023-05-17 13:40:57 -04:00
Tekktrik
f2fb9ccd80 Trim whitespace in CoC 2023-05-17 13:29:00 -04:00
Tekktrik
5b9edfe1f5 Update CoC 2023-05-16 23:48:39 -04:00
Tekktrik
79af3b8975 Fix sphinx extension name typo 2023-05-16 23:43:07 -04:00
Tekktrik
aa411e48f5 Add whitespace 2023-05-16 23:36:36 -04:00
Tekktrik
0c1f54d34a Add sphinx docs folder 2023-05-16 23:35:43 -04:00
Tekktrik
ef124118a4 Update homepage 2023-05-16 23:35:34 -04:00
Tekktrik
06e0c1690f Use pyproject.toml 2023-05-16 23:23:06 -04:00
Tekktrik
f9cb830724 Added optional requirements file 2023-05-16 23:18:49 -04:00
Tekktrik
e68f04dc92 Added space in license file 2023-05-16 23:18:12 -04:00
Tekktrik
e88218c116 Update CoC 2023-05-16 23:11:11 -04:00
Tekktrik
5ce84065b8 Add RTD config 2023-05-16 23:10:42 -04:00
Tekktrik
f69901a3c0 Specify exception in .pylintrc 2023-05-16 23:03:48 -04:00
Tekktrik
1d9ca5e50a Update .pre-commit-config.yaml 2023-05-16 23:03:21 -04:00
Tekktrik
5e4fa3569d Add .venv to .gitignore 2023-05-16 23:01:41 -04:00
Cedar Grove Maker Studios
5f417de942 update docs 2023-03-15 22:14:30 -07:00
Cedar Grove Maker Studios
fca1b3b36c
Merge pull request #3 from tekktrik/dev/update-ci
Update CI files
2023-02-06 17:46:16 -08:00
Alec Delaney
d86e973d33 Update CI files 2023-02-06 20:36:12 -05:00
Cedar Grove Maker Studios
9b380e927a fix pylint error 2023-01-14 12:26:12 -08:00
Cedar Grove Maker Studios
c4e06b1e93 fix channel select data buffer issue
clears the data buffer before changing channels to avoid ghosting

adds a timeout counter for the Cycle Ready flag check rather than a fixed settling time delay (improves latency)
2023-01-14 12:04:01 -08:00
28 changed files with 621 additions and 691 deletions

11
.gitattributes vendored Normal file
View file

@ -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

View file

@ -10,71 +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 pylint, Sphinx, pre-commit
run: |
pip install --force-reinstall pylint 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: Check For docs folder
id: need-docs
run: |
echo ::set-output name=docs::$( find . -wholename './docs' )
- name: Build docs
if: contains(steps.need-docs.outputs.docs, '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: Run Build CI workflow
uses: adafruit/workflows-circuitpython-libs/build@main

View file

@ -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 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@v2
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: |
for file in $(find -not -path "./.*" -not -path "./docs*" -name "*.py"); do
sed -i -e "s/0.0.0-auto.0/${{github.event.release.tag_name}}/" $file;
done;
python setup.py sdist
twine upload dist/*

19
.github/workflows/release_gh.yml vendored Normal file
View file

@ -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 }}

19
.github/workflows/release_pypi.yml vendored Normal file
View file

@ -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 }}

1
.gitignore vendored
View file

@ -37,6 +37,7 @@ _build
# Virtual environment-specific files
.env
.venv
# MacOS-specific files
*.DS_Store

View file

@ -1,40 +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: 22.3.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: black
- repo: https://github.com/fsfe/reuse-tool
rev: v0.12.1
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
hooks:
- id: reuse
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
- id: ruff-format
- id: ruff
args: ["--fix"]
- repo: https://github.com/fsfe/reuse-tool
rev: v3.0.1
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/pylint
rev: v2.15.5
hooks:
- id: pylint
name: pylint (library code)
types: [python]
exclude: "^(docs/|examples/|tests/|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,consider-using-f-string $example; done)']
language: system
- id: pylint_tests
name: pylint (tests code)
description: Run pylint rules on "tests/*.py" files
entry: /usr/bin/env bash -c
args: ['([[ ! -d "tests" ]] || for test in $(find . -path "./tests/*.py"); do pylint --disable=missing-docstring $test; done)']
language: system
- id: reuse

436
.pylintrc
View file

@ -1,436 +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=
# 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,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,pointless-string-statement
# 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*(# )?<?https?://\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
# 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
# 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]
# 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_]*)|(__.*__))$
# Minimum line length for functions/classes that require docstrings, shorter
# 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_]*))$
# 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
# 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]+))$
# 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
# 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_]*))$
[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=Exception

22
.readthedocs.yaml Normal file
View file

@ -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

View file

@ -1,10 +1,10 @@
<!--
SPDX-FileCopyrightText: 2014 Coraline Ada Ehmke
SPDX-FileCopyrightText: 2019-2021 Kattni Rembor
SPDX-FileCopyrightText: 2019-2021 Kattni Rembor for Adafruit Industries
SPDX-License-Identifier: CC-BY-4.0
-->
# CircuitPython Community Code of Conduct
# Adafruit Community Code of Conduct
## Our Pledge
@ -20,35 +20,52 @@ race, religion, or sexual identity and orientation.
We are committed to providing a friendly, safe and welcoming environment for
all.
Examples of behavior that contributes to creating a positive environment
Examples of behavior that contributes to creating and maintaining a positive environment
include:
* Be kind and courteous to others
* Using welcoming and inclusive language
* Respecting the identity of every community member, including asking for their
pronouns if uncertain
* Being respectful of differing viewpoints and experiences
* Collaborating with other community members
* Providing desired assistance and knowledge to other community members
* Being open to new information and ideas
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
Examples of unacceptable behavior by community members include:
* The use of sexualized language or imagery and sexual attention or advances
* The use of inappropriate images, including in a community member's avatar
* The use of inappropriate language, including in a community member's nickname
* The use of inappropriate language or profanity, including in a community member's nickname
* Any spamming, flaming, baiting or other attention-stealing behavior
* Excessive or unwelcome helping; answering outside the scope of the question
asked
* Discussion or promotion of activities or projects that intend or pose a risk of
significant harm
* Trolling, insulting/derogatory comments, and personal or political attacks
* Trolling, insulting/derogatory comments, and attacks of any nature (including,
but not limited to, personal or political attacks)
* Promoting or spreading disinformation, lies, or conspiracy theories against
a person, group, organisation, project, or community
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Engaging in behavior that creates an unwelcoming or uninclusive environment
* Other conduct which could reasonably be considered inappropriate
The Adafruit Community welcomes everyone and strives to create a safe space for all. It is built
around sharing and contributing to technology. We encourage discussing your thoughts, experiences,
and feelings within the scope of the community. However, there are topics that can sometimes stray
from that scope, and can lead to hurting others and create an unwelcoming, uninclusive environment.
Examples of discussion topics that have been known to stray outside the scope of the Adafruit
Community include, but are not limited to:
* Discussions regarding religion and related topics
* Discussions regarding politics and related topics
The goal of the standards and moderation guidelines outlined here is to build
and maintain a respectful community. We ask that you dont just aim to be
"technically unimpeachable", but rather try to be your best self.
@ -72,26 +89,30 @@ inappropriate, threatening, offensive, or harmful.
## Moderation
Instances of behaviors that violate the CircuitPython Community Code of Conduct
Instances of behaviors that violate the Adafruit Community Code of Conduct
may be reported by any member of the community. Community members are
encouraged to report these situations, including situations they witness
involving other community members.
You may report in the following ways:
In any situation, you may email the project maintainer.
In any situation, you may email <support@adafruit.com>.
Email reports will be kept confidential.
On the Adafruit Discord, you may send an open message from any channel
to all Community Moderators by tagging @community moderators. You may
also send an open message from the #help-with-community channel, or a
direct message to any Community Moderator.
In situations on GitHub where the issue is particularly offensive, possibly
illegal, requires immediate action, or violates the GitHub terms of service,
you should also report the message directly to GitHub via the comment, or via
[GitHub Support](https://support.github.com/contact/report-abuse?category=report-abuse&report=other&report_type=unspecified).
The source of email and direct message reports will be kept confidential.
In situations on Discord where the issue is particularly offensive, possibly
illegal, requires immediate action, or violates the Discord terms of service,
you should also report the message directly to [Discord](https://discord.com/safety).
These are the steps for upholding our communitys standards of conduct.
1. Any member of the community may report any situation that violates the
CircuitPython Community Code of Conduct. All reports will be reviewed and
Adafruit Community Code of Conduct. All reports will be reviewed and
investigated.
2. If the behavior is a severe violation, the community member who
committed the violation may be banned immediately, without warning.
@ -105,18 +126,19 @@ These are the steps for upholding our communitys standards of conduct.
banned.
6. Disciplinary actions (warnings, bans, etc) for Code of Conduct violations apply
to the platform where the violation occurred. However, depending on the severity
of the violation, the disciplinary action may be applied across CircuitPython's
other community platforms. For example, a severe violation in one Community forum
may result in a ban on not only the CircuitPython GitHub organisation,
but also on the CircuitPython Twitter, live stream text chats, etc.
of the violation, the disciplinary action may be applied across Adafruit's other
community platforms. For example, a severe violation on the Adafruit Discord
server may result in a ban on not only the Adafruit Discord server, but also on
the Adafruit GitHub organisation, Adafruit Forums, Adafruit Twitter, etc.
## Scope
This Code of Conduct and the enforcement policies listed above apply to all
CircuitPython Community venues. This includes but is not limited to any community
spaces (both public and private), and CircuitPython repositories. Examples of
CircuitPython Community spaces include but are not limited to meet-ups, issue
threads on GitHub, text chats during a live stream, or interaction at a conference.
Adafruit Community venues. This includes but is not limited to any community
spaces (both public and private), the entire Adafruit Discord server, and
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
interaction at a conference.
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. As a community
@ -125,13 +147,11 @@ accordingly.
## Attribution
This Code of Conduct is adapted from the
[Adafruit Community Code of Conduct](https://github.com/adafruit/Adafruit_Community_Code_of_Conduct),
which is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/),
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/),
version 1.4, available on [contributor-covenant.org](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html),
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
For other projects adopting the CircuitPython Community Code of
For other projects adopting the Adafruit Community Code of
Conduct, please contact the maintainers of those projects for enforcement.
If you wish to use this code of conduct for your own project, consider
explicitly mentioning your moderation policy or making a copy with your

View file

@ -1,7 +1,9 @@
Introduction
============
.. image:: https://readthedocs.org/projects/circuitpython-nau7802/badge/?version=latest
:target: https://docs.circuitpython.org/projects/nau7802/en/latest/
:alt: Documentation Status
.. image:: https://img.shields.io/discord/327254708534116352.svg
@ -14,9 +16,9 @@ Introduction
: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
A CircuitPython driver class for the NAU7802 24-bit ADC.
@ -58,6 +60,13 @@ Or the following command to update an existing version:
circup update
Installing for Blinka with Pip
==============================
.. code-block:: shell
pip3 install cedargrove-nau7802
Usage Example
=============

View file

@ -1,3 +1,4 @@
SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
SPDX-FileCopyrightText: Copyright (c) 2022 JG for Cedar Grove Maker Studios
SPDX-License-Identifier: MIT

View file

@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: Copyright (c) 2023 JG for Cedar Grove Maker Studios
#
# SPDX-License-Identifier: MIT
"""
`cedargrove_nau7802`
================================================================================
@ -21,6 +22,7 @@ Implementation Notes
* `NAU7802 FeatherWing; OSH Park project (16-DIP version)
<https://oshpark.com/shared_projects/ZfryHYnc>`_
* `SparkFun Quicc Scale (single channel) <https://www.sparkfun.com/products/15242>`_
* `Adafruit NAU78082 STEMMA QT (single channel) <https://www.adafruit.com/product/4538>`_
**Software and Dependencies:**
@ -31,17 +33,15 @@ Implementation Notes
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
"""
import time
import struct
import time
from adafruit_bus_device.i2c_device import I2CDevice
from adafruit_register.i2c_struct import ROUnaryStruct
from adafruit_register.i2c_bit import ROBit, RWBit
# from adafruit_register.i2c_struct import UnaryStruct
from adafruit_register.i2c_bits import RWBits
from adafruit_register.i2c_bits import ROBits
from adafruit_register.i2c_bit import RWBit
from adafruit_register.i2c_bit import ROBit
from adafruit_register.i2c_bits import ROBits, RWBits
from adafruit_register.i2c_struct import ROUnaryStruct
__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/CedarGroveStudios/CircuitPython_NAU7802.git"
@ -60,7 +60,7 @@ _PGA = 0x1B # Programmable Gain Amplifier RW
_PWR_CTRL = 0x1C # Power Control RW
_REV_ID = 0x1F # Chip Revision ID R-
# pylint: disable=too-few-public-methods
class LDOVoltage:
"""Internal low-dropout voltage regulator settings."""
@ -103,7 +103,6 @@ class CalibrationMode:
class NAU7802:
"""The primary NAU7802 class."""
# pylint: disable=too-many-instance-attributes
def __init__(self, i2c_bus, address=0x2A, active_channels=1):
"""Instantiate NAU7802; LDO 3v0 volts, gain 128, 10 samples per second
conversion rate, disabled ADC chopper clock, low ESR caps, and PGA output
@ -143,7 +142,7 @@ class NAU7802:
_pu_cycle_start = RWBit(_PU_CTRL, 4, 1, False)
# Power-Up Cycle Ready (CR) R-
_pu_cycle_ready = ROBit(_PU_CTRL, 5, 1, False)
# Power-Up AVDD Source ADDS) RW
# Power-Up AVDD Source (ADDS) RW
_pu_ldo_source = RWBit(_PU_CTRL, 7, 1, False)
# Control_1 Gain (GAINS) RW
_c1_gains = RWBits(3, _CTRL1, 0, 1, False)
@ -179,12 +178,15 @@ class NAU7802:
@property
def channel(self):
"Selected channel number (1 or 2)."
"""Selected channel number (1 or 2)."""
return self._c2_chan_select + 1
@channel.setter
def channel(self, chan=1):
"""Select the active channel. Valid channel numbers are 1 and 2."""
"""Select the active channel. Valid channel numbers are 1 and 2.
Returns True unless a cycle ready (CR) timeout occurs."""
self.read() # Clear the data buffer
if chan == 1:
self._c2_chan_select = 0x0
@ -193,9 +195,12 @@ class NAU7802:
else:
raise ValueError("Invalid Channel Number")
time.sleep(0.500) # Fixed settling time
# Check cycle ready flag; timeout after 1.0 sec
start_check = time.monotonic()
while not self._pu_cycle_ready:
pass
if time.monotonic() - start_check > 1.0:
return False
return True
@property
def ldo_voltage(self):
@ -205,7 +210,7 @@ class NAU7802:
@ldo_voltage.setter
def ldo_voltage(self, voltage="EXTERNAL"):
"""Select the LDO Voltage. Valid voltages are '2V4', '2V7', '3V0'."""
if not "LDO_" + voltage in dir(LDOVoltage):
if not f"LDO_{voltage}" in dir(LDOVoltage):
raise ValueError("Invalid LDO Voltage")
self._ldo_voltage = voltage
if self._ldo_voltage == "2V4":
@ -222,9 +227,9 @@ class NAU7802:
@gain.setter
def gain(self, factor=1):
"""Select PGA gain factor. Valid values are '1, 2, 4, 8, 16, 32, 64,
"""Select PGA gain factor. Valid values are 1, 2, 4, 8, 16, 32, 64,
and 128."""
if not "GAIN_X" + str(factor) in dir(Gain):
if not f"GAIN_X{factor}" in dir(Gain):
raise ValueError("Invalid Gain Factor")
self._gain = factor
if self._gain == 1:
@ -244,6 +249,28 @@ class NAU7802:
elif self._gain == 128:
self._c1_gains = Gain.GAIN_X128
@property
def poll_rate(self):
"""ADC conversion/polling rate."""
return self._c2_conv_rate
@poll_rate.setter
def poll_rate(self, rate=0):
"""Select polling rate. Valid values are 10, 20, 40, 80, and 320."""
if not f"RATE_{rate}SPS" in dir(ConversionRate):
raise ValueError("Invalid Conversion Rate")
self._rate = rate
if self._rate == 10:
self._c2_conv_rate = ConversionRate.RATE_10SPS
if self._rate == 20:
self._c2_conv_rate = ConversionRate.RATE_20SPS
if self._rate == 40:
self._c2_conv_rate = ConversionRate.RATE_40SPS
if self._rate == 80:
self._c2_conv_rate = ConversionRate.RATE_80SPS
if self._rate == 320:
self._c2_conv_rate = ConversionRate.RATE_320SPS
def enable(self, power=True):
"""Enable(start) or disable(stop) the internal analog and digital
systems power. Enable = True; Disable (low power) = False. Returns

BIN
docs/_static/favicon.ico vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

3
docs/_static/favicon.ico.license vendored Normal file
View file

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
SPDX-License-Identifier: CC-BY-4.0

8
docs/api.rst Normal file
View file

@ -0,0 +1,8 @@
.. If you created a package, create one automodule per module in the package.
API Reference
#############
.. automodule:: cedargrove_nau7802
:members:

3
docs/api.rst.license Normal file
View file

@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries
#
# SPDX-License-Identifier: MIT

185
docs/conf.py Normal file
View file

@ -0,0 +1,185 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import datetime
import os
import sys
sys.path.insert(0, os.path.abspath(".."))
# -- General configuration ------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinxcontrib.jquery",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
]
# TODO: Please Read!
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
# autodoc_mock_imports = ["digitalio", "busio", "micropython", "adafruit_bus_device"]
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"BusDevice": (
"https://docs.circuitpython.org/projects/busdevice/en/latest/",
None,
),
"CircuitPython": ("https://docs.circuitpython.org/en/latest/", None),
}
# Show the docstring from both the class and its __init__() method.
autoclass_content = "both"
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
source_suffix = ".rst"
# The master toctree document.
master_doc = "index"
# General information about the project.
project = "Adafruit NAU7802 Library"
creation_year = "2023"
current_year = str(datetime.datetime.now().year)
year_duration = (
current_year if current_year == creation_year else creation_year + " - " + current_year
)
copyright = year_duration + " JG"
author = "JG"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "1.0"
# The full version, including alpha/beta/rc tags.
release = "1.0"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "en"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = [
"_build",
"Thumbs.db",
".DS_Store",
".env",
"CODE_OF_CONDUCT.md",
]
# The reST default role (used for this markup: `text`) to use for all
# documents.
#
default_role = "any"
# If true, '()' will be appended to :func: etc. cross-reference text.
#
add_function_parentheses = True
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# If this is True, todo emits a warning for each TODO entries. The default is False.
todo_emit_warnings = True
napoleon_numpy_docstring = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
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,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#
html_favicon = "_static/favicon.ico"
# Output file base name for HTML help builder.
htmlhelp_basename = "AdafruitNAU7802Librarydoc"
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
# Latex figure (float) alignment
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(
master_doc,
"AdafruitNAU7802Library.tex",
"Adafruit NAU7802 Library Documentation",
author,
"manual",
),
]
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(
master_doc,
"AdafruitNAU7802library",
"Adafruit NAU7802 Library Documentation",
[author],
1,
),
]
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
master_doc,
"AdafruitNAU7802Library",
"Adafruit NAU7802 Library Documentation",
author,
"AdafruitNAU7802Library",
"One line description of project.",
"Miscellaneous",
),
]

8
docs/examples.rst Normal file
View file

@ -0,0 +1,8 @@
Simple test
------------
Ensure your device works with this simple test.
.. literalinclude:: ../examples/nau7802_simpletest.py
:caption: examples/nau7802_simpletest.py
:linenos:

View file

@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries
#
# SPDX-License-Identifier: MIT

48
docs/index.rst Normal file
View file

@ -0,0 +1,48 @@
.. include:: ../README.rst
Table of Contents
=================
.. toctree::
:maxdepth: 4
:hidden:
self
.. toctree::
:caption: Examples
examples
.. toctree::
:caption: API Reference
:maxdepth: 3
api
.. toctree::
:caption: Tutorials
.. toctree::
:caption: Related Products
Adafruit NAU7802 24-Bit ADC <https://www.adafruit.com/product/4538>
.. toctree::
:caption: Other Links
Download from GitHub <https://github.com/adafruit/CircuitPython_NAU7802/releases/latest>
Download Library Bundle <https://circuitpython.org/libraries>
CircuitPython Reference Documentation <https://docs.circuitpython.org>
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
Discord Chat <https://adafru.it/discord>
Adafruit Learning System <https://learn.adafruit.com>
Adafruit Blog <https://blog.adafruit.com>
Adafruit Store <https://www.adafruit.com>
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

3
docs/index.rst.license Normal file
View file

@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries
#
# SPDX-License-Identifier: MIT

6
docs/requirements.txt Normal file
View file

@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
sphinx>=4.0.0
sphinxcontrib-jquery

View file

@ -9,7 +9,9 @@ average count of 2.
"""
import time
import board
from cedargrove_nau7802 import NAU7802
# Instantiate 24-bit load sensor ADC; two channels, default gain of 128
@ -21,14 +23,16 @@ def zero_channel():
a new channel is selected, or to adjust for measurement drift. Remove weight
and tare from load cell before executing."""
print(
"channel %1d calibrate.INTERNAL: %5s"
% (nau7802.channel, nau7802.calibrate("INTERNAL"))
"channel {0:1d} calibrate.INTERNAL: {1:5s}".format(
nau7802.channel, str(nau7802.calibrate("INTERNAL"))
)
)
print(
"channel %1d calibrate.OFFSET: %5s"
% (nau7802.channel, nau7802.calibrate("OFFSET"))
"channel {0:1d} calibrate.OFFSET: {1:5s}".format(
nau7802.channel, str(nau7802.calibrate("OFFSET"))
)
)
print("...channel %1d zeroed" % nau7802.channel)
print(f"...channel {nau7802.channel:1d} zeroed")
def read_raw_value(samples=2):
@ -64,8 +68,8 @@ while True:
print("=====")
nau7802.channel = 1
value = read_raw_value()
print("channel %1.0f raw value: %7.0f" % (nau7802.channel, value))
print(f"channel {nau7802.channel:1.0f} raw value: {value:7.0f}")
nau7802.channel = 2
value = read_raw_value()
print("channel %1.0f raw value: %7.0f" % (nau7802.channel, value))
print(f"channel {nau7802.channel:1.0f} raw value: {value:7.0f}")

View file

@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2022 Alec Delaney, for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense

View file

@ -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 = "cedargrove-nau7802"
description = "A CircuitPython driver class for the NAU7802 24-bit ADC"
version = "0.0.0+auto.0"
readme = "README.rst"
authors = [
{name = "Adafruit Industries", email = "circuitpython@adafruit.com"}
]
urls = {Homepage = "https://github.com/adafruit/CircuitPython_NAU7802"}
keywords = [
"adafruit",
"nau7802",
"adc",
"sensor",
"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 = ["cedargrove_nau7802"]
[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
optional-dependencies = {optional = {file = ["optional_requirements.txt"]}}

105
ruff.toml Normal file
View file

@ -0,0 +1,105 @@
# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
#
# SPDX-License-Identifier: MIT
target-version = "py38"
line-length = 100
[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
"PLR0915", # too-many-statements
"PLR0917", # too-many-positional-arguments
"PLR0904", # too-many-public-methods
"PLR0912", # too-many-branches
"PLR0916", # too-many-boolean-expressions
]
[format]
line-ending = "lf"

View file

@ -1,9 +0,0 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
# SPDX-FileCopyrightText: Copyright (c) 2022 JG for Cedar Grove Maker Studios
#
# 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.
"""