Compare commits

...

53 commits

Author SHA1 Message Date
86b09efaab remove bad-whitespace pylint directive 2020-08-23 11:01:51 -05:00
Scott Shawcroft
ebe44a1389
Merge pull request #22 from adafruit/black-update
Black reformatting with Python 3 target.
2020-04-08 10:12:41 -07:00
Kattni Rembor
197157afec Black reformatting with Python 3 target. 2020-04-08 13:01:05 -04:00
sommersoft
09142ef74d build.yml: add black formatting check
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-04-07 16:10:46 -05:00
Kattni
c4f014aef1
Merge pull request #21 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2020-03-23 16:38:43 -04:00
dherrada
a82399df8c Ran black, updated to pylint 2.x 2020-03-20 20:59:18 -04:00
sommersoft
e2836e994e update build.yml to pip install pylint black sphinx
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-03-17 20:09:25 -05:00
sommersoft
f08d3cbfb8 update pylintrc for black
Signed-off-by: sommersoft <sommersoft@gmail.com>
2020-03-17 20:09:22 -05:00
sommersoft
1e1b552709
Merge pull request #20 from sommersoft/patch_coc_2
Update Code of Conduct
2020-03-15 23:39:30 -05:00
sommersoft
2d0910549e update code of conduct 2020-03-15 23:32:01 -05:00
Carter Nelson
e0d80f61d2
Merge pull request #19 from caternuson/iss18
Change proximity to a property
2020-03-10 16:24:22 -07:00
caternuson
637de6b55c change proximity to a property 2020-03-10 10:56:18 -07:00
dherrada
d27d18139d
Update pylint examples directive 2020-01-23 10:49:16 -05:00
Limor "Ladyada" Fried
459c2731e0
Merge pull request #15 from adafruit/dherrada-patch-1
Moved repository from Travis to GitHub Actions
2019-12-27 23:47:08 -05:00
dherrada
1930cd4b15 Moved repository from Travis to GitHub Actions 2019-12-27 22:23:26 -05:00
Melissa LeBlanc-Williams
905fcfc221
Merge pull request #14 from kattni/fix-up
Update version info, README
2019-09-25 10:44:36 -07:00
Kattni Rembor
2a467d7ad7 Update version info, README 2019-09-25 12:53:00 -04:00
jerryneedell
6324f277bf
Merge pull request #13 from tannewt/remove_stop
Remove stop kwarg and use write_then_readinto.
2019-08-23 08:06:50 -04:00
Scott Shawcroft
a4315e2735
Remove stop kwarg and use write_then_readinto.
See https://github.com/adafruit/circuitpython/issues/2082 for details.
2019-08-21 16:36:32 -07:00
Carter Nelson
68f818fce8
Merge pull request #12 from s-light/patch-1
Removed unused `int_pin` from example.
2019-04-01 16:07:24 -07:00
Stefan Krüger
af6264b1f3
removed unused int_pin 2019-04-02 00:10:50 +02:00
Kattni
7905415b5b
Merge pull request #11 from sommersoft/readme_fix_travis
Update README Travis Badge
2018-12-21 13:46:37 -06:00
sommersoft
d89c478fdb change 'travis-ci.org' to 'travis-ci.com' 2018-12-21 13:27:20 -06:00
Brennen Bearnes
25987347a0
Merge pull request #10 from adafruit/pylint-version-fix
pylint version fix
2018-12-05 12:35:56 -07:00
Kattni
71e30e3ecd
pylint version fix 2018-12-03 17:22:20 -05:00
Brennen Bearnes
133849a498
Merge pull request #9 from adafruit/pypi-readme-update
PyPI installation added to README
2018-10-31 17:55:48 -06:00
Kattni
6f16ec841d
PyPI installtion added to README 2018-10-31 16:54:14 -04:00
sommersoft
589e3e928d ignore the board module imports in .pylintrc
Signed-off-by: sommersoft <sommersoft@gmail.com>
2018-08-25 14:01:52 +00:00
Limor "Ladyada" Fried
bedf020361
Update apds9960_proximity_simpletest.py
use a universally known pin
2018-07-03 16:33:30 -04:00
Limor "Ladyada" Fried
ab802b2f26
Update apds9960_color_simpletest.py
use a universally known pin
2018-07-03 16:33:12 -04:00
Brennen Bearnes
65cab9d8e7 setup.py: add adafruit-circuitpython-register to dependencies 2018-07-03 14:32:36 -06:00
Brennen Bearnes
3a0b108980 add setup.py, add pypi to .travis.yml, misc. tweaks for pypi, .gitignore
Per instructions at:

adafruit/circuitpython#979
2018-07-03 14:11:01 -06:00
Scott Shawcroft
bb1b172214
Merge pull request #8 from tannewt/fix_register_in_docs
Mock micropython ourselves so const passes values through unchanged.
2018-03-19 09:44:45 -07:00
Scott Shawcroft
cc20be656f Mock micropython ourselves so const passes values through unchanged.
The automock wraps everything in a MockObject.
2018-03-19 00:01:41 -07:00
Kattni
becfa166b9
Merge pull request #7 from sommersoft/new_docs
Added LICENSE
2018-03-17 17:36:50 -04:00
sommersoft
09c3b177c0 Merge branch 'new_docs' of https://github.com/sommersoft/Adafruit_CircuitPython_APDS9960 into new_docs 2018-03-16 19:10:22 -05:00
sommersoft
dca8d46a3a added LICENSE 2018-03-16 19:09:09 -05:00
Kattni
4e68900535
Merge pull request #6 from sommersoft/new_docs
Improve Ref Docs
2018-03-11 19:03:11 -04:00
sommersoft
74ebe51e45
intersphinx mapping; parens closing & missing arg 2018-03-11 18:01:28 -05:00
sommersoft
ea51fb67d1
updated conf.py; removed errant space in intersphinx mapping 2018-03-11 17:55:27 -05:00
sommersoft
e8e4d19b61 added conf.py Bus Device intersphinx link 2018-03-10 09:15:01 -06:00
sommersoft
923de52f38 updated README; added Travis badge 2018-03-10 09:07:17 -06:00
Kattni
047c898d17
Merge pull request #4 from sommersoft/new_docs
Improve Ref Docs
2018-02-23 16:44:42 -05:00
sommersoft
41b423f200 updated README 2018-02-22 23:18:55 -06:00
sommersoft
c096261440 updated .travis & .readthedocs yml 2018-02-22 23:17:18 -06:00
sommersoft
24245ad6f6 setup docs folder 2018-02-22 23:15:19 -06:00
sommersoft
2023e77de0 renamed examples 2018-02-22 23:07:49 -06:00
Scott Shawcroft
8ff7f19c32
Merge pull request #3 from brentru/readthedocs-badge
rtd badge + corrected url
2018-02-14 17:47:49 -08:00
brentru
b18ae3dd90 corrected url 2018-02-14 15:32:41 -05:00
Limor "Ladyada" Fried
b0c370ea1f
Merge pull request #2 from adafruit/tannewt-patch-1
Update .travis.yml
2018-01-02 15:51:38 -05:00
Scott Shawcroft
cc8fefcc50
Update .travis.yml
Fix files to lint
2018-01-02 12:51:03 -08:00
Limor "Ladyada" Fried
6512226978
Merge pull request #1 from mrmcwethy/setpina1
changed example to match README.rst
2018-01-02 15:40:48 -05:00
mrmcwethy
9e22a80792 changed example to match README.rst 2018-01-02 13:36:21 -07:00
23 changed files with 629 additions and 213 deletions

57
.github/workflows/build.yml vendored Normal file
View 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
View 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/*

7
.gitignore vendored
View file

@ -1,6 +1,11 @@
*.mpy
.idea
__pycache__
_build
*.pyc
.env
build*
bundles
*.DS_Store
.eggs
dist
**/*.egg-info

View file

@ -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
@ -156,7 +156,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local
# (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=
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.

View file

@ -1,31 +0,0 @@
# This is a common .travis.yml for generating library release zip files for
# CircuitPython library releases using circuitpython-build-tools.
# See https://github.com/adafruit/circuitpython-build-tools for detailed setup
# instructions.
dist: trusty
sudo: false
language: python
python:
- "3.6"
cache:
pip: true
deploy:
provider: releases
api_key: $GITHUB_TOKEN
file_glob: true
file: bundles/*
skip_cleanup: true
overwrite: true
on:
tags: true
install:
- pip install pylint circuitpython-build-tools
script:
- pylint adafruit_apds9960.py
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-apds9960 --library_location .

View file

@ -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 dont 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 communitys 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.

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 Michael McWethy for Adafruit Inc
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.

View file

@ -2,23 +2,25 @@
Introduction
============
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-APDS9960/badge/?version=latest
:target: https://circuitpython.readthedocs.io/projects/apds/en/latest/
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-apds9960/badge/?version=latest
:target: https://circuitpython.readthedocs.io/projects/apds9960/en/latest/
:alt: Documentation Status
.. image :: https://img.shields.io/discord/327254708534116352.svg
:target: https://discord.gg/nBQh6qu
:alt: Discord
.. image:: https://github.com/adafruit/Adafruit_CircuitPython_APDS9960/workflows/Build%20CI/badge.svg
:target: https://github.com/adafruit/Adafruit_CircuitPython_APDS9960/actions/
:alt: Build Status
The APDS9960 is a specialize chip that detects hand gestures, proximity detection
and ambient light color over I2C. Its available on
`Adafruit as a breakout <https://www.adafruit.com/product/3595>`_.
Dependencies
=============
Installation and Dependencies
=============================
This driver depends on:
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
@ -27,9 +29,52 @@ Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
Installing from PyPI
--------------------
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from PyPI <https://pypi.org/project/adafruit-circuitpython-apds9960/>`_. To install for current user:
.. code-block:: shell
pip3 install adafruit-circuitpython-apds9960
To install system-wide (this may be required in some cases):
.. code-block:: shell
sudo pip3 install adafruit-circuitpython-apds9960
To install in a virtual environment in your current project:
.. code-block:: shell
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-apds9960
Usage Example
=============
.. code-block:: python
import board
import busio
import digitalio
from adafruit_apds9960.apds9960 import APDS9960
i2c = busio.I2C(board.SCL, board.SDA)
int_pin = digitalio.DigitalInOut(board.D5)
apds = APDS9960(i2c, interrupt_pin=int_pin)
apds.enable_proximity = True
apds.proximity_interrupt_threshold = (0, 175)
apds.enable_proximity_interrupt = True
while True:
print(apds.proximity)
apds.clear_interrupt()
Hardware Set-up
---------------
@ -108,20 +153,12 @@ To check for a object in proximity, see if a gesture is available first, then ge
while True:
if not interrupt_pin.value:
print(apds.proximity())
print(apds.proximity)
# clear the interrupt
apds.clear_interrupt()
API Reference
=============
.. toctree::
:maxdepth: 2
api
Contributing
============
@ -152,3 +189,26 @@ Then run the build:
.. code-block::shell
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-apds --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.

View file

@ -35,30 +35,31 @@ from adafruit_register.i2c_bit import RWBit
from adafruit_bus_device.i2c_device import I2CDevice
from micropython import const
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_APDS9960.git"
# ADDRESS_DEF = const(0x39)
# INTEGRATION_TIME_DEF = const(0x01)
# GAIN_DEF = const(0x01)
#pylint: disable-msg=bad-whitespace
#APDS9960_RAM = const(0x00)
APDS9960_ENABLE = const(0x80)
APDS9960_ATIME = const(0x81)
#APDS9960_WTIME = const(0x83)
#APDS9960_AILTIL = const(0x84)
# APDS9960_RAM = const(0x00)
APDS9960_ENABLE = const(0x80)
APDS9960_ATIME = const(0x81)
# APDS9960_WTIME = const(0x83)
# APDS9960_AILTIL = const(0x84)
# APDS9960_AILTH = const(0x85)
# APDS9960_AIHTL = const(0x86)
# APDS9960_AIHTH = const(0x87)
APDS9960_PILT = const(0x89)
APDS9960_PIHT = const(0x8B)
APDS9960_PERS = const(0x8C)
APDS9960_PILT = const(0x89)
APDS9960_PIHT = const(0x8B)
APDS9960_PERS = const(0x8C)
# APDS9960_CONFIG1 = const(0x8D)
# APDS9960_PPULSE = const(0x8E)
APDS9960_CONTROL = const(0x8F)
APDS9960_CONTROL = const(0x8F)
# APDS9960_CONFIG2 = const(0x90)
APDS9960_ID = const(0x92)
APDS9960_STATUS = const(0x93)
APDS9960_CDATAL = const(0x94)
APDS9960_ID = const(0x92)
APDS9960_STATUS = const(0x93)
APDS9960_CDATAL = const(0x94)
# APDS9960_CDATAH = const(0x95)
# APDS9960_RDATAL = const(0x96)
# APDS9960_RDATAH = const(0x97)
@ -66,35 +67,34 @@ APDS9960_CDATAL = const(0x94)
# APDS9960_GDATAH = const(0x99)
# APDS9960_BDATAL = const(0x9A)
# APDS9960_BDATAH = const(0x9B)
APDS9960_PDATA = const(0x9C)
APDS9960_PDATA = const(0x9C)
# APDS9960_POFFSET_UR = const(0x9D)
# APDS9960_POFFSET_DL = const(0x9E)
# APDS9960_CONFIG3 = const(0x9F)
APDS9960_GPENTH = const(0xA0)
APDS9960_GPENTH = const(0xA0)
# APDS9960_GEXTH = const(0xA1)
APDS9960_GCONF1 = const(0xA2)
APDS9960_GCONF2 = const(0xA3)
APDS9960_GCONF1 = const(0xA2)
APDS9960_GCONF2 = const(0xA3)
# APDS9960_GOFFSET_U = const(0xA4)
# APDS9960_GOFFSET_D = const(0xA5)
# APDS9960_GOFFSET_L = const(0xA7)
# APDS9960_GOFFSET_R = const(0xA9)
APDS9960_GPULSE = const(0xA6)
APDS9960_GCONF3 = const(0xAA)
APDS9960_GCONF4 = const(0xAB)
APDS9960_GFLVL = const(0xAE)
APDS9960_GSTATUS = const(0xAF)
APDS9960_GPULSE = const(0xA6)
APDS9960_GCONF3 = const(0xAA)
APDS9960_GCONF4 = const(0xAB)
APDS9960_GFLVL = const(0xAE)
APDS9960_GSTATUS = const(0xAF)
# APDS9960_IFORCE = const(0xE4)
# APDS9960_PICLEAR = const(0xE5)
# APDS9960_CICLEAR = const(0xE6)
APDS9960_AICLEAR = const(0xE7)
APDS9960_GFIFO_U = const(0xFC)
APDS9960_AICLEAR = const(0xE7)
APDS9960_GFIFO_U = const(0xFC)
# APDS9960_GFIFO_D = const(0xFD)
# APDS9960_GFIFO_L = const(0xFE)
# APDS9960_GFIFO_R = const(0xFF)
#pylint: enable-msg=bad-whitespace
#pylint: disable-msg=too-many-instance-attributes
# pylint: disable-msg=too-many-instance-attributes
class APDS9960:
"""
APDS9900 provide basic driver services for the ASDS9960 breakout board
@ -105,12 +105,9 @@ class APDS9960:
_gesture_mode = RWBit(APDS9960_GCONF4, 0)
_proximity_persistance = RWBits(4, APDS9960_PERS, 4)
def __init__(self,
i2c, *,
interrupt_pin=None,
address=0x39,
integration_time=0x01,
gain=0x01):
def __init__(
self, i2c, *, interrupt_pin=None, address=0x39, integration_time=0x01, gain=0x01
):
self.buf129 = None
self.buf2 = bytearray(2)
@ -136,9 +133,9 @@ class APDS9960:
self.color_gain = gain
self.integration_time = integration_time
self.gesture_dimensions = 0x00 # all
self.gesture_fifo_threshold = 0x01 # fifo 4
self.gesture_gain = 0x02 # gain 4
self.gesture_dimensions = 0x00 # all
self.gesture_fifo_threshold = 0x01 # fifo 4
self.gesture_gain = 0x02 # gain 4
self.gesture_proximity_threshold = 50
self._reset_counts()
@ -153,7 +150,6 @@ class APDS9960:
self._saw_left_start = 0
self._saw_right_start = 0
enable = RWBit(APDS9960_ENABLE, 0)
"""Board enable. True to enable, False to disable"""
enable_color = RWBit(APDS9960_ENABLE, 1)
@ -184,7 +180,7 @@ class APDS9960:
self._gesture_mode = False
self._gesture_enable = enable_flag
def gesture(self): #pylint: disable-msg=too-many-branches
def gesture(self): # pylint: disable-msg=too-many-branches
"""Returns gesture code if detected. =0 if no gesture detected
=1 if an UP, =2 if a DOWN, =3 if an LEFT, =4 if a RIGHT
"""
@ -204,14 +200,19 @@ class APDS9960:
up_down_diff = 0
left_right_diff = 0
gesture_received = 0
time.sleep(0.030) # 30 ms
time.sleep(0.030) # 30 ms
n_recs = self._read8(APDS9960_GFLVL)
if n_recs:
with self.i2c_device as i2c:
i2c.write(buffer, end=1, stop=False)
i2c.readinto(buffer, start=1, end=min(129, 1 + n_recs * 4))
i2c.write_then_readinto(
buffer,
buffer,
out_end=1,
in_start=1,
in_end=min(129, 1 + n_recs * 4),
)
upp, down, left, right = buffer[1:5]
if abs(upp - down) > 13:
@ -225,14 +226,14 @@ class APDS9960:
# either leading edge of down movement
# or trailing edge of up movement
if self._saw_up_start:
gesture_received = 0x01 # up
gesture_received = 0x01 # up
else:
self._saw_down_start += 1
elif up_down_diff > 0:
# either leading edge of up movement
# or trailing edge of down movement
if self._saw_down_start:
gesture_received = 0x02 # down
gesture_received = 0x02 # down
else:
self._saw_up_start += 1
@ -241,14 +242,14 @@ class APDS9960:
# either leading edge of right movement
# trailing edge of left movement
if self._saw_left_start:
gesture_received = 0x03 # left
gesture_received = 0x03 # left
else:
self._saw_right_start += 1
elif left_right_diff > 0:
# either leading edge of left movement
# trailing edge of right movement
if self._saw_right_start:
gesture_received = 0x04 #right
gesture_received = 0x04 # right
else:
self._saw_left_start += 1
@ -280,10 +281,12 @@ class APDS9960:
@property
def color_data(self):
"""Tuple containing r, g, b, c values"""
return self._color_data16(APDS9960_CDATAL + 2), \
self._color_data16(APDS9960_CDATAL + 4), \
self._color_data16(APDS9960_CDATAL + 6), \
self._color_data16(APDS9960_CDATAL)
return (
self._color_data16(APDS9960_CDATAL + 2),
self._color_data16(APDS9960_CDATAL + 4),
self._color_data16(APDS9960_CDATAL + 6),
self._color_data16(APDS9960_CDATAL),
)
### PROXIMITY
@property
@ -293,9 +296,11 @@ class APDS9960:
When setting the proximity interrupt threshold values using a tuple of
zero to three values: low threshold, high threshold, persistance.
persistance defaults to 4 if not provided"""
return self._read8(APDS9960_PILT), \
self._read8(APDS9960_PIHT), \
self._proximity_persistance
return (
self._read8(APDS9960_PILT),
self._read8(APDS9960_PIHT),
self._proximity_persistance,
)
@proximity_interrupt_threshold.setter
def proximity_interrupt_threshold(self, setting_tuple):
@ -303,12 +308,11 @@ class APDS9960:
self._write8(APDS9960_PILT, setting_tuple[0])
if len(setting_tuple) > 1:
self._write8(APDS9960_PIHT, setting_tuple[1])
persist = 4 # default 4
persist = 4 # default 4
if len(setting_tuple) > 2:
persist = min(setting_tuple[2], 7)
self._proximity_persistance = persist
@property
def gesture_proximity_threshold(self):
"""Proximity threshold value: range 0-255"""
@ -316,10 +320,11 @@ class APDS9960:
@gesture_proximity_threshold.setter
def gesture_proximity_threshold(self, thresh):
self._write8(APDS9960_GPENTH, thresh & 0xff)
self._write8(APDS9960_GPENTH, thresh & 0xFF)
@property
def proximity(self):
"""proximity value: range 0-255"""
"""Proximity value: range 0-255"""
return self._read8(APDS9960_PDATA)
def clear_interrupt(self):
@ -333,7 +338,7 @@ class APDS9960:
@integration_time.setter
def integration_time(self, int_time):
self._write8(APDS9960_ATIME, int_time & 0xff)
self._write8(APDS9960_ATIME, int_time & 0xFF)
# method for reading and writing to I2C
def _write8(self, command, abyte):
@ -356,8 +361,7 @@ class APDS9960:
buf = self.buf2
buf[0] = command
with self.i2c_device as i2c:
i2c.write(buf, end=1)
i2c.readinto(buf, end=1)
i2c.write_then_readinto(buf, buf, out_end=1, in_end=1)
return buf[0]
def _color_data16(self, command):
@ -366,6 +370,5 @@ class APDS9960:
buf = self.buf2
buf[0] = command
with self.i2c_device as i2c:
i2c.write(buf, end=1, stop=False)
i2c.readinto(buf)
i2c.write_then_readinto(buf, buf, out_end=1)
return buf[1] << 8 | buf[0]

View file

@ -28,6 +28,9 @@ Helper functions for color calculations
* Author(s): Michael McWethy
"""
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_APDS9960.git"
def calculate_color_temperature(r, g, b):
"""Converts the raw R/G/B values to color temperature in degrees Kelvin"""
@ -53,6 +56,7 @@ def calculate_color_temperature(r, g, b):
# Return the results in degrees Kelvin
return cct
def calculate_lux(r, g, b):
"""Calculate ambient light values"""
# This only uses RGB ... how can we integrate clear or calculate lux

10
api.rst
View file

@ -1,10 +0,0 @@
`APDS9960` - Driver for Gesture/Proximity/Color detection board
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.. automodule:: adafruit_apds9960.apds9960
:members:
`Color Utility Functions` - Utility function related to Color detection
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.. automodule:: adafruit_apds9960.colorutility
:members:

BIN
docs/_static/favicon.ico vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

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.
.. automodule:: adafruit_apds9960.apds9960
:members:
.. automodule:: adafruit_apds9960.colorutility
:members:

View file

@ -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,39 +11,48 @@ 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",
]
# 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"]
# Mock out micropython ourselves so that we can make const a lambda.
import imp
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
m = imp.new_module("micropython")
m.const = lambda x: x
sys.modules["micropython"] = m
intersphinx_mapping = {
"python": ("https://docs.python.org/3.4", None),
"BusDevice": (
"https://circuitpython.readthedocs.io/projects/busdevice/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 = 'README'
master_doc = "index"
# General information about the project.
project = u'Adafruit APDS9960 Library'
copyright = u'2017 Michael McWethy'
author = u'Michael McWethy'
project = "Adafruit APDS9960 Library"
copyright = "2017 Michael McWethy"
author = "Michael McWethy"
# 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.
@ -54,7 +64,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']
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.
@ -66,64 +76,76 @@ 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
# If this is True, todo emits a warning for each TODO entries. The default is False.
todo_emit_warnings = True
# -- Options for HTML output ----------------------------------------------
# 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"
# Output file base name for HTML help builder.
htmlhelp_basename = 'AdafruitApds9960Librarydoc'
htmlhelp_basename = "AdafruitApds9960Librarydoc"
# -- 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, 'AdafruitAPDS9960Library.tex', u'AdafruitAPDS9960 Library Documentation',
author, 'manual'),
(
master_doc,
"AdafruitAPDS9960Library.tex",
"AdafruitAPDS9960 Library Documentation",
author,
"manual",
),
]
# -- Options for manual page output ---------------------------------------
@ -131,8 +153,13 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'AdafruitAPDS9960library', u'Adafruit APDS9960 Library Documentation',
[author], 1)
(
master_doc,
"AdafruitAPDS9960library",
"Adafruit APDS9960 Library Documentation",
[author],
1,
)
]
# -- Options for Texinfo output -------------------------------------------
@ -141,7 +168,13 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'AdafruitAPDS9960Library', u'Adafruit APDS9960 Library Documentation',
author, 'AdafruitAPDS9960Library', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"AdafruitAPDS9960Library",
"Adafruit APDS9960 Library Documentation",
author,
"AdafruitAPDS9960Library",
"One line description of project.",
"Miscellaneous",
),
]

16
docs/examples.rst Normal file
View file

@ -0,0 +1,16 @@
Simple test
------------
Ensure your device works with this simple test.
.. literalinclude:: ../examples/apds9960_color_simpletest.py
:caption: examples/apds9960_color_simpletest.py
:linenos:
.. literalinclude:: ../examples/apds9960_gesture_simpletest.py
:caption: examples/apds9960_gesture_simpletest.py
:linenos:
.. literalinclude:: ../examples/apds9960_proximity_simpletest.py
:caption: examples/apds9960_proximity_simpletest.py
:linenos:

47
docs/index.rst Normal file
View file

@ -0,0 +1,47 @@
.. 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 APDS9960 Proximity, Light, RGB, and Gesture Sensor <https://www.adafruit.com/product/3595>
.. toctree::
:caption: Other Links
Download <https://github.com/adafruit/Adafruit_CircuitPython_APDS9960/releases/latest>
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
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`

View file

@ -1,25 +1,22 @@
import time
import board
import busio
import digitalio
from adafruit_apds9960.apds9960 import APDS9960
from adafruit_apds9960 import colorutility
i2c = busio.I2C(board.SCL, board.SDA)
int_pin = digitalio.DigitalInOut(board.A2)
apds = APDS9960(i2c)
apds.enable_color = True
while True:
#create some variables to store the color data in
# create some variables to store the color data in
#wait for color data to be ready
# wait for color data to be ready
while not apds.color_data_ready:
time.sleep(0.005)
#get the data and print the different channels
# get the data and print the different channels
r, g, b, c = apds.color_data
print("red: ", r)
print("green: ", g)

View file

@ -4,7 +4,7 @@ import digitalio
from adafruit_apds9960.apds9960 import APDS9960
i2c = busio.I2C(board.SCL, board.SDA)
int_pin = digitalio.DigitalInOut(board.A2)
int_pin = digitalio.DigitalInOut(board.D5)
apds = APDS9960(i2c, interrupt_pin=int_pin)
apds.enable_proximity = True
@ -14,7 +14,7 @@ apds.enable_proximity_interrupt = True
while True:
# print the proximity reading when the interrupt pin goes low
if not int_pin.value:
print(apds.proximity())
print(apds.proximity)
# clear the interrupt
apds.clear_interrupt()

View file

@ -0,0 +1,13 @@
import time
import board
import busio
from adafruit_apds9960.apds9960 import APDS9960
i2c = busio.I2C(board.SCL, board.SDA)
apds = APDS9960(i2c)
apds.enable_proximity = True
while True:
print(apds.proximity)
time.sleep(0.2)

View file

@ -1,2 +1,3 @@
adafruit-circuitpython-bus-device
Adafruit-Blinka
adafruit-circuitpython-busdevice
adafruit-circuitpython-register

56
setup.py Normal file
View file

@ -0,0 +1,56 @@
"""A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
"""
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
long_description = f.read()
setup(
name="adafruit-circuitpython-apds9960",
use_scm_version=True,
setup_requires=["setuptools_scm"],
description="CircuitPython driver for APSD9960 Gesture breakout board",
long_description=long_description,
long_description_content_type="text/x-rst",
# The project's main homepage.
url="https://github.com/adafruit/Adafruit_CircuitPython_APDS9960",
# Author details
author="Adafruit Industries",
author_email="circuitpython@adafruit.com",
install_requires=[
"Adafruit-Blinka",
"adafruit-circuitpython-register",
"adafruit-circuitpython-busdevice",
],
# Choose your license
license="MIT",
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"Topic :: System :: Hardware",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
],
# What does your project relate to?
keywords="adafruit apsd9960 gesture color proximity light sensor hardware micropython circuitpython",
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
packages=["adafruit_apds9960"],
)