Compare commits
58 commits
pypi-readm
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ffc009f29 | ||
|
|
0153a80021 | ||
|
|
0ecce36c22 | ||
|
|
fe54dce5fc | ||
|
|
d0583749cb | ||
|
|
fa1d64147c | ||
|
|
f334edadec | ||
|
|
566dbbd8ab | ||
|
|
198e04f9ec | ||
|
|
cd93fb848e | ||
|
|
3091c81133 | ||
|
|
7416475be7 | ||
|
|
0810df908b | ||
|
|
d39520c31b | ||
|
|
d57b5d4d7c | ||
|
|
a05292527f | ||
|
|
b2aab835dc | ||
|
|
e8baa7b0d7 | ||
|
|
a778646bd2 | ||
|
|
84a72ad189 | ||
|
|
37f556c4ae | ||
|
|
219073732a | ||
|
|
6fee72baa4 | ||
|
|
67a8a969cf | ||
|
|
4e14466bb5 | ||
|
|
e991f58ceb | ||
|
|
33bb64cd99 | ||
|
|
520e4f065a | ||
|
|
f128d33d01 | ||
|
|
1c4f21c3a6 | ||
|
|
23be8dd884 | ||
|
|
6f0cfb2f42 | ||
|
|
a3d1c3ffaf | ||
|
|
96e97cfe1e | ||
|
|
aeaaf4ba6b | ||
|
|
9e503e761f | ||
|
|
e439d7e2ed | ||
|
|
50061b7c9d | ||
|
|
ad595ebcf2 | ||
|
|
f53c08a5ad | ||
|
|
2bb1050ca1 | ||
|
|
cf6cd50865 | ||
|
|
d6201ea20a | ||
|
|
5ba760c6de | ||
|
|
8b6bb82d0d | ||
|
|
caba0ea660 | ||
|
|
1b9a1af0a6 | ||
|
|
6b7ea95417 | ||
|
|
0109b1f10c | ||
|
|
cb5cabecb5 | ||
|
|
2e61b96df3 | ||
|
|
b7509eab13 | ||
|
|
a06b7c2761 | ||
|
|
c9aa810c2f | ||
|
|
b9ebd1f8fb | ||
|
|
afa92fa0bc | ||
|
|
2323ca920a | ||
|
|
1c1f3da447 |
24 changed files with 933 additions and 806 deletions
57
.github/workflows/build.yml
vendored
Normal file
57
.github/workflows/build.yml
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
name: Build CI
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
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.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 dependencies
|
||||
# (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.)
|
||||
run: |
|
||||
source actions-ci/install.sh
|
||||
- name: Pip install pylint, black, & Sphinx
|
||||
run: |
|
||||
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
|
||||
- name: Library version
|
||||
run: git describe --dirty --always --tags
|
||||
- name: Check formatting
|
||||
run: |
|
||||
black --check --target-version=py35 .
|
||||
- name: PyLint
|
||||
run: |
|
||||
pylint $( find . -path './adafruit*.py' )
|
||||
([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*.py" ))
|
||||
- name: Build assets
|
||||
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
|
||||
- name: Build docs
|
||||
working-directory: docs
|
||||
run: sphinx-build -E -W -b html . _build/html
|
||||
81
.github/workflows/release.yml
vendored
Normal file
81
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
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/*
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,7 +4,6 @@ __pycache__
|
|||
_build
|
||||
*.pyc
|
||||
.env
|
||||
build*
|
||||
bundles
|
||||
*.DS_Store
|
||||
.eggs
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ confidence=
|
|||
# no Warning level messages displayed, use"--disable=all --enable=classes
|
||||
# --disable=W"
|
||||
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
|
||||
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error
|
||||
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
|
||||
|
||||
# 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
|
||||
|
|
@ -119,7 +119,8 @@ 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,TODO
|
||||
notes=FIXME,XXX
|
||||
|
||||
|
||||
[TYPECHECK]
|
||||
|
|
|
|||
32
.travis.yml
32
.travis.yml
|
|
@ -1,32 +0,0 @@
|
|||
dist: trusty
|
||||
sudo: false
|
||||
language: python
|
||||
python:
|
||||
- '3.6'
|
||||
cache:
|
||||
pip: true
|
||||
deploy:
|
||||
- provider: releases
|
||||
api_key: "$GITHUB_TOKEN"
|
||||
file_glob: true
|
||||
file: "$TRAVIS_BUILD_DIR/bundles/*"
|
||||
skip_cleanup: true
|
||||
overwrite: true
|
||||
on:
|
||||
tags: true
|
||||
- provider: pypi
|
||||
user: adafruit-travis
|
||||
on:
|
||||
tags: true
|
||||
password:
|
||||
secure: QCVXg2x28R7W6g+YvewEM0XamfyNVUal0CvNTFgjrnqj4K9Yd9gd8uKXM9cmFxD54y2Uvw8vWyNwQ4IsVZOuuTTohzc3hIlQhSEWhYZTt5i/JQISQSph/Q/dSn0/rb7n2/utfj/g1hB7cQlAtkecISrtIF7wOJacrh11z5/Ay99kcpc60Y7YFjZTbx02g8NnM0g6Cg92fEdRLr2UtwloFw1C0+nQxdb9vS7xj3IWrtfopQ3LRVsLTGocctj5u6OPgkh+FZma+NCIseONqpYX4PYRrRZJRQ4g+SZ+6tFb6zVOHsIAJ0Z6PdLMZmUeNGb42mTfHxPFWaTtPXi5/bgsOLfuL7IMpkirrqQFyppvqi7bqBYC5dCDGguEvzwHZusK4h8SAXiLJL4hZVkzNQ4JJN3JQSvAaF7nv8LIHGNpPsFOF8sd5gndMHUOBZx+lJ6wHqk3dxrhfehKKyv/xZ8Tl1ot65E8I3QBrJfREDbSgTfyetEFMPQLOUkZFcag3FCjiLVfR2AxxxaSPMcS0eUDefhYHm78ukZi8EQRiM/5Pnqv7tnsFg4+ua4c5Hw2Tck5htNAHEMMJ94PxvFSGhbZ8ujjSjiSPePfAVoJZo1617rL7cw54LeaOe6zU5fJiWEMVDeonCFK9yZ9tmqxpEnEf+wwK4bfTI8TycA9e5oNY0M=
|
||||
install:
|
||||
- pip install -r requirements.txt
|
||||
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
|
||||
- pip install --force-reinstall pylint==1.9.2
|
||||
script:
|
||||
- pylint adafruit_ads1x15/*.py
|
||||
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
|
||||
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ads1x15 --library_location
|
||||
.
|
||||
- cd docs && sphinx-build -E -W -b html . _build/html && cd ..
|
||||
|
|
@ -1,74 +1,129 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
# Adafruit Community Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
contributors and leaders pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
size, disability, ethnicity, gender identity and expression, level or type of
|
||||
experience, education, socio-economic status, nationality, personal appearance,
|
||||
race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
We are committed to providing a friendly, safe and welcoming environment for
|
||||
all.
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Be kind and courteous to others
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Collaborating with other community members
|
||||
* 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:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* 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
|
||||
* Any spamming, flaming, baiting or other attention-stealing behavior
|
||||
* Excessive or unwelcome helping; answering outside the scope of the question
|
||||
asked
|
||||
* Trolling, insulting/derogatory comments, and 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
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
* Other conduct which could reasonably be considered inappropriate
|
||||
|
||||
The goal of the standards and moderation guidelines outlined here is to build
|
||||
and maintain a respectful community. We ask that you don’t just aim to be
|
||||
"technically unimpeachable", but rather try to be your best self.
|
||||
|
||||
We value many things beyond technical expertise, including collaboration and
|
||||
supporting others within our community. Providing a positive experience for
|
||||
other community members can have a much more significant impact than simply
|
||||
providing the correct answer.
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
Project leaders are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
Project leaders have the right and responsibility to remove, edit, or
|
||||
reject messages, comments, commits, code, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
permanently any community member for other behaviors that they deem
|
||||
inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Moderation
|
||||
|
||||
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 send an email to <support@adafruit.com>.
|
||||
|
||||
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 any channel, or a direct message to
|
||||
@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442,
|
||||
@sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175.
|
||||
|
||||
Email and direct message reports will be kept confidential.
|
||||
|
||||
In situations on Discord where the issue is particularly egregious, possibly
|
||||
illegal, requires immediate action, or violates the Discord terms of service,
|
||||
you should also report the message directly to Discord.
|
||||
|
||||
These are the steps for upholding our community’s standards of conduct.
|
||||
|
||||
1. Any member of the community may report any situation that violates the
|
||||
Adafruit Community Code of Conduct. All reports will be reviewed and
|
||||
investigated.
|
||||
2. If the behavior is an egregious violation, the community member who
|
||||
committed the violation may be banned immediately, without warning.
|
||||
3. Otherwise, moderators will first respond to such behavior with a warning.
|
||||
4. Moderators follow a soft "three strikes" policy - the community member may
|
||||
be given another chance, if they are receptive to the warning and change their
|
||||
behavior.
|
||||
5. If the community member is unreceptive or unreasonable when warned by a
|
||||
moderator, or the warning goes unheeded, they may be banned for a first or
|
||||
second offense. Repeated offenses will result in the community member being
|
||||
banned.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct and the enforcement policies listed above apply to all
|
||||
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. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at support@adafruit.com. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
when an individual is representing the project or its community. As a community
|
||||
member, you are representing our community, and are expected to behave
|
||||
accordingly.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 1.4, available at
|
||||
<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).
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
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
|
||||
own moderation policy so as to avoid confusion.
|
||||
|
|
|
|||
88
README.rst
88
README.rst
|
|
@ -9,8 +9,8 @@ Introduction
|
|||
:target: https://adafru.it/discord
|
||||
:alt: Discord
|
||||
|
||||
.. image:: https://travis-ci.org/adafruit/Adafruit_CircuitPython_ADS1x15.svg?branch=master
|
||||
:target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_ADS1x15
|
||||
.. image:: https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15/workflows/Build%20CI/badge.svg
|
||||
:target: https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15/actions/
|
||||
:alt: Build Status
|
||||
|
||||
Support for the ADS1x15 series of analog-to-digital converters. Available in 12-bit (ADS1015)
|
||||
|
|
@ -62,31 +62,29 @@ Single Ended
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
import board
|
||||
import busio
|
||||
from adafruit_ads1x15.single_ended import ADS1015
|
||||
import time
|
||||
import board
|
||||
import busio
|
||||
import adafruit_ads1x15.ads1015 as ADS
|
||||
from adafruit_ads1x15.analog_in import AnalogIn
|
||||
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
adc = ADS1015(i2c)
|
||||
while True:
|
||||
# channel 0
|
||||
print(adc[0].value, adc[0].volts)
|
||||
# Create the I2C bus
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
|
||||
Differential
|
||||
------------
|
||||
# Create the ADC object using the I2C bus
|
||||
ads = ADS.ADS1015(i2c)
|
||||
|
||||
.. code-block:: python
|
||||
# Create single-ended input on channel 0
|
||||
chan = AnalogIn(ads, ADS.P0)
|
||||
|
||||
import board
|
||||
import busio
|
||||
from adafruit_ads1x15.differential import ADS1015
|
||||
# Create differential input between channel 0 and 1
|
||||
#chan = AnalogIn(ads, ADS.P0, ADS.P1)
|
||||
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
adc = ADS1015(i2c)
|
||||
while True:
|
||||
# channel 0 - channel 1
|
||||
print(adc[(0,1)].value, adc[(0,1)].volts)
|
||||
print("{:>5}\t{:>5}".format('raw', 'v'))
|
||||
|
||||
while True:
|
||||
print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
|
||||
time.sleep(0.5)
|
||||
|
||||
Contributing
|
||||
============
|
||||
|
|
@ -95,49 +93,7 @@ Contributions are welcome! Please read our `Code of Conduct
|
|||
<https://github.com/adafruit/Adafruit_CircuitPython_CircuitPython_ADS1x15/blob/master/CODE_OF_CONDUCT.md>`_
|
||||
before contributing to help this project stay welcoming.
|
||||
|
||||
Building locally
|
||||
================
|
||||
Documentation
|
||||
=============
|
||||
|
||||
To build this library locally you'll need to install the
|
||||
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
python3 -m venv .env
|
||||
source .env/bin/activate
|
||||
pip install circuitpython-build-tools
|
||||
|
||||
Once installed, make sure you are in the virtual environment:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
source .env/bin/activate
|
||||
|
||||
Then run the build:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ads1x15 --library_location .
|
||||
|
||||
Sphinx documentation
|
||||
--------------------
|
||||
|
||||
Sphinx is used to build the documentation based on rST files and comments in the code. First,
|
||||
install dependencies (feel free to reuse the virtual environment from above):
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
python3 -m venv .env
|
||||
source .env/bin/activate
|
||||
pip install Sphinx sphinx-rtd-theme
|
||||
|
||||
Now, once you have the virtual environment activated:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
cd docs
|
||||
sphinx-build -E -W -b html . _build/html
|
||||
|
||||
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
|
||||
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
|
||||
locally verify it will pass.
|
||||
For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.
|
||||
|
|
|
|||
|
|
@ -1,233 +0,0 @@
|
|||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2017 Carter Nelson for Adafruit Industries
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
"""
|
||||
`adafruit_ads1x15`
|
||||
====================================================
|
||||
|
||||
CircuitPython driver for ADS1015/1115 ADCs.
|
||||
|
||||
* Author(s): Carter Nelson
|
||||
"""
|
||||
|
||||
__version__ = "0.0.0-auto.0"
|
||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15.git"
|
||||
|
||||
import time
|
||||
from micropython import const
|
||||
from adafruit_bus_device.i2c_device import I2CDevice
|
||||
|
||||
# Register and other configuration values:
|
||||
# pylint: disable=bad-whitespace
|
||||
ADS1X15_DEFAULT_ADDRESS = const(0x48)
|
||||
ADS1X15_POINTER_CONVERSION = const(0x00)
|
||||
ADS1X15_POINTER_CONFIG = const(0x01)
|
||||
ADS1X15_POINTER_LOW_THRESHOLD = const(0x02)
|
||||
ADS1X15_POINTER_HIGH_THRESHOLD = const(0x03)
|
||||
ADS1X15_CONFIG_OS_SINGLE = const(0x8000)
|
||||
ADS1X15_CONFIG_MUX_OFFSET = const(12)
|
||||
# Maping of gain values to config register values.
|
||||
ADS1X15_CONFIG_GAIN = {
|
||||
2/3: 0x0000,
|
||||
1: 0x0200,
|
||||
2: 0x0400,
|
||||
4: 0x0600,
|
||||
8: 0x0800,
|
||||
16: 0x0A00
|
||||
}
|
||||
ADS1X15_PGA_RANGE = {
|
||||
2/3: 6.144,
|
||||
1: 4.096,
|
||||
2: 2.048,
|
||||
4: 1.024,
|
||||
8: 0.512,
|
||||
16: 0.256
|
||||
}
|
||||
ADS1X15_CONFIG_MODE_CONTINUOUS = const(0x0000)
|
||||
ADS1X15_CONFIG_MODE_SINGLE = const(0x0100)
|
||||
# Mapping of data/sample rate to config register values for ADS1015 (faster).
|
||||
ADS1015_CONFIG_DR = {
|
||||
128: 0x0000,
|
||||
250: 0x0020,
|
||||
490: 0x0040,
|
||||
920: 0x0060,
|
||||
1600: 0x0080,
|
||||
2400: 0x00A0,
|
||||
3300: 0x00C0
|
||||
}
|
||||
# Mapping of data/sample rate to config register values for ADS1115 (slower).
|
||||
ADS1115_CONFIG_DR = {
|
||||
8: 0x0000,
|
||||
16: 0x0020,
|
||||
32: 0x0040,
|
||||
64: 0x0060,
|
||||
128: 0x0080,
|
||||
250: 0x00A0,
|
||||
475: 0x00C0,
|
||||
860: 0x00E0
|
||||
}
|
||||
ADS1X15_CONFIG_COMP_WINDOW = const(0x0010)
|
||||
ADS1X15_CONFIG_COMP_ACTIVE_HIGH = const(0x0008)
|
||||
ADS1X15_CONFIG_COMP_LATCHING = const(0x0004)
|
||||
ADS1X15_CONFIG_COMP_QUE = {
|
||||
1: 0x0000,
|
||||
2: 0x0001,
|
||||
4: 0x0002
|
||||
}
|
||||
ADS1X15_CONFIG_COMP_QUE_DISABLE = const(0x0003)
|
||||
ADS1X15_DIFF_CHANNELS = {
|
||||
(0,1): 0,
|
||||
(0,3): 1,
|
||||
(1,3): 2,
|
||||
(2,3): 3
|
||||
}
|
||||
# pylint: enable=bad-whitespace
|
||||
|
||||
class ADC_Channel(object):
|
||||
"""Provides per channel access to ADC readings."""
|
||||
|
||||
def __init__(self, adc, channel):
|
||||
self._adc = adc
|
||||
self._channel = channel
|
||||
|
||||
@property
|
||||
def value(self, ):
|
||||
"""ADC reading in raw counts."""
|
||||
return self._adc._read_channel(self._channel) # pylint: disable=protected-access
|
||||
|
||||
@property
|
||||
def volts(self, ):
|
||||
"""ADC reading in volts."""
|
||||
return self._adc._read_channel_volts(self._channel) # pylint: disable=protected-access
|
||||
|
||||
|
||||
class ADS1x15(object):
|
||||
"""Base functionality for ADS1x15 analog to digital converters."""
|
||||
|
||||
def __init__(self, i2c, address=ADS1X15_DEFAULT_ADDRESS):
|
||||
self.buf = bytearray(3)
|
||||
self.i2c_device = I2CDevice(i2c, address)
|
||||
self.bits = None
|
||||
self._channels = [ADC_Channel(self, 0),
|
||||
ADC_Channel(self, 1),
|
||||
ADC_Channel(self, 2),
|
||||
ADC_Channel(self, 3)]
|
||||
|
||||
def _write_register(self, reg, value):
|
||||
"""Write 16 bit value to register."""
|
||||
self.buf[0] = reg
|
||||
self.buf[1] = (value >> 8) & 0xFF
|
||||
self.buf[2] = value & 0xFF
|
||||
with self.i2c_device as i2c:
|
||||
i2c.write(self.buf)
|
||||
|
||||
def _read_register(self, reg):
|
||||
"""Return 16 bit register value as tuple of (LSB, MSB)."""
|
||||
self.buf[0] = reg
|
||||
with self.i2c_device as i2c:
|
||||
i2c.write(self.buf, end=1, stop=False)
|
||||
i2c.readinto(self.buf, start=1)
|
||||
return self.buf[1] << 8 | self.buf[2]
|
||||
|
||||
def _data_rate_default(self):
|
||||
"""Retrieve the default data rate for this ADC (in samples per second).
|
||||
Should be implemented by subclasses.
|
||||
"""
|
||||
raise NotImplementedError('Subclasses must implement _data_rate_default!')
|
||||
|
||||
def _data_rate_config(self, data_rate):
|
||||
"""Subclasses should override this function and return a 16-bit value
|
||||
that can be OR'ed with the config register to set the specified
|
||||
data rate. If a value of None is specified then a default data_rate
|
||||
setting should be returned. If an invalid or unsupported data_rate is
|
||||
provided then an exception should be thrown.
|
||||
"""
|
||||
raise NotImplementedError('Subclass must implement _data_rate_config function!')
|
||||
|
||||
def _conversion_value(self, low, high):
|
||||
"""Subclasses should override this function that takes the low and high
|
||||
byte of a conversion result and returns a signed integer value.
|
||||
"""
|
||||
raise NotImplementedError('Subclass must implement _conversion_value function!')
|
||||
|
||||
def _read_channel(self, channel):
|
||||
"""Subclasses should override this function to return a value for the
|
||||
requested channels as a signed integer value.
|
||||
"""
|
||||
raise NotImplementedError('Subclass must implement _read_channel function!')
|
||||
|
||||
def _read_channel_volts(self, channel):
|
||||
"""Subclasses should override this function to return a value for the
|
||||
requested channels as a float value.
|
||||
"""
|
||||
raise NotImplementedError('Subclass must implement _read_channel_volts function!')
|
||||
|
||||
def _conversion_complete(self):
|
||||
"""Return status of ADC conversion."""
|
||||
# OS is bit 15
|
||||
# OS = 0: Device is currently performing a conversion
|
||||
# OS = 1: Device is not currently performing a conversion
|
||||
return self._read_register(ADS1X15_POINTER_CONFIG) & 0x8000
|
||||
|
||||
def _read(self, mux, gain, data_rate, mode):
|
||||
"""Perform an ADC read with the provided mux, gain, data_rate, and mode
|
||||
values. Returns the signed integer result of the read.
|
||||
"""
|
||||
config = ADS1X15_CONFIG_OS_SINGLE # Go out of power-down mode for conversion.
|
||||
# Specify mux value.
|
||||
config |= (mux & 0x07) << ADS1X15_CONFIG_MUX_OFFSET
|
||||
# Validate the passed in gain and then set it in the config.
|
||||
if gain not in ADS1X15_CONFIG_GAIN:
|
||||
raise ValueError('Gain must be one of: 2/3, 1, 2, 4, 8, 16')
|
||||
config |= ADS1X15_CONFIG_GAIN[gain]
|
||||
# Set the mode (continuous or single shot).
|
||||
config |= mode
|
||||
# Get the default data rate if none is specified (default differs between
|
||||
# ADS1015 and ADS1115).
|
||||
if data_rate is None:
|
||||
data_rate = self._data_rate_default()
|
||||
# Set the data rate (this is controlled by the subclass as it differs
|
||||
# between ADS1015 and ADS1115).
|
||||
config |= self._data_rate_config(data_rate)
|
||||
config |= ADS1X15_CONFIG_COMP_QUE_DISABLE # Disble comparator mode.
|
||||
# Send the config value to start the ADC conversion.
|
||||
self._write_register(ADS1X15_POINTER_CONFIG, config)
|
||||
# Wait for conversion to complete
|
||||
while not self._conversion_complete():
|
||||
time.sleep(0.01)
|
||||
# Return the result
|
||||
return self.get_last_result()
|
||||
|
||||
def stop_adc(self):
|
||||
"""Stop all continuous ADC conversions (either normal or difference mode).
|
||||
"""
|
||||
# Set the config register to its default value of 0x8583 to stop
|
||||
# continuous conversions.
|
||||
self._write_register(ADS1X15_POINTER_CONFIG, 0x8583)
|
||||
|
||||
def get_last_result(self):
|
||||
"""Read the last conversion result when in continuous conversion mode.
|
||||
Will return a signed integer value.
|
||||
"""
|
||||
# Retrieve the conversion register value, convert to a signed int, and
|
||||
# return it.
|
||||
result = self._read_register(ADS1X15_POINTER_CONVERSION)
|
||||
return self._conversion_value(result & 0xff, result >> 8)
|
||||
79
adafruit_ads1x15/ads1015.py
Normal file
79
adafruit_ads1x15/ads1015.py
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2018 Carter Nelson for Adafruit Industries
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
"""
|
||||
`ads1015`
|
||||
====================================================
|
||||
|
||||
CircuitPython driver for ADS1015 ADCs.
|
||||
|
||||
* Author(s): Carter Nelson
|
||||
"""
|
||||
import struct
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from .ads1x15 import ADS1x15, Mode
|
||||
|
||||
# Data sample rates
|
||||
_ADS1015_CONFIG_DR = {
|
||||
128: 0x0000,
|
||||
250: 0x0020,
|
||||
490: 0x0040,
|
||||
920: 0x0060,
|
||||
1600: 0x0080,
|
||||
2400: 0x00A0,
|
||||
3300: 0x00C0,
|
||||
}
|
||||
|
||||
# Pins
|
||||
P0 = 0
|
||||
P1 = 1
|
||||
P2 = 2
|
||||
P3 = 3
|
||||
|
||||
|
||||
class ADS1015(ADS1x15):
|
||||
"""Class for the ADS1015 12 bit ADC."""
|
||||
|
||||
@property
|
||||
def bits(self):
|
||||
"""The ADC bit resolution."""
|
||||
return 12
|
||||
|
||||
@property
|
||||
def rates(self):
|
||||
"""Possible data rate settings."""
|
||||
r = list(_ADS1015_CONFIG_DR.keys())
|
||||
r.sort()
|
||||
return r
|
||||
|
||||
@property
|
||||
def rate_config(self):
|
||||
"""Rate configuration masks."""
|
||||
return _ADS1015_CONFIG_DR
|
||||
|
||||
def _data_rate_default(self):
|
||||
return 1600
|
||||
|
||||
def _conversion_value(self, raw_adc):
|
||||
raw_adc = raw_adc.to_bytes(2, "big")
|
||||
value = struct.unpack(">h", raw_adc)[0]
|
||||
return value >> 4
|
||||
80
adafruit_ads1x15/ads1115.py
Normal file
80
adafruit_ads1x15/ads1115.py
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2018 Carter Nelson for Adafruit Industries
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
"""
|
||||
`ads1115`
|
||||
====================================================
|
||||
|
||||
CircuitPython driver for 1115 ADCs.
|
||||
|
||||
* Author(s): Carter Nelson
|
||||
"""
|
||||
import struct
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from .ads1x15 import ADS1x15, Mode
|
||||
|
||||
# Data sample rates
|
||||
_ADS1115_CONFIG_DR = {
|
||||
8: 0x0000,
|
||||
16: 0x0020,
|
||||
32: 0x0040,
|
||||
64: 0x0060,
|
||||
128: 0x0080,
|
||||
250: 0x00A0,
|
||||
475: 0x00C0,
|
||||
860: 0x00E0,
|
||||
}
|
||||
|
||||
# Pins
|
||||
P0 = 0
|
||||
P1 = 1
|
||||
P2 = 2
|
||||
P3 = 3
|
||||
|
||||
|
||||
class ADS1115(ADS1x15):
|
||||
"""Class for the ADS1115 16 bit ADC."""
|
||||
|
||||
@property
|
||||
def bits(self):
|
||||
"""The ADC bit resolution."""
|
||||
return 16
|
||||
|
||||
@property
|
||||
def rates(self):
|
||||
"""Possible data rate settings."""
|
||||
r = list(_ADS1115_CONFIG_DR.keys())
|
||||
r.sort()
|
||||
return r
|
||||
|
||||
@property
|
||||
def rate_config(self):
|
||||
"""Rate configuration masks."""
|
||||
return _ADS1115_CONFIG_DR
|
||||
|
||||
def _data_rate_default(self):
|
||||
return 128
|
||||
|
||||
def _conversion_value(self, raw_adc):
|
||||
raw_adc = raw_adc.to_bytes(2, "big")
|
||||
value = struct.unpack(">h", raw_adc)[0]
|
||||
return value
|
||||
218
adafruit_ads1x15/ads1x15.py
Normal file
218
adafruit_ads1x15/ads1x15.py
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2018 Carter Nelson for Adafruit Industries
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
"""
|
||||
`ads1x15`
|
||||
====================================================
|
||||
|
||||
CircuitPython base class driver for ADS1015/1115 ADCs.
|
||||
|
||||
* Author(s): Carter Nelson
|
||||
"""
|
||||
|
||||
__version__ = "0.0.0-auto.0"
|
||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15.git"
|
||||
|
||||
import time
|
||||
from micropython import const
|
||||
from adafruit_bus_device.i2c_device import I2CDevice
|
||||
|
||||
# pylint: disable=bad-whitespace
|
||||
_ADS1X15_DEFAULT_ADDRESS = const(0x48)
|
||||
_ADS1X15_POINTER_CONVERSION = const(0x00)
|
||||
_ADS1X15_POINTER_CONFIG = const(0x01)
|
||||
_ADS1X15_CONFIG_OS_SINGLE = const(0x8000)
|
||||
_ADS1X15_CONFIG_MUX_OFFSET = const(12)
|
||||
_ADS1X15_CONFIG_COMP_QUE_DISABLE = const(0x0003)
|
||||
_ADS1X15_CONFIG_GAIN = {
|
||||
2 / 3: 0x0000,
|
||||
1: 0x0200,
|
||||
2: 0x0400,
|
||||
4: 0x0600,
|
||||
8: 0x0800,
|
||||
16: 0x0A00,
|
||||
}
|
||||
# pylint: enable=bad-whitespace
|
||||
|
||||
|
||||
class Mode:
|
||||
"""An enum-like class representing possible ADC operating modes."""
|
||||
|
||||
# See datasheet "Operating Modes" section
|
||||
# values here are masks for setting MODE bit in Config Register
|
||||
# pylint: disable=too-few-public-methods
|
||||
CONTINUOUS = 0x0000
|
||||
SINGLE = 0x0100
|
||||
|
||||
|
||||
class ADS1x15:
|
||||
"""Base functionality for ADS1x15 analog to digital converters."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
i2c,
|
||||
gain=1,
|
||||
data_rate=None,
|
||||
mode=Mode.SINGLE,
|
||||
address=_ADS1X15_DEFAULT_ADDRESS,
|
||||
):
|
||||
# pylint: disable=too-many-arguments
|
||||
self._last_pin_read = None
|
||||
self.buf = bytearray(3)
|
||||
self._data_rate = self._gain = self._mode = None
|
||||
self.gain = gain
|
||||
self.data_rate = self._data_rate_default() if data_rate is None else data_rate
|
||||
self.mode = mode
|
||||
self.i2c_device = I2CDevice(i2c, address)
|
||||
|
||||
@property
|
||||
def data_rate(self):
|
||||
"""The data rate for ADC conversion in samples per second."""
|
||||
return self._data_rate
|
||||
|
||||
@data_rate.setter
|
||||
def data_rate(self, rate):
|
||||
possible_rates = self.rates
|
||||
if rate not in possible_rates:
|
||||
raise ValueError("Data rate must be one of: {}".format(possible_rates))
|
||||
self._data_rate = rate
|
||||
|
||||
@property
|
||||
def rates(self):
|
||||
"""Possible data rate settings."""
|
||||
raise NotImplementedError("Subclass must implement rates property.")
|
||||
|
||||
@property
|
||||
def rate_config(self):
|
||||
"""Rate configuration masks."""
|
||||
raise NotImplementedError("Subclass must implement rate_config property.")
|
||||
|
||||
@property
|
||||
def gain(self):
|
||||
"""The ADC gain."""
|
||||
return self._gain
|
||||
|
||||
@gain.setter
|
||||
def gain(self, gain):
|
||||
possible_gains = self.gains
|
||||
if gain not in possible_gains:
|
||||
raise ValueError("Gain must be one of: {}".format(possible_gains))
|
||||
self._gain = gain
|
||||
|
||||
@property
|
||||
def gains(self):
|
||||
"""Possible gain settings."""
|
||||
g = list(_ADS1X15_CONFIG_GAIN.keys())
|
||||
g.sort()
|
||||
return g
|
||||
|
||||
@property
|
||||
def mode(self):
|
||||
"""The ADC conversion mode."""
|
||||
return self._mode
|
||||
|
||||
@mode.setter
|
||||
def mode(self, mode):
|
||||
if mode not in (Mode.CONTINUOUS, Mode.SINGLE):
|
||||
raise ValueError("Unsupported mode.")
|
||||
self._mode = mode
|
||||
|
||||
def read(self, pin, is_differential=False):
|
||||
"""I2C Interface for ADS1x15-based ADCs reads.
|
||||
|
||||
params:
|
||||
:param pin: individual or differential pin.
|
||||
:param bool is_differential: single-ended or differential read.
|
||||
"""
|
||||
pin = pin if is_differential else pin + 0x04
|
||||
return self._read(pin)
|
||||
|
||||
def _data_rate_default(self):
|
||||
"""Retrieve the default data rate for this ADC (in samples per second).
|
||||
Should be implemented by subclasses.
|
||||
"""
|
||||
raise NotImplementedError("Subclasses must implement _data_rate_default!")
|
||||
|
||||
def _conversion_value(self, raw_adc):
|
||||
"""Subclasses should override this function that takes the 16 raw ADC
|
||||
values of a conversion result and returns a signed integer value.
|
||||
"""
|
||||
raise NotImplementedError("Subclass must implement _conversion_value function!")
|
||||
|
||||
def _read(self, pin):
|
||||
"""Perform an ADC read. Returns the signed integer result of the read."""
|
||||
if self.mode == Mode.CONTINUOUS and self._last_pin_read == pin:
|
||||
return self._conversion_value(self.get_last_result(True))
|
||||
self._last_pin_read = pin
|
||||
if self.mode == Mode.SINGLE:
|
||||
config = _ADS1X15_CONFIG_OS_SINGLE
|
||||
else:
|
||||
config = 0
|
||||
config |= (pin & 0x07) << _ADS1X15_CONFIG_MUX_OFFSET
|
||||
config |= _ADS1X15_CONFIG_GAIN[self.gain]
|
||||
config |= self.mode
|
||||
config |= self.rate_config[self.data_rate]
|
||||
config |= _ADS1X15_CONFIG_COMP_QUE_DISABLE
|
||||
self._write_register(_ADS1X15_POINTER_CONFIG, config)
|
||||
|
||||
if self.mode == Mode.SINGLE:
|
||||
# poll conversion complete status bit
|
||||
while not self._conversion_complete():
|
||||
pass
|
||||
else:
|
||||
# just sleep (can't poll in continuous)
|
||||
time.sleep(2 / self.data_rate)
|
||||
|
||||
return self._conversion_value(self.get_last_result(False))
|
||||
|
||||
def _conversion_complete(self):
|
||||
"""Return status of ADC conversion."""
|
||||
# OS is bit 15
|
||||
# OS = 0: Device is currently performing a conversion
|
||||
# OS = 1: Device is not currently performing a conversion
|
||||
return self._read_register(_ADS1X15_POINTER_CONFIG) & 0x8000
|
||||
|
||||
def get_last_result(self, fast=False):
|
||||
"""Read the last conversion result when in continuous conversion mode.
|
||||
Will return a signed integer value. If fast is True, the register
|
||||
pointer is not updated as part of the read. This reduces I2C traffic
|
||||
and increases possible read rate.
|
||||
"""
|
||||
return self._read_register(_ADS1X15_POINTER_CONVERSION, fast)
|
||||
|
||||
def _write_register(self, reg, value):
|
||||
"""Write 16 bit value to register."""
|
||||
self.buf[0] = reg
|
||||
self.buf[1] = (value >> 8) & 0xFF
|
||||
self.buf[2] = value & 0xFF
|
||||
with self.i2c_device as i2c:
|
||||
i2c.write(self.buf)
|
||||
|
||||
def _read_register(self, reg, fast=False):
|
||||
"""Read 16 bit register value. If fast is True, the pointer register
|
||||
is not updated.
|
||||
"""
|
||||
with self.i2c_device as i2c:
|
||||
if fast:
|
||||
i2c.readinto(self.buf, end=2)
|
||||
else:
|
||||
i2c.write_then_readinto(bytearray([reg]), self.buf, in_end=2)
|
||||
return self.buf[0] << 8 | self.buf[1]
|
||||
73
adafruit_ads1x15/analog_in.py
Normal file
73
adafruit_ads1x15/analog_in.py
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2018 Carter Nelson for Adafruit
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
"""
|
||||
`analog_in`
|
||||
==============================
|
||||
AnalogIn for single-ended and
|
||||
differential ADC readings.
|
||||
|
||||
* Author(s): Carter Nelson, adapted from MCP3xxx original by Brent Rubell
|
||||
"""
|
||||
|
||||
# pylint: disable=bad-whitespace
|
||||
_ADS1X15_DIFF_CHANNELS = {(0, 1): 0, (0, 3): 1, (1, 3): 2, (2, 3): 3}
|
||||
_ADS1X15_PGA_RANGE = {2 / 3: 6.144, 1: 4.096, 2: 2.048, 4: 1.024, 8: 0.512, 16: 0.256}
|
||||
# pylint: enable=bad-whitespace
|
||||
|
||||
|
||||
class AnalogIn:
|
||||
"""AnalogIn Mock Implementation for ADC Reads."""
|
||||
|
||||
def __init__(self, ads, positive_pin, negative_pin=None):
|
||||
"""AnalogIn
|
||||
|
||||
:param ads: The ads object.
|
||||
:param ~digitalio.DigitalInOut positive_pin: Required pin for single-ended.
|
||||
:param ~digitalio.DigitalInOut negative_pin: Optional pin for differential reads.
|
||||
"""
|
||||
self._ads = ads
|
||||
self._pin_setting = positive_pin
|
||||
self._negative_pin = negative_pin
|
||||
self.is_differential = False
|
||||
if negative_pin is not None:
|
||||
pins = (self._pin_setting, self._negative_pin)
|
||||
if pins not in _ADS1X15_DIFF_CHANNELS:
|
||||
raise ValueError(
|
||||
"Differential channels must be one of: {}".format(
|
||||
list(_ADS1X15_DIFF_CHANNELS.keys())
|
||||
)
|
||||
)
|
||||
self._pin_setting = _ADS1X15_DIFF_CHANNELS[pins]
|
||||
self.is_differential = True
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
"""Returns the value of an ADC pin as an integer."""
|
||||
return self._ads.read(
|
||||
self._pin_setting, is_differential=self.is_differential
|
||||
) << (16 - self._ads.bits)
|
||||
|
||||
@property
|
||||
def voltage(self):
|
||||
"""Returns the voltage from the ADC pin as a floating point value."""
|
||||
volts = self.value * _ADS1X15_PGA_RANGE[self._ads.gain] / 32767
|
||||
return volts
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2017 Carter Nelson for Adafruit Industries
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
"""
|
||||
`adafruit_ads1x15.differential`
|
||||
====================================================
|
||||
|
||||
Differential driver for ADS1015/1115 ADCs.
|
||||
|
||||
* Author(s): Carter Nelson
|
||||
"""
|
||||
|
||||
__version__ = "0.0.0-auto.0"
|
||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15.git"
|
||||
|
||||
from .adafruit_ads1x15 import ADS1x15, ADS1X15_DIFF_CHANNELS
|
||||
from .adafruit_ads1x15 import ADS1X15_CONFIG_MODE_SINGLE, ADS1X15_CONFIG_MODE_CONTINUOUS
|
||||
from .adafruit_ads1x15 import ADS1X15_PGA_RANGE, ADS1015_CONFIG_DR, ADS1115_CONFIG_DR
|
||||
|
||||
# pylint: disable=abstract-method
|
||||
class ADS1x15_Differential(ADS1x15):
|
||||
"""Base functionality for ADS1x15 analog to digital converters operating
|
||||
in differential mode."""
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self._channels[ADS1X15_DIFF_CHANNELS[key]]
|
||||
|
||||
def read_adc_difference(self, differential, gain=1, data_rate=None):
|
||||
"""Read the difference between two ADC channels and return the ADC value
|
||||
as a signed integer result. Differential must be one of:
|
||||
- 0 = Channel 0 minus channel 1
|
||||
- 1 = Channel 0 minus channel 3
|
||||
- 2 = Channel 1 minus channel 3
|
||||
- 3 = Channel 2 minus channel 3
|
||||
"""
|
||||
if not 0 <= differential <= 3:
|
||||
raise ValueError('Differential must be a value within 0-3!')
|
||||
# Perform a single shot read using the provided differential value
|
||||
# as the mux value (which will enable differential mode).
|
||||
return self._read(differential, gain, data_rate, ADS1X15_CONFIG_MODE_SINGLE)
|
||||
|
||||
def read_volts_difference(self, differential, gain=1, data_rate=None):
|
||||
"""Read the difference between two ADC channels and return the voltage value
|
||||
as a floating point result. Differential must be one of:
|
||||
- 0 = Channel 0 minus channel 1
|
||||
- 1 = Channel 0 minus channel 3
|
||||
- 2 = Channel 1 minus channel 3
|
||||
- 3 = Channel 2 minus channel 3
|
||||
"""
|
||||
if not 0 <= differential <= 3:
|
||||
raise ValueError('Differential must be a value within 0-3!')
|
||||
raw = self.read_adc_difference(differential, gain, data_rate)
|
||||
volts = raw * (ADS1X15_PGA_RANGE[gain] / (2**(self.bits-1) - 1))
|
||||
return volts
|
||||
|
||||
def start_adc_difference(self, differential, gain=1, data_rate=None):
|
||||
"""Start continuous ADC conversions between two ADC channels. Differential
|
||||
must be one of:
|
||||
- 0 = Channel 0 minus channel 1
|
||||
- 1 = Channel 0 minus channel 3
|
||||
- 2 = Channel 1 minus channel 3
|
||||
- 3 = Channel 2 minus channel 3
|
||||
Will return an initial conversion result, then call the get_last_result()
|
||||
function continuously to read the most recent conversion result. Call
|
||||
stop_adc() to stop conversions.
|
||||
"""
|
||||
if not 0 <= differential <= 3:
|
||||
raise ValueError('Differential must be a value within 0-3!')
|
||||
# Perform a single shot read using the provided differential value
|
||||
# as the mux value (which will enable differential mode).
|
||||
return self._read(differential, gain, data_rate, ADS1X15_CONFIG_MODE_CONTINUOUS)
|
||||
# pylint: enable=abstract-method
|
||||
|
||||
class ADS1015(ADS1x15_Differential):
|
||||
"""ADS1015 12-bit differential analog to digital converter instance."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ADS1015, self).__init__(*args, **kwargs)
|
||||
self.bits = 12
|
||||
|
||||
def _data_rate_default(self):
|
||||
# Default from datasheet page 19, config register DR bit default.
|
||||
return 1600
|
||||
|
||||
def _data_rate_config(self, data_rate):
|
||||
if data_rate not in ADS1015_CONFIG_DR:
|
||||
raise ValueError('Data rate must be one of: 128, 250, 490, 920, 1600, 2400, 3300')
|
||||
return ADS1015_CONFIG_DR[data_rate]
|
||||
|
||||
def _conversion_value(self, low, high):
|
||||
# Convert to 12-bit signed value.
|
||||
value = ((high & 0xFF) << 4) | ((low & 0xFF) >> 4)
|
||||
# Check for sign bit and turn into a negative value if set.
|
||||
if value & 0x800 != 0:
|
||||
value -= 1 << 12
|
||||
return value
|
||||
|
||||
def _read_channel(self, channel):
|
||||
return self.read_adc_difference(channel)
|
||||
|
||||
def _read_channel_volts(self, channel):
|
||||
return self.read_volts_difference(channel)
|
||||
|
||||
|
||||
class ADS1115(ADS1x15_Differential):
|
||||
"""ADS1115 16-bit differential analog to digital converter instance."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ADS1115, self).__init__(*args, **kwargs)
|
||||
self.bits = 16
|
||||
|
||||
def _data_rate_default(self):
|
||||
# Default from datasheet page 16, config register DR bit default.
|
||||
return 128
|
||||
|
||||
def _data_rate_config(self, data_rate):
|
||||
if data_rate not in ADS1115_CONFIG_DR:
|
||||
raise ValueError('Data rate must be one of: 8, 16, 32, 64, 128, 250, 475, 860')
|
||||
return ADS1115_CONFIG_DR[data_rate]
|
||||
|
||||
def _conversion_value(self, low, high):
|
||||
# Convert to 16-bit signed value.
|
||||
value = ((high & 0xFF) << 8) | (low & 0xFF)
|
||||
# Check for sign bit and turn into a negative value if set.
|
||||
if value & 0x8000 != 0:
|
||||
value -= 1 << 16
|
||||
return value
|
||||
|
||||
def _read_channel(self, channel):
|
||||
return self.read_adc_difference(channel)
|
||||
|
||||
def _read_channel_volts(self, channel):
|
||||
return self.read_volts_difference(channel)
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2017 Carter Nelson for Adafruit Industries
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
"""
|
||||
`adafruit_ads1x15.single_ended`
|
||||
====================================================
|
||||
|
||||
Single-ended driver for ADS1015/1115 ADCs.
|
||||
|
||||
* Author(s): Carter Nelson
|
||||
"""
|
||||
|
||||
__version__ = "0.0.0-auto.0"
|
||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15.git"
|
||||
|
||||
from .adafruit_ads1x15 import ADS1x15
|
||||
from .adafruit_ads1x15 import ADS1X15_CONFIG_MODE_SINGLE, ADS1X15_CONFIG_MODE_CONTINUOUS
|
||||
from .adafruit_ads1x15 import ADS1X15_PGA_RANGE, ADS1015_CONFIG_DR, ADS1115_CONFIG_DR
|
||||
|
||||
# pylint: disable=abstract-method
|
||||
class ADS1x15_SingleEnded(ADS1x15):
|
||||
"""Base functionality for ADS1x15 analog to digital converters operating
|
||||
in single ended mode."""
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self._channels[key]
|
||||
|
||||
def read_adc(self, channel, gain=1, data_rate=None):
|
||||
"""Read a single ADC channel and return the ADC value as a signed integer
|
||||
result. Channel must be a value within 0-3.
|
||||
"""
|
||||
if not 0 <= channel <= 3:
|
||||
raise ValueError('Channel must be a value within 0-3!')
|
||||
# Perform a single shot read and set the mux value to the channel plus
|
||||
# the highest bit (bit 3) set.
|
||||
return self._read(channel + 0x04, gain, data_rate, ADS1X15_CONFIG_MODE_SINGLE)
|
||||
|
||||
def read_volts(self, channel, gain=1, data_rate=None):
|
||||
"""Read a single ADC channel and return the voltage value as a floating point
|
||||
result. Channel must be a value within 0-3.
|
||||
"""
|
||||
if not 0 <= channel <= 3:
|
||||
raise ValueError('Channel must be a value within 0-3!')
|
||||
raw = self.read_adc(channel, gain, data_rate)
|
||||
volts = raw * (ADS1X15_PGA_RANGE[gain] / (2**(self.bits-1) - 1))
|
||||
return volts
|
||||
|
||||
def start_adc(self, channel, gain=1, data_rate=None):
|
||||
"""Start continuous ADC conversions on the specified channel (0-3). Will
|
||||
return an initial conversion result, then call the get_last_result()
|
||||
function to read the most recent conversion result. Call stop_adc() to
|
||||
stop conversions.
|
||||
"""
|
||||
if not 0 <= channel <= 3:
|
||||
raise ValueError('Channel must be a value within 0-3!')
|
||||
# Start continuous reads and set the mux value to the channel plus
|
||||
# the highest bit (bit 3) set.
|
||||
return self._read(channel + 0x04, gain, data_rate, ADS1X15_CONFIG_MODE_CONTINUOUS)
|
||||
# pylint: enable=abstract-method
|
||||
|
||||
class ADS1015(ADS1x15_SingleEnded):
|
||||
"""ADS1015 12-bit single ended analog to digital converter instance."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ADS1015, self).__init__(*args, **kwargs)
|
||||
self.bits = 12
|
||||
|
||||
def _data_rate_default(self):
|
||||
# Default from datasheet page 19, config register DR bit default.
|
||||
return 1600
|
||||
|
||||
def _data_rate_config(self, data_rate):
|
||||
if data_rate not in ADS1015_CONFIG_DR:
|
||||
raise ValueError('Data rate must be one of: 128, 250, 490, 920, 1600, 2400, 3300')
|
||||
return ADS1015_CONFIG_DR[data_rate]
|
||||
|
||||
def _conversion_value(self, low, high):
|
||||
# Convert to 12-bit signed value.
|
||||
value = ((high & 0xFF) << 4) | ((low & 0xFF) >> 4)
|
||||
# Check for sign bit and turn into a negative value if set.
|
||||
if value & 0x800 != 0:
|
||||
value -= 1 << 12
|
||||
return value
|
||||
|
||||
def _read_channel(self, channel):
|
||||
return self.read_adc(channel)
|
||||
|
||||
def _read_channel_volts(self, channel):
|
||||
return self.read_volts(channel)
|
||||
|
||||
|
||||
class ADS1115(ADS1x15_SingleEnded):
|
||||
"""ADS1115 16-bit single ended analog to digital converter instance."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ADS1115, self).__init__(*args, **kwargs)
|
||||
self.bits = 16
|
||||
|
||||
def _data_rate_default(self):
|
||||
# Default from datasheet page 16, config register DR bit default.
|
||||
return 128
|
||||
|
||||
def _data_rate_config(self, data_rate):
|
||||
if data_rate not in ADS1115_CONFIG_DR:
|
||||
raise ValueError('Data rate must be one of: 8, 16, 32, 64, 128, 250, 475, 860')
|
||||
return ADS1115_CONFIG_DR[data_rate]
|
||||
|
||||
def _conversion_value(self, low, high):
|
||||
# Convert to 16-bit signed value.
|
||||
value = ((high & 0xFF) << 8) | (low & 0xFF)
|
||||
# Check for sign bit and turn into a negative value if set.
|
||||
if value & 0x8000 != 0:
|
||||
value -= 1 << 16
|
||||
return value
|
||||
|
||||
def _read_channel(self, channel):
|
||||
return self.read_adc(channel)
|
||||
|
||||
def _read_channel_volts(self, channel):
|
||||
return self.read_volts(channel)
|
||||
|
|
@ -1,11 +1,14 @@
|
|||
|
||||
.. If you created a package, create one automodule per module in the package.
|
||||
|
||||
.. automodule:: adafruit_ads1x15.adafruit_ads1x15
|
||||
.. automodule:: adafruit_ads1x15.ads1x15
|
||||
:members:
|
||||
|
||||
.. automodule:: adafruit_ads1x15.differential
|
||||
.. automodule:: adafruit_ads1x15.ads1015
|
||||
:members:
|
||||
|
||||
.. automodule:: adafruit_ads1x15.single_ended
|
||||
.. automodule:: adafruit_ads1x15.ads1115
|
||||
:members:
|
||||
|
||||
.. automodule:: adafruit_ads1x15.analog_in
|
||||
:members:
|
||||
118
docs/conf.py
118
docs/conf.py
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath('..'))
|
||||
|
||||
sys.path.insert(0, os.path.abspath(".."))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
|
|
@ -10,34 +11,45 @@ sys.path.insert(0, os.path.abspath('..'))
|
|||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.viewcode',
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.intersphinx",
|
||||
"sphinx.ext.viewcode",
|
||||
]
|
||||
|
||||
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
|
||||
intersphinx_mapping = {
|
||||
"python": ("https://docs.python.org/3.4", None),
|
||||
"BusDevice": (
|
||||
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
|
||||
None,
|
||||
),
|
||||
"Register": (
|
||||
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
|
||||
None,
|
||||
),
|
||||
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
|
||||
}
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Adafruit CIRCUITPYTHON_ADS1X15 Library'
|
||||
copyright = u'2017 Carter Nelson'
|
||||
author = u'Carter Nelson'
|
||||
project = "Adafruit CIRCUITPYTHON_ADS1X15 Library"
|
||||
copyright = "2017 Carter Nelson"
|
||||
author = "Carter Nelson"
|
||||
|
||||
# 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 = u'1.0'
|
||||
version = "1.0"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = u'1.0'
|
||||
release = "1.0"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
|
@ -49,7 +61,7 @@ language = None
|
|||
# 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']
|
||||
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.
|
||||
|
|
@ -61,7 +73,7 @@ default_role = "any"
|
|||
add_function_parentheses = True
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = False
|
||||
|
|
@ -75,59 +87,62 @@ todo_emit_warnings = True
|
|||
# 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'
|
||||
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(), '.']
|
||||
|
||||
html_theme = "sphinx_rtd_theme"
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
|
||||
except:
|
||||
html_theme = 'default'
|
||||
html_theme_path = ['.']
|
||||
html_theme = "default"
|
||||
html_theme_path = ["."]
|
||||
else:
|
||||
html_theme_path = ['.']
|
||||
html_theme_path = ["."]
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
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'
|
||||
html_favicon = "_static/favicon.ico"
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'AdafruitCIRCUITPYTHON_ADS1X15Librarydoc'
|
||||
htmlhelp_basename = "AdafruitCIRCUITPYTHON_ADS1X15Librarydoc"
|
||||
|
||||
# -- 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',
|
||||
# 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, 'AdafruitCIRCUITPYTHON_ADS1X15Library.tex', u'Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation',
|
||||
author, 'manual'),
|
||||
(
|
||||
master_doc,
|
||||
"AdafruitCIRCUITPYTHON_ADS1X15Library.tex",
|
||||
"Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation",
|
||||
author,
|
||||
"manual",
|
||||
),
|
||||
]
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
|
@ -135,8 +150,13 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'adafruitCIRCUITPYTHON_ADS1X15library', u'Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation',
|
||||
[author], 1)
|
||||
(
|
||||
master_doc,
|
||||
"adafruitCIRCUITPYTHON_ADS1X15library",
|
||||
"Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation",
|
||||
[author],
|
||||
1,
|
||||
)
|
||||
]
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
|
@ -145,7 +165,13 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'AdafruitCIRCUITPYTHON_ADS1X15Library', u'Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation',
|
||||
author, 'AdafruitCIRCUITPYTHON_ADS1X15Library', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
master_doc,
|
||||
"AdafruitCIRCUITPYTHON_ADS1X15Library",
|
||||
"Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation",
|
||||
author,
|
||||
"AdafruitCIRCUITPYTHON_ADS1X15Library",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ Simple test
|
|||
|
||||
Ensure your device works with this simple test.
|
||||
|
||||
.. literalinclude:: ../examples/ads1115_single_ended_simpletest.py
|
||||
:caption: examples/ads1115_single_ended_simpletest.py
|
||||
.. literalinclude:: ../examples/ads1x15_simpletest.py
|
||||
:caption: examples/ads1x15_ads1015_simpletest.py
|
||||
:linenos:
|
||||
|
||||
.. literalinclude:: ../examples/ads1115_differential_simpletest.py
|
||||
:caption: examples/ads1115_differential_simpletest.py
|
||||
.. literalinclude:: ../examples/ads1x15_ads1115_simpletest.py
|
||||
:caption: examples/ads1x15_ads1115_simpletest.py
|
||||
:linenos:
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
import time
|
||||
import board
|
||||
import busio
|
||||
from adafruit_ads1x15.differential import ADS1115
|
||||
|
||||
# Create the I2C bus
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
|
||||
# Create the ADC object using the I2C bus
|
||||
adc = ADS1115(i2c)
|
||||
|
||||
# Print header
|
||||
print("CHAN 0 - CHAN 1")
|
||||
print("{:>5}\t{:>5}".format('raw', 'v'))
|
||||
|
||||
while True:
|
||||
# Get raw reading for differential input between channel 0 and 1
|
||||
raw = adc[(0, 1)].value
|
||||
|
||||
# Get voltage reading for differential input between channel 0 and 1
|
||||
volts = adc[(0, 1)].volts
|
||||
|
||||
# Print results
|
||||
print("{:>5}\t{:>5.3f}".format(raw, volts))
|
||||
|
||||
# Sleep for a bit
|
||||
time.sleep(0.5)
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
import time
|
||||
import board
|
||||
import busio
|
||||
from adafruit_ads1x15.single_ended import ADS1115
|
||||
|
||||
# Create the I2C bus
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
|
||||
# Create the ADC object using the I2C bus
|
||||
adc = ADS1115(i2c)
|
||||
|
||||
# Print header
|
||||
print(" CHAN 0 CHAN 1 CHAN 2 CHAN 3")
|
||||
print("{:>5}\t{:>5}\t{:>5}\t{:>5}\t{:>5}\t{:>5}\t{:>5}\t{:>5}"
|
||||
.format('raw', 'v', 'raw', 'v', 'raw', 'v', 'raw', 'v'))
|
||||
|
||||
while True:
|
||||
# Get raw readings for each channel
|
||||
r0 = adc[0].value
|
||||
r1 = adc[1].value
|
||||
r2 = adc[2].value
|
||||
r3 = adc[3].value
|
||||
|
||||
# Get voltage readings for each channel
|
||||
v0 = adc[0].volts
|
||||
v1 = adc[1].volts
|
||||
v2 = adc[2].volts
|
||||
v3 = adc[3].volts
|
||||
|
||||
# Print results
|
||||
print("{:>5}\t{:>5.3f}\t{:>5}\t{:>5.3f}\t{:>5}\t{:>5.3f}\t{:>5}\t{:>5.3f}"
|
||||
.format(r0, v0, r1, v1, r2, v2, r3, v3))
|
||||
|
||||
# Sleep for a bit
|
||||
time.sleep(0.5)
|
||||
25
examples/ads1x15_ads1115_simpletest.py
Normal file
25
examples/ads1x15_ads1115_simpletest.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import time
|
||||
import board
|
||||
import busio
|
||||
import adafruit_ads1x15.ads1115 as ADS
|
||||
from adafruit_ads1x15.analog_in import AnalogIn
|
||||
|
||||
# Create the I2C bus
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
|
||||
# Create the ADC object using the I2C bus
|
||||
ads = ADS.ADS1115(i2c)
|
||||
# you can specify an I2C adress instead of the default 0x48
|
||||
# ads = ADS.ADS1115(i2c, address=0x49)
|
||||
|
||||
# Create single-ended input on channel 0
|
||||
chan = AnalogIn(ads, ADS.P0)
|
||||
|
||||
# Create differential input between channel 0 and 1
|
||||
# chan = AnalogIn(ads, ADS.P0, ADS.P1)
|
||||
|
||||
print("{:>5}\t{:>5}".format("raw", "v"))
|
||||
|
||||
while True:
|
||||
print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
|
||||
time.sleep(0.5)
|
||||
37
examples/ads1x15_fast_read.py
Normal file
37
examples/ads1x15_fast_read.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import time
|
||||
import board
|
||||
import busio
|
||||
import adafruit_ads1x15.ads1015 as ADS
|
||||
from adafruit_ads1x15.ads1x15 import Mode
|
||||
from adafruit_ads1x15.analog_in import AnalogIn
|
||||
|
||||
# Data collection setup
|
||||
RATE = 3300
|
||||
SAMPLES = 1000
|
||||
|
||||
# Create the I2C bus with a fast frequency
|
||||
i2c = busio.I2C(board.SCL, board.SDA, frequency=1000000)
|
||||
|
||||
# Create the ADC object using the I2C bus
|
||||
ads = ADS.ADS1015(i2c)
|
||||
|
||||
# Create single-ended input on channel 0
|
||||
chan0 = AnalogIn(ads, ADS.P0)
|
||||
|
||||
# ADC Configuration
|
||||
ads.mode = Mode.CONTINUOUS
|
||||
ads.data_rate = RATE
|
||||
|
||||
data = [None] * SAMPLES
|
||||
|
||||
start = time.monotonic()
|
||||
|
||||
# Read the same channel over and over
|
||||
for i in range(SAMPLES):
|
||||
data[i] = chan0.value
|
||||
|
||||
end = time.monotonic()
|
||||
total_time = end - start
|
||||
|
||||
print("Time of capture: {}s".format(total_time))
|
||||
print("Sample rate requested={} actual={}".format(RATE, SAMPLES / total_time))
|
||||
41
examples/ads1x15_gain_example.py
Normal file
41
examples/ads1x15_gain_example.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import time
|
||||
import board
|
||||
import busio
|
||||
|
||||
# import adafruit_ads1x15.ads1015 as ADS
|
||||
import adafruit_ads1x15.ads1115 as ADS
|
||||
from adafruit_ads1x15.analog_in import AnalogIn
|
||||
|
||||
# Create the I2C bus
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
|
||||
# Create the ADS object
|
||||
# ads = ADS.ADS1015(i2c)
|
||||
ads = ADS.ADS1115(i2c)
|
||||
|
||||
# Create a sinlge ended channel on Pin 0
|
||||
# Max counts for ADS1015 = 2047
|
||||
# ADS1115 = 32767
|
||||
chan = AnalogIn(ads, ADS.P0)
|
||||
|
||||
# The ADS1015 and ADS1115 both have the same gain options.
|
||||
#
|
||||
# GAIN RANGE (V)
|
||||
# ---- ---------
|
||||
# 2/3 +/- 6.144
|
||||
# 1 +/- 4.096
|
||||
# 2 +/- 2.048
|
||||
# 4 +/- 1.024
|
||||
# 8 +/- 0.512
|
||||
# 16 +/- 0.256
|
||||
#
|
||||
gains = (2 / 3, 1, 2, 4, 8, 16)
|
||||
|
||||
while True:
|
||||
ads.gain = gains[0]
|
||||
print("{:5} {:5.3f}".format(chan.value, chan.voltage), end="")
|
||||
for gain in gains[1:]:
|
||||
ads.gain = gain
|
||||
print(" | {:5} {:5.3f}".format(chan.value, chan.voltage), end="")
|
||||
print()
|
||||
time.sleep(0.5)
|
||||
23
examples/ads1x15_simpletest.py
Normal file
23
examples/ads1x15_simpletest.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import time
|
||||
import board
|
||||
import busio
|
||||
import adafruit_ads1x15.ads1015 as ADS
|
||||
from adafruit_ads1x15.analog_in import AnalogIn
|
||||
|
||||
# Create the I2C bus
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
|
||||
# Create the ADC object using the I2C bus
|
||||
ads = ADS.ADS1015(i2c)
|
||||
|
||||
# Create single-ended input on channel 0
|
||||
chan = AnalogIn(ads, ADS.P0)
|
||||
|
||||
# Create differential input between channel 0 and 1
|
||||
# chan = AnalogIn(ads, ADS.P0, ADS.P1)
|
||||
|
||||
print("{:>5}\t{:>5}".format("raw", "v"))
|
||||
|
||||
while True:
|
||||
print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
|
||||
time.sleep(0.5)
|
||||
53
setup.py
53
setup.py
|
|
@ -6,6 +6,7 @@ https://github.com/pypa/sampleproject
|
|||
"""
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
# To use a consistent encoding
|
||||
from codecs import open
|
||||
from os import path
|
||||
|
|
@ -13,50 +14,38 @@ from os import path
|
|||
here = path.abspath(path.dirname(__file__))
|
||||
|
||||
# Get the long description from the README file
|
||||
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
|
||||
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
|
||||
long_description = f.read()
|
||||
|
||||
setup(
|
||||
name='adafruit-circuitpython-ads1x15',
|
||||
|
||||
name="adafruit-circuitpython-ads1x15",
|
||||
use_scm_version=True,
|
||||
setup_requires=['setuptools_scm'],
|
||||
|
||||
description='CircuitPython library for controlling an ADS1x15 ADC.',
|
||||
setup_requires=["setuptools_scm"],
|
||||
description="CircuitPython library for controlling an ADS1x15 ADC.",
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/x-rst',
|
||||
|
||||
long_description_content_type="text/x-rst",
|
||||
# The project's main homepage.
|
||||
url='https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15',
|
||||
|
||||
url="https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15",
|
||||
# Author details
|
||||
author='Adafruit Industries',
|
||||
author_email='circuitpython@adafruit.com',
|
||||
|
||||
install_requires=[
|
||||
'Adafruit-Blinka',
|
||||
'adafruit-circuitpython-busdevice'
|
||||
],
|
||||
|
||||
author="Adafruit Industries",
|
||||
author_email="circuitpython@adafruit.com",
|
||||
install_requires=["Adafruit-Blinka", "adafruit-circuitpython-busdevice"],
|
||||
# Choose your license
|
||||
license='MIT',
|
||||
|
||||
license="MIT",
|
||||
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Developers',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: System :: Hardware',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Developers",
|
||||
"Topic :: Software Development :: Libraries",
|
||||
"Topic :: System :: Hardware",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.4",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
],
|
||||
|
||||
# What does your project relate to?
|
||||
keywords='adafruit ads1x115 adc hardware micropython circuitpython',
|
||||
|
||||
keywords="adafruit ads1x115 adc hardware micropython circuitpython",
|
||||
# You can just specify the packages manually here if your project is
|
||||
# simple. Or you can use find_packages().
|
||||
packages=['adafruit_ads1x15'],
|
||||
packages=["adafruit_ads1x15"],
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue