Compare commits
53 commits
master
...
remove-bad
| Author | SHA1 | Date | |
|---|---|---|---|
| 86b09efaab | |||
|
|
ebe44a1389 | ||
|
|
197157afec | ||
|
|
09142ef74d | ||
|
|
c4f014aef1 | ||
|
|
a82399df8c | ||
|
|
e2836e994e | ||
|
|
f08d3cbfb8 | ||
|
|
1e1b552709 | ||
|
|
2d0910549e | ||
|
|
e0d80f61d2 | ||
|
|
637de6b55c | ||
|
|
d27d18139d | ||
|
|
459c2731e0 | ||
|
|
1930cd4b15 | ||
|
|
905fcfc221 | ||
|
|
2a467d7ad7 | ||
|
|
6324f277bf | ||
|
|
a4315e2735 | ||
|
|
68f818fce8 | ||
|
|
af6264b1f3 | ||
|
|
7905415b5b | ||
|
|
d89c478fdb | ||
|
|
25987347a0 | ||
|
|
71e30e3ecd | ||
|
|
133849a498 | ||
|
|
6f16ec841d | ||
|
|
589e3e928d | ||
|
|
bedf020361 | ||
|
|
ab802b2f26 | ||
|
|
65cab9d8e7 | ||
|
|
3a0b108980 | ||
|
|
bb1b172214 | ||
|
|
cc20be656f | ||
|
|
becfa166b9 | ||
|
|
09c3b177c0 | ||
|
|
dca8d46a3a | ||
|
|
4e68900535 | ||
|
|
74ebe51e45 | ||
|
|
ea51fb67d1 | ||
|
|
e8e4d19b61 | ||
|
|
923de52f38 | ||
|
|
047c898d17 | ||
|
|
41b423f200 | ||
|
|
c096261440 | ||
|
|
24245ad6f6 | ||
|
|
2023e77de0 | ||
|
|
8ff7f19c32 | ||
|
|
b18ae3dd90 | ||
|
|
b0c370ea1f | ||
|
|
cc8fefcc50 | ||
|
|
6512226978 | ||
|
|
9e22a80792 |
23 changed files with 629 additions and 213 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/*
|
||||||
7
.gitignore
vendored
7
.gitignore
vendored
|
|
@ -1,6 +1,11 @@
|
||||||
|
*.mpy
|
||||||
|
.idea
|
||||||
__pycache__
|
__pycache__
|
||||||
_build
|
_build
|
||||||
*.pyc
|
*.pyc
|
||||||
.env
|
.env
|
||||||
build*
|
|
||||||
bundles
|
bundles
|
||||||
|
*.DS_Store
|
||||||
|
.eggs
|
||||||
|
dist
|
||||||
|
**/*.egg-info
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ confidence=
|
||||||
# no Warning level messages displayed, use"--disable=all --enable=classes
|
# no Warning level messages displayed, use"--disable=all --enable=classes
|
||||||
# --disable=W"
|
# --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=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
|
# 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
|
# 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
|
# (useful for modules/projects where namespaces are manipulated during runtime
|
||||||
# and thus existing member attributes cannot be deduced by static analysis. It
|
# and thus existing member attributes cannot be deduced by static analysis. It
|
||||||
# supports qualified module names, as well as Unix pattern matching.
|
# 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
|
# Show a hint with possible names when a member name was not found. The aspect
|
||||||
# of finding the hint is based on edit distance.
|
# of finding the hint is based on edit distance.
|
||||||
|
|
|
||||||
31
.travis.yml
31
.travis.yml
|
|
@ -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 .
|
|
||||||
|
|
@ -1,74 +1,129 @@
|
||||||
# Contributor Covenant Code of Conduct
|
# Adafruit Community Code of Conduct
|
||||||
|
|
||||||
## Our Pledge
|
## Our Pledge
|
||||||
|
|
||||||
In the interest of fostering an open and welcoming environment, we as
|
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
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
size, disability, ethnicity, gender identity and expression, level or type of
|
||||||
nationality, personal appearance, race, religion, or sexual identity and
|
experience, education, socio-economic status, nationality, personal appearance,
|
||||||
orientation.
|
race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
## Our Standards
|
## 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
|
Examples of behavior that contributes to creating a positive environment
|
||||||
include:
|
include:
|
||||||
|
|
||||||
|
* Be kind and courteous to others
|
||||||
* Using welcoming and inclusive language
|
* Using welcoming and inclusive language
|
||||||
* Being respectful of differing viewpoints and experiences
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Collaborating with other community members
|
||||||
* Gracefully accepting constructive criticism
|
* Gracefully accepting constructive criticism
|
||||||
* Focusing on what is best for the community
|
* Focusing on what is best for the community
|
||||||
* Showing empathy towards other community members
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
* The use of sexualized language or imagery and sexual attention or advances
|
||||||
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
|
* 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
|
* Public or private harassment
|
||||||
* Publishing others' private information, such as a physical or electronic
|
* Publishing others' private information, such as a physical or electronic
|
||||||
address, without explicit permission
|
address, without explicit permission
|
||||||
* Other conduct which could reasonably be considered inappropriate in a
|
* Other conduct which could reasonably be considered inappropriate
|
||||||
professional setting
|
|
||||||
|
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
|
## 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
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
response to any instances of unacceptable behavior.
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or
|
Project leaders have the right and responsibility to remove, edit, or
|
||||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
reject messages, comments, commits, code, issues, and other contributions
|
||||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
permanently any contributor for other behaviors that they deem inappropriate,
|
permanently any community member for other behaviors that they deem
|
||||||
threatening, offensive, or harmful.
|
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
|
## 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
|
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
|
when an individual is representing the project or its community. As a community
|
||||||
representing a project or community include using an official project e-mail
|
member, you are representing our community, and are expected to behave
|
||||||
address, posting via an official social media account, or acting as an appointed
|
accordingly.
|
||||||
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.
|
|
||||||
|
|
||||||
## Attribution
|
## Attribution
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
available at [http://contributor-covenant.org/version/1/4][version]
|
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
|
For other projects adopting the Adafruit Community Code of
|
||||||
[version]: http://contributor-covenant.org/version/1/4/
|
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
21
LICENSE
Normal 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.
|
||||||
90
README.rst
90
README.rst
|
|
@ -2,23 +2,25 @@
|
||||||
Introduction
|
Introduction
|
||||||
============
|
============
|
||||||
|
|
||||||
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-APDS9960/badge/?version=latest
|
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-apds9960/badge/?version=latest
|
||||||
|
:target: https://circuitpython.readthedocs.io/projects/apds9960/en/latest/
|
||||||
:target: https://circuitpython.readthedocs.io/projects/apds/en/latest/
|
|
||||||
|
|
||||||
:alt: Documentation Status
|
:alt: Documentation Status
|
||||||
|
|
||||||
.. image :: https://img.shields.io/discord/327254708534116352.svg
|
.. image :: https://img.shields.io/discord/327254708534116352.svg
|
||||||
:target: https://discord.gg/nBQh6qu
|
:target: https://discord.gg/nBQh6qu
|
||||||
:alt: Discord
|
: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
|
The APDS9960 is a specialize chip that detects hand gestures, proximity detection
|
||||||
and ambient light color over I2C. Its available on
|
and ambient light color over I2C. Its available on
|
||||||
`Adafruit as a breakout <https://www.adafruit.com/product/3595>`_.
|
`Adafruit as a breakout <https://www.adafruit.com/product/3595>`_.
|
||||||
|
|
||||||
|
|
||||||
Dependencies
|
Installation and Dependencies
|
||||||
=============
|
=============================
|
||||||
This driver depends on:
|
This driver depends on:
|
||||||
|
|
||||||
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
|
* `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
|
This is easily achieved by downloading
|
||||||
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
|
`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
|
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
|
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:
|
while True:
|
||||||
if not interrupt_pin.value:
|
if not interrupt_pin.value:
|
||||||
print(apds.proximity())
|
print(apds.proximity)
|
||||||
|
|
||||||
# clear the interrupt
|
# clear the interrupt
|
||||||
apds.clear_interrupt()
|
apds.clear_interrupt()
|
||||||
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
=============
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 2
|
|
||||||
|
|
||||||
api
|
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
============
|
============
|
||||||
|
|
||||||
|
|
@ -152,3 +189,26 @@ Then run the build:
|
||||||
.. code-block::shell
|
.. code-block::shell
|
||||||
|
|
||||||
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-apds --library_location .
|
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.
|
||||||
|
|
|
||||||
|
|
@ -35,30 +35,31 @@ from adafruit_register.i2c_bit import RWBit
|
||||||
from adafruit_bus_device.i2c_device import I2CDevice
|
from adafruit_bus_device.i2c_device import I2CDevice
|
||||||
from micropython import const
|
from micropython import const
|
||||||
|
|
||||||
|
__version__ = "0.0.0-auto.0"
|
||||||
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_APDS9960.git"
|
||||||
|
|
||||||
# ADDRESS_DEF = const(0x39)
|
# ADDRESS_DEF = const(0x39)
|
||||||
# INTEGRATION_TIME_DEF = const(0x01)
|
# INTEGRATION_TIME_DEF = const(0x01)
|
||||||
# GAIN_DEF = const(0x01)
|
# GAIN_DEF = const(0x01)
|
||||||
|
|
||||||
#pylint: disable-msg=bad-whitespace
|
# APDS9960_RAM = const(0x00)
|
||||||
#APDS9960_RAM = const(0x00)
|
APDS9960_ENABLE = const(0x80)
|
||||||
APDS9960_ENABLE = const(0x80)
|
APDS9960_ATIME = const(0x81)
|
||||||
APDS9960_ATIME = const(0x81)
|
# APDS9960_WTIME = const(0x83)
|
||||||
#APDS9960_WTIME = const(0x83)
|
# APDS9960_AILTIL = const(0x84)
|
||||||
#APDS9960_AILTIL = const(0x84)
|
|
||||||
# APDS9960_AILTH = const(0x85)
|
# APDS9960_AILTH = const(0x85)
|
||||||
# APDS9960_AIHTL = const(0x86)
|
# APDS9960_AIHTL = const(0x86)
|
||||||
# APDS9960_AIHTH = const(0x87)
|
# APDS9960_AIHTH = const(0x87)
|
||||||
APDS9960_PILT = const(0x89)
|
APDS9960_PILT = const(0x89)
|
||||||
APDS9960_PIHT = const(0x8B)
|
APDS9960_PIHT = const(0x8B)
|
||||||
APDS9960_PERS = const(0x8C)
|
APDS9960_PERS = const(0x8C)
|
||||||
# APDS9960_CONFIG1 = const(0x8D)
|
# APDS9960_CONFIG1 = const(0x8D)
|
||||||
# APDS9960_PPULSE = const(0x8E)
|
# APDS9960_PPULSE = const(0x8E)
|
||||||
APDS9960_CONTROL = const(0x8F)
|
APDS9960_CONTROL = const(0x8F)
|
||||||
# APDS9960_CONFIG2 = const(0x90)
|
# APDS9960_CONFIG2 = const(0x90)
|
||||||
APDS9960_ID = const(0x92)
|
APDS9960_ID = const(0x92)
|
||||||
APDS9960_STATUS = const(0x93)
|
APDS9960_STATUS = const(0x93)
|
||||||
APDS9960_CDATAL = const(0x94)
|
APDS9960_CDATAL = const(0x94)
|
||||||
# APDS9960_CDATAH = const(0x95)
|
# APDS9960_CDATAH = const(0x95)
|
||||||
# APDS9960_RDATAL = const(0x96)
|
# APDS9960_RDATAL = const(0x96)
|
||||||
# APDS9960_RDATAH = const(0x97)
|
# APDS9960_RDATAH = const(0x97)
|
||||||
|
|
@ -66,35 +67,34 @@ APDS9960_CDATAL = const(0x94)
|
||||||
# APDS9960_GDATAH = const(0x99)
|
# APDS9960_GDATAH = const(0x99)
|
||||||
# APDS9960_BDATAL = const(0x9A)
|
# APDS9960_BDATAL = const(0x9A)
|
||||||
# APDS9960_BDATAH = const(0x9B)
|
# APDS9960_BDATAH = const(0x9B)
|
||||||
APDS9960_PDATA = const(0x9C)
|
APDS9960_PDATA = const(0x9C)
|
||||||
# APDS9960_POFFSET_UR = const(0x9D)
|
# APDS9960_POFFSET_UR = const(0x9D)
|
||||||
# APDS9960_POFFSET_DL = const(0x9E)
|
# APDS9960_POFFSET_DL = const(0x9E)
|
||||||
# APDS9960_CONFIG3 = const(0x9F)
|
# APDS9960_CONFIG3 = const(0x9F)
|
||||||
APDS9960_GPENTH = const(0xA0)
|
APDS9960_GPENTH = const(0xA0)
|
||||||
# APDS9960_GEXTH = const(0xA1)
|
# APDS9960_GEXTH = const(0xA1)
|
||||||
APDS9960_GCONF1 = const(0xA2)
|
APDS9960_GCONF1 = const(0xA2)
|
||||||
APDS9960_GCONF2 = const(0xA3)
|
APDS9960_GCONF2 = const(0xA3)
|
||||||
# APDS9960_GOFFSET_U = const(0xA4)
|
# APDS9960_GOFFSET_U = const(0xA4)
|
||||||
# APDS9960_GOFFSET_D = const(0xA5)
|
# APDS9960_GOFFSET_D = const(0xA5)
|
||||||
# APDS9960_GOFFSET_L = const(0xA7)
|
# APDS9960_GOFFSET_L = const(0xA7)
|
||||||
# APDS9960_GOFFSET_R = const(0xA9)
|
# APDS9960_GOFFSET_R = const(0xA9)
|
||||||
APDS9960_GPULSE = const(0xA6)
|
APDS9960_GPULSE = const(0xA6)
|
||||||
APDS9960_GCONF3 = const(0xAA)
|
APDS9960_GCONF3 = const(0xAA)
|
||||||
APDS9960_GCONF4 = const(0xAB)
|
APDS9960_GCONF4 = const(0xAB)
|
||||||
APDS9960_GFLVL = const(0xAE)
|
APDS9960_GFLVL = const(0xAE)
|
||||||
APDS9960_GSTATUS = const(0xAF)
|
APDS9960_GSTATUS = const(0xAF)
|
||||||
# APDS9960_IFORCE = const(0xE4)
|
# APDS9960_IFORCE = const(0xE4)
|
||||||
# APDS9960_PICLEAR = const(0xE5)
|
# APDS9960_PICLEAR = const(0xE5)
|
||||||
# APDS9960_CICLEAR = const(0xE6)
|
# APDS9960_CICLEAR = const(0xE6)
|
||||||
APDS9960_AICLEAR = const(0xE7)
|
APDS9960_AICLEAR = const(0xE7)
|
||||||
APDS9960_GFIFO_U = const(0xFC)
|
APDS9960_GFIFO_U = const(0xFC)
|
||||||
# APDS9960_GFIFO_D = const(0xFD)
|
# APDS9960_GFIFO_D = const(0xFD)
|
||||||
# APDS9960_GFIFO_L = const(0xFE)
|
# APDS9960_GFIFO_L = const(0xFE)
|
||||||
# APDS9960_GFIFO_R = const(0xFF)
|
# 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:
|
class APDS9960:
|
||||||
"""
|
"""
|
||||||
APDS9900 provide basic driver services for the ASDS9960 breakout board
|
APDS9900 provide basic driver services for the ASDS9960 breakout board
|
||||||
|
|
@ -105,12 +105,9 @@ class APDS9960:
|
||||||
_gesture_mode = RWBit(APDS9960_GCONF4, 0)
|
_gesture_mode = RWBit(APDS9960_GCONF4, 0)
|
||||||
_proximity_persistance = RWBits(4, APDS9960_PERS, 4)
|
_proximity_persistance = RWBits(4, APDS9960_PERS, 4)
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(
|
||||||
i2c, *,
|
self, i2c, *, interrupt_pin=None, address=0x39, integration_time=0x01, gain=0x01
|
||||||
interrupt_pin=None,
|
):
|
||||||
address=0x39,
|
|
||||||
integration_time=0x01,
|
|
||||||
gain=0x01):
|
|
||||||
|
|
||||||
self.buf129 = None
|
self.buf129 = None
|
||||||
self.buf2 = bytearray(2)
|
self.buf2 = bytearray(2)
|
||||||
|
|
@ -136,9 +133,9 @@ class APDS9960:
|
||||||
|
|
||||||
self.color_gain = gain
|
self.color_gain = gain
|
||||||
self.integration_time = integration_time
|
self.integration_time = integration_time
|
||||||
self.gesture_dimensions = 0x00 # all
|
self.gesture_dimensions = 0x00 # all
|
||||||
self.gesture_fifo_threshold = 0x01 # fifo 4
|
self.gesture_fifo_threshold = 0x01 # fifo 4
|
||||||
self.gesture_gain = 0x02 # gain 4
|
self.gesture_gain = 0x02 # gain 4
|
||||||
self.gesture_proximity_threshold = 50
|
self.gesture_proximity_threshold = 50
|
||||||
self._reset_counts()
|
self._reset_counts()
|
||||||
|
|
||||||
|
|
@ -153,7 +150,6 @@ class APDS9960:
|
||||||
self._saw_left_start = 0
|
self._saw_left_start = 0
|
||||||
self._saw_right_start = 0
|
self._saw_right_start = 0
|
||||||
|
|
||||||
|
|
||||||
enable = RWBit(APDS9960_ENABLE, 0)
|
enable = RWBit(APDS9960_ENABLE, 0)
|
||||||
"""Board enable. True to enable, False to disable"""
|
"""Board enable. True to enable, False to disable"""
|
||||||
enable_color = RWBit(APDS9960_ENABLE, 1)
|
enable_color = RWBit(APDS9960_ENABLE, 1)
|
||||||
|
|
@ -184,7 +180,7 @@ class APDS9960:
|
||||||
self._gesture_mode = False
|
self._gesture_mode = False
|
||||||
self._gesture_enable = enable_flag
|
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
|
"""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
|
=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
|
up_down_diff = 0
|
||||||
left_right_diff = 0
|
left_right_diff = 0
|
||||||
gesture_received = 0
|
gesture_received = 0
|
||||||
time.sleep(0.030) # 30 ms
|
time.sleep(0.030) # 30 ms
|
||||||
|
|
||||||
n_recs = self._read8(APDS9960_GFLVL)
|
n_recs = self._read8(APDS9960_GFLVL)
|
||||||
if n_recs:
|
if n_recs:
|
||||||
|
|
||||||
with self.i2c_device as i2c:
|
with self.i2c_device as i2c:
|
||||||
i2c.write(buffer, end=1, stop=False)
|
i2c.write_then_readinto(
|
||||||
i2c.readinto(buffer, start=1, end=min(129, 1 + n_recs * 4))
|
buffer,
|
||||||
|
buffer,
|
||||||
|
out_end=1,
|
||||||
|
in_start=1,
|
||||||
|
in_end=min(129, 1 + n_recs * 4),
|
||||||
|
)
|
||||||
upp, down, left, right = buffer[1:5]
|
upp, down, left, right = buffer[1:5]
|
||||||
|
|
||||||
if abs(upp - down) > 13:
|
if abs(upp - down) > 13:
|
||||||
|
|
@ -225,14 +226,14 @@ class APDS9960:
|
||||||
# either leading edge of down movement
|
# either leading edge of down movement
|
||||||
# or trailing edge of up movement
|
# or trailing edge of up movement
|
||||||
if self._saw_up_start:
|
if self._saw_up_start:
|
||||||
gesture_received = 0x01 # up
|
gesture_received = 0x01 # up
|
||||||
else:
|
else:
|
||||||
self._saw_down_start += 1
|
self._saw_down_start += 1
|
||||||
elif up_down_diff > 0:
|
elif up_down_diff > 0:
|
||||||
# either leading edge of up movement
|
# either leading edge of up movement
|
||||||
# or trailing edge of down movement
|
# or trailing edge of down movement
|
||||||
if self._saw_down_start:
|
if self._saw_down_start:
|
||||||
gesture_received = 0x02 # down
|
gesture_received = 0x02 # down
|
||||||
else:
|
else:
|
||||||
self._saw_up_start += 1
|
self._saw_up_start += 1
|
||||||
|
|
||||||
|
|
@ -241,14 +242,14 @@ class APDS9960:
|
||||||
# either leading edge of right movement
|
# either leading edge of right movement
|
||||||
# trailing edge of left movement
|
# trailing edge of left movement
|
||||||
if self._saw_left_start:
|
if self._saw_left_start:
|
||||||
gesture_received = 0x03 # left
|
gesture_received = 0x03 # left
|
||||||
else:
|
else:
|
||||||
self._saw_right_start += 1
|
self._saw_right_start += 1
|
||||||
elif left_right_diff > 0:
|
elif left_right_diff > 0:
|
||||||
# either leading edge of left movement
|
# either leading edge of left movement
|
||||||
# trailing edge of right movement
|
# trailing edge of right movement
|
||||||
if self._saw_right_start:
|
if self._saw_right_start:
|
||||||
gesture_received = 0x04 #right
|
gesture_received = 0x04 # right
|
||||||
else:
|
else:
|
||||||
self._saw_left_start += 1
|
self._saw_left_start += 1
|
||||||
|
|
||||||
|
|
@ -280,10 +281,12 @@ class APDS9960:
|
||||||
@property
|
@property
|
||||||
def color_data(self):
|
def color_data(self):
|
||||||
"""Tuple containing r, g, b, c values"""
|
"""Tuple containing r, g, b, c values"""
|
||||||
return self._color_data16(APDS9960_CDATAL + 2), \
|
return (
|
||||||
self._color_data16(APDS9960_CDATAL + 4), \
|
self._color_data16(APDS9960_CDATAL + 2),
|
||||||
self._color_data16(APDS9960_CDATAL + 6), \
|
self._color_data16(APDS9960_CDATAL + 4),
|
||||||
self._color_data16(APDS9960_CDATAL)
|
self._color_data16(APDS9960_CDATAL + 6),
|
||||||
|
self._color_data16(APDS9960_CDATAL),
|
||||||
|
)
|
||||||
|
|
||||||
### PROXIMITY
|
### PROXIMITY
|
||||||
@property
|
@property
|
||||||
|
|
@ -293,9 +296,11 @@ class APDS9960:
|
||||||
When setting the proximity interrupt threshold values using a tuple of
|
When setting the proximity interrupt threshold values using a tuple of
|
||||||
zero to three values: low threshold, high threshold, persistance.
|
zero to three values: low threshold, high threshold, persistance.
|
||||||
persistance defaults to 4 if not provided"""
|
persistance defaults to 4 if not provided"""
|
||||||
return self._read8(APDS9960_PILT), \
|
return (
|
||||||
self._read8(APDS9960_PIHT), \
|
self._read8(APDS9960_PILT),
|
||||||
self._proximity_persistance
|
self._read8(APDS9960_PIHT),
|
||||||
|
self._proximity_persistance,
|
||||||
|
)
|
||||||
|
|
||||||
@proximity_interrupt_threshold.setter
|
@proximity_interrupt_threshold.setter
|
||||||
def proximity_interrupt_threshold(self, setting_tuple):
|
def proximity_interrupt_threshold(self, setting_tuple):
|
||||||
|
|
@ -303,12 +308,11 @@ class APDS9960:
|
||||||
self._write8(APDS9960_PILT, setting_tuple[0])
|
self._write8(APDS9960_PILT, setting_tuple[0])
|
||||||
if len(setting_tuple) > 1:
|
if len(setting_tuple) > 1:
|
||||||
self._write8(APDS9960_PIHT, setting_tuple[1])
|
self._write8(APDS9960_PIHT, setting_tuple[1])
|
||||||
persist = 4 # default 4
|
persist = 4 # default 4
|
||||||
if len(setting_tuple) > 2:
|
if len(setting_tuple) > 2:
|
||||||
persist = min(setting_tuple[2], 7)
|
persist = min(setting_tuple[2], 7)
|
||||||
self._proximity_persistance = persist
|
self._proximity_persistance = persist
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gesture_proximity_threshold(self):
|
def gesture_proximity_threshold(self):
|
||||||
"""Proximity threshold value: range 0-255"""
|
"""Proximity threshold value: range 0-255"""
|
||||||
|
|
@ -316,10 +320,11 @@ class APDS9960:
|
||||||
|
|
||||||
@gesture_proximity_threshold.setter
|
@gesture_proximity_threshold.setter
|
||||||
def gesture_proximity_threshold(self, thresh):
|
def gesture_proximity_threshold(self, thresh):
|
||||||
self._write8(APDS9960_GPENTH, thresh & 0xff)
|
self._write8(APDS9960_GPENTH, thresh & 0xFF)
|
||||||
|
|
||||||
|
@property
|
||||||
def proximity(self):
|
def proximity(self):
|
||||||
"""proximity value: range 0-255"""
|
"""Proximity value: range 0-255"""
|
||||||
return self._read8(APDS9960_PDATA)
|
return self._read8(APDS9960_PDATA)
|
||||||
|
|
||||||
def clear_interrupt(self):
|
def clear_interrupt(self):
|
||||||
|
|
@ -333,7 +338,7 @@ class APDS9960:
|
||||||
|
|
||||||
@integration_time.setter
|
@integration_time.setter
|
||||||
def integration_time(self, int_time):
|
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
|
# method for reading and writing to I2C
|
||||||
def _write8(self, command, abyte):
|
def _write8(self, command, abyte):
|
||||||
|
|
@ -356,8 +361,7 @@ class APDS9960:
|
||||||
buf = self.buf2
|
buf = self.buf2
|
||||||
buf[0] = command
|
buf[0] = command
|
||||||
with self.i2c_device as i2c:
|
with self.i2c_device as i2c:
|
||||||
i2c.write(buf, end=1)
|
i2c.write_then_readinto(buf, buf, out_end=1, in_end=1)
|
||||||
i2c.readinto(buf, end=1)
|
|
||||||
return buf[0]
|
return buf[0]
|
||||||
|
|
||||||
def _color_data16(self, command):
|
def _color_data16(self, command):
|
||||||
|
|
@ -366,6 +370,5 @@ class APDS9960:
|
||||||
buf = self.buf2
|
buf = self.buf2
|
||||||
buf[0] = command
|
buf[0] = command
|
||||||
with self.i2c_device as i2c:
|
with self.i2c_device as i2c:
|
||||||
i2c.write(buf, end=1, stop=False)
|
i2c.write_then_readinto(buf, buf, out_end=1)
|
||||||
i2c.readinto(buf)
|
|
||||||
return buf[1] << 8 | buf[0]
|
return buf[1] << 8 | buf[0]
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ Helper functions for color calculations
|
||||||
* Author(s): Michael McWethy
|
* 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):
|
def calculate_color_temperature(r, g, b):
|
||||||
"""Converts the raw R/G/B values to color temperature in degrees Kelvin"""
|
"""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 the results in degrees Kelvin
|
||||||
return cct
|
return cct
|
||||||
|
|
||||||
|
|
||||||
def calculate_lux(r, g, b):
|
def calculate_lux(r, g, b):
|
||||||
"""Calculate ambient light values"""
|
"""Calculate ambient light values"""
|
||||||
# This only uses RGB ... how can we integrate clear or calculate lux
|
# This only uses RGB ... how can we integrate clear or calculate lux
|
||||||
|
|
|
||||||
10
api.rst
10
api.rst
|
|
@ -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
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
8
docs/api.rst
Normal 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:
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
sys.path.insert(0, os.path.abspath('.'))
|
|
||||||
|
sys.path.insert(0, os.path.abspath(".."))
|
||||||
|
|
||||||
# -- General configuration ------------------------------------------------
|
# -- General configuration ------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -10,39 +11,48 @@ sys.path.insert(0, os.path.abspath('.'))
|
||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
# ones.
|
# ones.
|
||||||
extensions = [
|
extensions = [
|
||||||
'sphinx.ext.autodoc',
|
"sphinx.ext.autodoc",
|
||||||
'sphinx.ext.intersphinx',
|
"sphinx.ext.intersphinx",
|
||||||
'sphinx.ext.viewcode',
|
"sphinx.ext.viewcode",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Uncomment the below if you use native CircuitPython modules such as
|
# Mock out micropython ourselves so that we can make const a lambda.
|
||||||
# digitalio, micropython and busio. List the modules you use. Without it, the
|
import imp
|
||||||
# autodoc module docs will fail to generate with a warning.
|
|
||||||
# autodoc_mock_imports = ["digitalio", "busio"]
|
|
||||||
|
|
||||||
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.
|
# 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.
|
# The master toctree document.
|
||||||
master_doc = 'README'
|
master_doc = "index"
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'Adafruit APDS9960 Library'
|
project = "Adafruit APDS9960 Library"
|
||||||
copyright = u'2017 Michael McWethy'
|
copyright = "2017 Michael McWethy"
|
||||||
author = u'Michael McWethy'
|
author = "Michael McWethy"
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = u'1.0'
|
version = "1.0"
|
||||||
# The full version, including alpha/beta/rc tags.
|
# 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
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|
@ -54,7 +64,7 @@ language = None
|
||||||
# List of patterns, relative to source directory, that match files and
|
# List of patterns, relative to source directory, that match files and
|
||||||
# directories to ignore when looking for source files.
|
# directories to ignore when looking for source files.
|
||||||
# This patterns also effect to html_static_path and html_extra_path
|
# 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
|
# The reST default role (used for this markup: `text`) to use for all
|
||||||
# documents.
|
# documents.
|
||||||
|
|
@ -66,64 +76,76 @@ default_role = "any"
|
||||||
add_function_parentheses = True
|
add_function_parentheses = True
|
||||||
|
|
||||||
# The name of the Pygments (syntax highlighting) style to use.
|
# 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.
|
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||||
todo_include_todos = False
|
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 ----------------------------------------------
|
# -- Options for HTML output ----------------------------------------------
|
||||||
|
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
# a list of builtin themes.
|
# 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
|
if not on_rtd: # only import and set the theme if we're building docs locally
|
||||||
try:
|
try:
|
||||||
import sphinx_rtd_theme
|
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:
|
except:
|
||||||
html_theme = 'default'
|
html_theme = "default"
|
||||||
html_theme_path = ['.']
|
html_theme_path = ["."]
|
||||||
else:
|
else:
|
||||||
html_theme_path = ['.']
|
html_theme_path = ["."]
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# 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,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# 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.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = 'AdafruitApds9960Librarydoc'
|
htmlhelp_basename = "AdafruitApds9960Librarydoc"
|
||||||
|
|
||||||
# -- Options for LaTeX output ---------------------------------------------
|
# -- Options for LaTeX output ---------------------------------------------
|
||||||
|
|
||||||
latex_elements = {
|
latex_elements = {
|
||||||
# The paper size ('letterpaper' or 'a4paper').
|
# The paper size ('letterpaper' or 'a4paper').
|
||||||
#
|
#
|
||||||
# 'papersize': 'letterpaper',
|
# 'papersize': 'letterpaper',
|
||||||
|
# The font size ('10pt', '11pt' or '12pt').
|
||||||
# The font size ('10pt', '11pt' or '12pt').
|
#
|
||||||
#
|
# 'pointsize': '10pt',
|
||||||
# 'pointsize': '10pt',
|
# Additional stuff for the LaTeX preamble.
|
||||||
|
#
|
||||||
# Additional stuff for the LaTeX preamble.
|
# 'preamble': '',
|
||||||
#
|
# Latex figure (float) alignment
|
||||||
# 'preamble': '',
|
#
|
||||||
|
# 'figure_align': 'htbp',
|
||||||
# Latex figure (float) alignment
|
|
||||||
#
|
|
||||||
# 'figure_align': 'htbp',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
# Grouping the document tree into LaTeX files. List of tuples
|
||||||
# (source start file, target name, title,
|
# (source start file, target name, title,
|
||||||
# author, documentclass [howto, manual, or own class]).
|
# author, documentclass [howto, manual, or own class]).
|
||||||
latex_documents = [
|
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 ---------------------------------------
|
# -- Options for manual page output ---------------------------------------
|
||||||
|
|
@ -131,8 +153,13 @@ latex_documents = [
|
||||||
# One entry per manual page. List of tuples
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
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 -------------------------------------------
|
# -- Options for Texinfo output -------------------------------------------
|
||||||
|
|
@ -141,7 +168,13 @@ man_pages = [
|
||||||
# (source start file, target name, title, author,
|
# (source start file, target name, title, author,
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
(master_doc, 'AdafruitAPDS9960Library', u'Adafruit APDS9960 Library Documentation',
|
(
|
||||||
author, 'AdafruitAPDS9960Library', 'One line description of project.',
|
master_doc,
|
||||||
'Miscellaneous'),
|
"AdafruitAPDS9960Library",
|
||||||
|
"Adafruit APDS9960 Library Documentation",
|
||||||
|
author,
|
||||||
|
"AdafruitAPDS9960Library",
|
||||||
|
"One line description of project.",
|
||||||
|
"Miscellaneous",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
16
docs/examples.rst
Normal file
16
docs/examples.rst
Normal 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
47
docs/index.rst
Normal 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`
|
||||||
|
|
@ -1,25 +1,22 @@
|
||||||
import time
|
import time
|
||||||
import board
|
import board
|
||||||
import busio
|
import busio
|
||||||
import digitalio
|
|
||||||
from adafruit_apds9960.apds9960 import APDS9960
|
from adafruit_apds9960.apds9960 import APDS9960
|
||||||
from adafruit_apds9960 import colorutility
|
from adafruit_apds9960 import colorutility
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
i2c = busio.I2C(board.SCL, board.SDA)
|
||||||
int_pin = digitalio.DigitalInOut(board.A2)
|
|
||||||
apds = APDS9960(i2c)
|
apds = APDS9960(i2c)
|
||||||
apds.enable_color = True
|
apds.enable_color = True
|
||||||
|
|
||||||
|
|
||||||
while 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:
|
while not apds.color_data_ready:
|
||||||
time.sleep(0.005)
|
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
|
r, g, b, c = apds.color_data
|
||||||
print("red: ", r)
|
print("red: ", r)
|
||||||
print("green: ", g)
|
print("green: ", g)
|
||||||
|
|
@ -4,7 +4,7 @@ import digitalio
|
||||||
from adafruit_apds9960.apds9960 import APDS9960
|
from adafruit_apds9960.apds9960 import APDS9960
|
||||||
|
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
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 = APDS9960(i2c, interrupt_pin=int_pin)
|
||||||
|
|
||||||
apds.enable_proximity = True
|
apds.enable_proximity = True
|
||||||
|
|
@ -14,7 +14,7 @@ apds.enable_proximity_interrupt = True
|
||||||
while True:
|
while True:
|
||||||
# print the proximity reading when the interrupt pin goes low
|
# print the proximity reading when the interrupt pin goes low
|
||||||
if not int_pin.value:
|
if not int_pin.value:
|
||||||
print(apds.proximity())
|
print(apds.proximity)
|
||||||
|
|
||||||
# clear the interrupt
|
# clear the interrupt
|
||||||
apds.clear_interrupt()
|
apds.clear_interrupt()
|
||||||
13
examples/apds9960_simpletest.py
Normal file
13
examples/apds9960_simpletest.py
Normal 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)
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
adafruit-circuitpython-bus-device
|
Adafruit-Blinka
|
||||||
|
adafruit-circuitpython-busdevice
|
||||||
adafruit-circuitpython-register
|
adafruit-circuitpython-register
|
||||||
|
|
|
||||||
56
setup.py
Normal file
56
setup.py
Normal 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"],
|
||||||
|
)
|
||||||
Loading…
Reference in a new issue