Compare commits
No commits in common. "master" and "tannewt-patch-1" have entirely different histories.
master
...
tannewt-pa
12 changed files with 222 additions and 575 deletions
57
.github/workflows/build.yml
vendored
57
.github/workflows/build.yml
vendored
|
|
@ -1,57 +0,0 @@
|
|||
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
81
.github/workflows/release.yml
vendored
|
|
@ -1,81 +0,0 @@
|
|||
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,11 +1,6 @@
|
|||
*.mpy
|
||||
.idea
|
||||
__pycache__
|
||||
_build
|
||||
*.pyc
|
||||
.env
|
||||
build*
|
||||
bundles
|
||||
*.DS_Store
|
||||
.eggs
|
||||
dist
|
||||
**/*.egg-info
|
||||
|
|
|
|||
|
|
@ -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,bad-continuation
|
||||
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
|
||||
|
||||
# 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=board
|
||||
ignored-modules=
|
||||
|
||||
# Show a hint with possible names when a member name was not found. The aspect
|
||||
# of finding the hint is based on edit distance.
|
||||
|
|
|
|||
32
.travis.yml
Normal file
32
.travis.yml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# 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 Sphinx sphinx-rtd-theme
|
||||
|
||||
script:
|
||||
- pylint adafruit_as726x.py
|
||||
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*.py)
|
||||
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-as726x --library_location .
|
||||
- cd docs && sphinx-build -E -W -b html . _build/html
|
||||
|
|
@ -1,129 +1,74 @@
|
|||
# Adafruit Community Code of Conduct
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and leaders pledge to making participation in our project and
|
||||
contributors and maintainers 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 or type of
|
||||
experience, education, socio-economic status, nationality, personal appearance,
|
||||
race, religion, or sexual identity and orientation.
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
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 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
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* 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
|
||||
|
||||
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.
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project leaders are responsible for clarifying the standards of acceptable
|
||||
Project maintainers 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 leaders have the right and responsibility to remove, edit, or
|
||||
reject messages, comments, commits, code, issues, and other contributions
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any community member for other behaviors that they deem
|
||||
inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Moderation
|
||||
|
||||
Instances of behaviors that violate the Adafruit Community Code of Conduct
|
||||
may be reported by any member of the community. Community members are
|
||||
encouraged to report these situations, including situations they witness
|
||||
involving other community members.
|
||||
|
||||
You may report in the following ways:
|
||||
|
||||
In any situation, you may send an email to <support@adafruit.com>.
|
||||
|
||||
On the Adafruit Discord, you may send an open message from any channel
|
||||
to all Community Moderators by tagging @community moderators. You may
|
||||
also send an open message from any channel, or a direct message to
|
||||
@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442,
|
||||
@sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175.
|
||||
|
||||
Email and direct message reports will be kept confidential.
|
||||
|
||||
In situations on Discord where the issue is particularly egregious, possibly
|
||||
illegal, requires immediate action, or violates the Discord terms of service,
|
||||
you should also report the message directly to Discord.
|
||||
|
||||
These are the steps for upholding our community’s standards of conduct.
|
||||
|
||||
1. Any member of the community may report any situation that violates the
|
||||
Adafruit Community Code of Conduct. All reports will be reviewed and
|
||||
investigated.
|
||||
2. If the behavior is an egregious violation, the community member who
|
||||
committed the violation may be banned immediately, without warning.
|
||||
3. Otherwise, moderators will first respond to such behavior with a warning.
|
||||
4. Moderators follow a soft "three strikes" policy - the community member may
|
||||
be given another chance, if they are receptive to the warning and change their
|
||||
behavior.
|
||||
5. If the community member is unreceptive or unreasonable when warned by a
|
||||
moderator, or the warning goes unheeded, they may be banned for a first or
|
||||
second offense. Repeated offenses will result in the community member being
|
||||
banned.
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## 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. As a community
|
||||
member, you are representing our community, and are expected to behave
|
||||
accordingly.
|
||||
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.
|
||||
|
||||
## Attribution
|
||||
|
||||
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).
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
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.
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
|
|
|
|||
88
README.rst
88
README.rst
|
|
@ -6,18 +6,17 @@ Introduction
|
|||
:alt: Documentation Status
|
||||
|
||||
.. image:: https://img.shields.io/discord/327254708534116352.svg
|
||||
:target: https://adafru.it/discord
|
||||
:target: https://discord.gg/nBQh6qu
|
||||
:alt: Discord
|
||||
|
||||
.. image:: https://github.com/adafruit/Adafruit_CircuitPython_AS726x/workflows/Build%20CI/badge.svg
|
||||
:target: https://github.com/adafruit/Adafruit_CircuitPython_AS726x/actions/
|
||||
.. image:: https://travis-ci.org/adafruit/Adafruit_CircuitPython_AS726x.svg?branch=master
|
||||
:target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_AS726x
|
||||
:alt: Build Status
|
||||
|
||||
Driver for the AS726x spectral sensors
|
||||
|
||||
Installation and Dependencies
|
||||
=============================
|
||||
|
||||
Dependencies
|
||||
=============
|
||||
This driver depends on:
|
||||
|
||||
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
|
||||
|
|
@ -28,32 +27,6 @@ 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-as726x/>`_. To install for
|
||||
current user:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
pip3 install adafruit-circuitpython-as726x
|
||||
|
||||
To install system-wide (this may be required in some cases:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
sudo pip3 install adafruit-circuitpython-as726x
|
||||
|
||||
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-as726x
|
||||
|
||||
Contributing
|
||||
============
|
||||
|
||||
|
|
@ -61,7 +34,52 @@ Contributions are welcome! Please read our `Code of Conduct
|
|||
<https://github.com/adafruit/adafruit_CircuitPython_AS726x/blob/master/CODE_OF_CONDUCT.md>`_
|
||||
before contributing to help this project stay welcoming.
|
||||
|
||||
Documentation
|
||||
=============
|
||||
Building locally
|
||||
================
|
||||
|
||||
For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.
|
||||
Zip release files
|
||||
-----------------
|
||||
|
||||
To build this library locally you'll need to install the
|
||||
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
python3 -m venv .env
|
||||
source .env/bin/activate
|
||||
pip install circuitpython-build-tools
|
||||
|
||||
Once installed, make sure you are in the virtual environment:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
source .env/bin/activate
|
||||
|
||||
Then run the build:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-as726x --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.
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ _AS726X_INT_T = const(0x05)
|
|||
_AS726X_DEVICE_TEMP = const(0x06)
|
||||
_AS726X_LED_CONTROL = const(0x07)
|
||||
|
||||
# for reading sensor data
|
||||
#for reading sensor data
|
||||
_AS7262_V_HIGH = const(0x08)
|
||||
_AS7262_V_LOW = const(0x09)
|
||||
_AS7262_B_HIGH = const(0x0A)
|
||||
|
|
@ -70,7 +70,7 @@ _AS7262_Y_CAL = const(0x20)
|
|||
_AS7262_O_CAL = const(0x24)
|
||||
_AS7262_R_CAL = const(0x28)
|
||||
|
||||
# hardware registers
|
||||
#hardware registers
|
||||
_AS726X_SLAVE_STATUS_REG = const(0x00)
|
||||
_AS726X_SLAVE_WRITE_REG = const(0x01)
|
||||
_AS726X_SLAVE_READ_REG = const(0x02)
|
||||
|
|
@ -92,33 +92,12 @@ _AS7262_RED_CALIBRATED = const(0x28)
|
|||
|
||||
_AS726X_NUM_CHANNELS = const(6)
|
||||
|
||||
_COLOR_REGS = (
|
||||
_AS7262_VIOLET,
|
||||
_AS7262_BLUE,
|
||||
_AS7262_GREEN,
|
||||
_AS7262_YELLOW,
|
||||
_AS7262_ORANGE,
|
||||
_AS7262_RED,
|
||||
)
|
||||
_COLOR_REGS_CALIBRATED = (
|
||||
_AS7262_VIOLET_CALIBRATED,
|
||||
_AS7262_BLUE_CALIBRATED,
|
||||
_AS7262_GREEN_CALIBRATED,
|
||||
_AS7262_YELLOW_CALIBRATED,
|
||||
_AS7262_ORANGE_CALIBRATED,
|
||||
_AS7262_RED_CALIBRATED,
|
||||
)
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
# pylint: disable=too-many-public-methods
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: disable=no-else-return
|
||||
# pylint: disable=inconsistent-return-statements
|
||||
|
||||
|
||||
class AS726x:
|
||||
"""AS726x spectral sensor base class.
|
||||
#pylint: disable=too-many-instance-attributes
|
||||
#pylint: disable=too-many-public-methods
|
||||
class Adafruit_AS726x(object):
|
||||
"""AS726x spectral sensor.
|
||||
|
||||
:param ~busio.I2C i2c_bus: The I2C bus connected to the sensor
|
||||
"""
|
||||
|
||||
MODE_0 = 0b00
|
||||
|
|
@ -129,7 +108,7 @@ class AS726x:
|
|||
"""Continuously gather samples of green, yellow, orange and red. Violet and blue are skipped
|
||||
and read zero."""
|
||||
|
||||
MODE_2 = 0b10 # default
|
||||
MODE_2 = 0b10 #default
|
||||
"""Continuously gather samples of all colors"""
|
||||
|
||||
ONE_SHOT = 0b11
|
||||
|
|
@ -141,33 +120,33 @@ class AS726x:
|
|||
|
||||
DRIVER_CURRENT_LIMITS = (12.5, 25, 50, 100)
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, i2c_bus):
|
||||
self._driver_led = False
|
||||
self._indicator_led = False
|
||||
self._driver_led_current = AS726x.DRIVER_CURRENT_LIMITS.index(12.5)
|
||||
self._indicator_led_current = AS726x.INDICATOR_CURRENT_LIMITS.index(1)
|
||||
self._conversion_mode = AS726x.MODE_2
|
||||
self._driver_led_current = Adafruit_AS726x.DRIVER_CURRENT_LIMITS.index(12.5)
|
||||
self._indicator_led_current = Adafruit_AS726x.INDICATOR_CURRENT_LIMITS.index(1)
|
||||
self._conversion_mode = Adafruit_AS726x.MODE_2
|
||||
self._integration_time = 0
|
||||
self._gain = AS726x.GAIN.index(1)
|
||||
self._gain = Adafruit_AS726x.GAIN.index(1)
|
||||
self.buf2 = bytearray(2)
|
||||
|
||||
# reset device
|
||||
self.i2c_device = I2CDevice(i2c_bus, _AS726X_ADDRESS)
|
||||
|
||||
#reset device
|
||||
self._virtual_write(_AS726X_CONTROL_SETUP, 0x80)
|
||||
|
||||
# wait for it to boot up
|
||||
#wait for it to boot up
|
||||
time.sleep(1)
|
||||
|
||||
# try to read the version reg to make sure we can connect
|
||||
#try to read the version reg to make sure we can connect
|
||||
version = self._virtual_read(_AS726X_HW_VERSION)
|
||||
|
||||
# TODO: add support for other devices
|
||||
#TODO: add support for other devices
|
||||
if version != 0x40:
|
||||
raise ValueError(
|
||||
"device could not be reached or this device is not supported!"
|
||||
)
|
||||
raise ValueError("device could not be reached or this device is not supported!")
|
||||
|
||||
self.integration_time = 140
|
||||
self.conversion_mode = AS726x.MODE_2
|
||||
self.conversion_mode = Adafruit_AS726x.MODE_2
|
||||
self.gain = 64
|
||||
|
||||
@property
|
||||
|
|
@ -212,14 +191,14 @@ class AS726x:
|
|||
|
||||
@driver_led_current.setter
|
||||
def driver_led_current(self, val):
|
||||
if val not in AS726x.DRIVER_CURRENT_LIMITS:
|
||||
if val not in Adafruit_AS726x.DRIVER_CURRENT_LIMITS:
|
||||
raise ValueError("Must be 12.5, 25, 50 or 100")
|
||||
if self._driver_led_current == val:
|
||||
return
|
||||
self._driver_led_current = val
|
||||
state = self._virtual_read(_AS726X_LED_CONTROL)
|
||||
state &= ~(0x3 << 4)
|
||||
state = state | (AS726x.DRIVER_CURRENT_LIMITS.index(val) << 4)
|
||||
state = state | (Adafruit_AS726x.DRIVER_CURRENT_LIMITS.index(val) << 4)
|
||||
self._virtual_write(_AS726X_LED_CONTROL, state)
|
||||
|
||||
@property
|
||||
|
|
@ -234,14 +213,14 @@ class AS726x:
|
|||
|
||||
@indicator_led_current.setter
|
||||
def indicator_led_current(self, val):
|
||||
if val not in AS726x.INDICATOR_CURRENT_LIMITS:
|
||||
if val not in Adafruit_AS726x.INDICATOR_CURRENT_LIMITS:
|
||||
raise ValueError("Must be 1, 2, 4 or 8")
|
||||
if self._indicator_led_current == val:
|
||||
return
|
||||
self._indicator_led_current = val
|
||||
state = self._virtual_read(_AS726X_LED_CONTROL)
|
||||
state &= ~(0x3 << 1)
|
||||
state = state | (AS726x.INDICATOR_CURRENT_LIMITS.index(val) << 4)
|
||||
state = state | (Adafruit_AS726x.INDICATOR_CURRENT_LIMITS.index(val) << 4)
|
||||
self._virtual_write(_AS726X_LED_CONTROL, state)
|
||||
|
||||
@property
|
||||
|
|
@ -272,14 +251,14 @@ class AS726x:
|
|||
|
||||
@gain.setter
|
||||
def gain(self, val):
|
||||
if val not in AS726x.GAIN:
|
||||
if val not in Adafruit_AS726x.GAIN:
|
||||
raise ValueError("Must be 1, 3.7, 16 or 64")
|
||||
if self._gain == val:
|
||||
return
|
||||
self._gain = val
|
||||
state = self._virtual_read(_AS726X_CONTROL_SETUP)
|
||||
state &= ~(0x3 << 4)
|
||||
state |= AS726x.GAIN.index(val) << 4
|
||||
state |= (Adafruit_AS726x.GAIN.index(val) << 4)
|
||||
self._virtual_write(_AS726X_CONTROL_SETUP, state)
|
||||
|
||||
@property
|
||||
|
|
@ -295,7 +274,7 @@ class AS726x:
|
|||
if self._integration_time == val:
|
||||
return
|
||||
self._integration_time = val
|
||||
self._virtual_write(_AS726X_INT_T, int(val / 2.8))
|
||||
self._virtual_write(_AS726X_INT_T, int(val/2.8))
|
||||
|
||||
def start_measurement(self):
|
||||
"""Begin a measurement.
|
||||
|
|
@ -319,7 +298,7 @@ class AS726x:
|
|||
val[1] = self._virtual_read(channel + 1)
|
||||
val[2] = self._virtual_read(channel + 2)
|
||||
val[3] = self._virtual_read(channel + 3)
|
||||
return struct.unpack("!f", val)[0]
|
||||
return struct.unpack('!f', val)[0]
|
||||
|
||||
@property
|
||||
def data_ready(self):
|
||||
|
|
@ -391,23 +370,6 @@ class AS726x:
|
|||
"""Raw red (650nm) 16-bit value"""
|
||||
return self.read_channel(_AS7262_RED)
|
||||
|
||||
def _virtual_read(self, addr):
|
||||
raise NotImplementedError("Must be implemented.")
|
||||
|
||||
def _virtual_write(self, addr, value):
|
||||
raise NotImplementedError("Must be implemented.")
|
||||
|
||||
|
||||
class AS726x_I2C(AS726x):
|
||||
"""AS726x spectral sensor via I2C.
|
||||
|
||||
:param ~busio.I2C i2c_bus: The I2C bus connected to the sensor
|
||||
"""
|
||||
|
||||
def __init__(self, i2c_bus, address=_AS726X_ADDRESS):
|
||||
self.i2c_device = I2CDevice(i2c_bus, address)
|
||||
super().__init__()
|
||||
|
||||
def _read_u8(self, command):
|
||||
"""read a single byte from a specified register"""
|
||||
buf = self.buf2
|
||||
|
|
@ -451,97 +413,18 @@ class AS726x_I2C(AS726x):
|
|||
# Read slave I2C status to see if the write buffer is ready.
|
||||
status = self._read_u8(_AS726X_SLAVE_STATUS_REG)
|
||||
if (status & _AS726X_SLAVE_TX_VALID) == 0:
|
||||
break # No inbound TX pending at slave. Okay to write now.
|
||||
break # No inbound TX pending at slave. Okay to write now.
|
||||
# Send the virtual register address (setting bit 7 to indicate a pending write).
|
||||
self.__write_u8(_AS726X_SLAVE_WRITE_REG, (addr | 0x80))
|
||||
while True:
|
||||
# Read the slave I2C status to see if the write buffer is ready.
|
||||
status = self._read_u8(_AS726X_SLAVE_STATUS_REG)
|
||||
if (status & _AS726X_SLAVE_TX_VALID) == 0:
|
||||
break # No inbound TX pending at slave. Okay to write data now.
|
||||
break # No inbound TX pending at slave. Okay to write data now.
|
||||
|
||||
# Send the data to complete the operation.
|
||||
self.__write_u8(_AS726X_SLAVE_WRITE_REG, value)
|
||||
|
||||
|
||||
class AS726x_UART(AS726x):
|
||||
"""AS726x spectral sensor via UART.
|
||||
|
||||
:param ~busio.UART uart: The UART connected to the sensor
|
||||
"""
|
||||
|
||||
def __init__(self, uart):
|
||||
self._uart = uart
|
||||
self._uart.baudrate = 115200
|
||||
super().__init__()
|
||||
|
||||
def read_channel(self, channel):
|
||||
"""Read an individual sensor channel"""
|
||||
return self._virtual_read(channel)
|
||||
|
||||
def read_calibrated_value(self, channel):
|
||||
"""Read a calibrated sensor channel"""
|
||||
return self._virtual_read(channel)
|
||||
|
||||
def _uart_xfer(self, cmd):
|
||||
self._uart.reset_input_buffer()
|
||||
cmd += "\n"
|
||||
self._uart.write(cmd.encode())
|
||||
time.sleep(0.1)
|
||||
if self._uart.in_waiting:
|
||||
resp = self._uart.read(self._uart.in_waiting)
|
||||
return resp.rstrip(b" OK\n")
|
||||
return None
|
||||
|
||||
def _virtual_read(self, addr):
|
||||
if addr == _AS726X_HW_VERSION:
|
||||
# just return what is expected
|
||||
return 0x40
|
||||
elif addr == _AS726X_DEVICE_TEMP:
|
||||
return int(self._uart_xfer("ATTEMP"))
|
||||
elif addr == _AS726X_LED_CONTROL:
|
||||
LED_IND = int(self._uart_xfer("ATLED0"))
|
||||
LED_DRV = int(self._uart_xfer("ATLED1"))
|
||||
return LED_IND << 3 | LED_DRV
|
||||
elif addr == _AS726X_CONTROL_SETUP:
|
||||
GAIN = int(self._uart_xfer("ATGAIN"))
|
||||
BANK = int(self._uart_xfer("ATTCSMD"))
|
||||
return GAIN << 4 | BANK << 2 | 1 << 1
|
||||
elif addr in _COLOR_REGS:
|
||||
resp = self._uart_xfer("ATDATA")
|
||||
resp = resp.decode().split(",")
|
||||
return int(resp[_COLOR_REGS.index(addr)])
|
||||
elif addr in _COLOR_REGS_CALIBRATED:
|
||||
resp = self._uart_xfer("ATCDATA")
|
||||
resp = resp.decode().split(",")
|
||||
return float(resp[_COLOR_REGS_CALIBRATED.index(addr)])
|
||||
|
||||
def _virtual_write(self, addr, value):
|
||||
if addr == _AS726X_CONTROL_SETUP:
|
||||
# check for reset
|
||||
if (value >> 7) & 0x01:
|
||||
self._uart.write(b"ATRST\n")
|
||||
return
|
||||
# otherwise proceed
|
||||
GAIN = (value >> 4) & 0x03
|
||||
BANK = (value >> 2) & 0x03
|
||||
self._uart_xfer("ATGAIN={}".format(GAIN))
|
||||
self._uart_xfer("ATTCSMD={}".format(BANK))
|
||||
elif addr == _AS726X_LED_CONTROL:
|
||||
ICL_DRV = (value >> 4) & 0x07
|
||||
LED_DRV = 100 if value & 0x08 else 0
|
||||
ICL_IND = (value >> 1) & 0x07
|
||||
LED_IND = 100 if value & 0x01 else 0
|
||||
self._uart_xfer("ATLED0={}".format(LED_IND))
|
||||
self._uart_xfer("ATLED1={}".format(LED_DRV))
|
||||
self._uart_xfer("ATLEDC={}".format(ICL_DRV << 4 | ICL_IND))
|
||||
elif addr == _AS726X_INT_T:
|
||||
value = int(value / 2.8)
|
||||
self._uart_xfer("ATINTTIME={}".format(value))
|
||||
|
||||
|
||||
# pylint: enable=too-many-instance-attributes
|
||||
# pylint: enable=too-many-public-methods
|
||||
# pylint: enable=invalid-name
|
||||
# pylint: enable=no-else-return
|
||||
# pylint: enable=inconsistent-return-statements
|
||||
#pylint: enable=too-many-instance-attributes
|
||||
#pylint: enable=too-many-public-methods
|
||||
|
|
|
|||
123
docs/conf.py
123
docs/conf.py
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath(".."))
|
||||
sys.path.insert(0, os.path.abspath('..'))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
|
|
@ -11,47 +10,41 @@ 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.todo",
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.todo',
|
||||
]
|
||||
|
||||
autodoc_member_order = "bysource"
|
||||
# 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", "adafruit_bus_device", "micropython", "ustruct"]
|
||||
|
||||
intersphinx_mapping = {
|
||||
"python": ("https://docs.python.org/3.4", None),
|
||||
"BusDevice": (
|
||||
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
|
||||
None,
|
||||
),
|
||||
"Register": (
|
||||
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
|
||||
None,
|
||||
),
|
||||
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
|
||||
}
|
||||
autodoc_member_order = 'bysource'
|
||||
|
||||
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/bus_device/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ["_templates"]
|
||||
templates_path = ['_templates']
|
||||
|
||||
source_suffix = ".rst"
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = "index"
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = "Adafruit AS726x Library"
|
||||
copyright = "2017 Dean Miller"
|
||||
author = "Dean Miller"
|
||||
project = u'Adafruit AS726x Library'
|
||||
copyright = u'2017 Dean Miller'
|
||||
author = u'Dean Miller'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = "1.0"
|
||||
version = u'1.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = "1.0"
|
||||
release = u'1.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
|
@ -63,7 +56,7 @@ language = None
|
|||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This patterns also effect to html_static_path and html_extra_path
|
||||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
|
|
@ -75,7 +68,7 @@ default_role = "any"
|
|||
add_function_parentheses = True
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = "sphinx"
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = False
|
||||
|
|
@ -89,56 +82,53 @@ todo_emit_warnings = True
|
|||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
|
||||
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||
|
||||
if not on_rtd: # only import and set the theme if we're building docs locally
|
||||
try:
|
||||
import sphinx_rtd_theme
|
||||
|
||||
html_theme = "sphinx_rtd_theme"
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
|
||||
except:
|
||||
html_theme = "default"
|
||||
html_theme_path = ["."]
|
||||
html_theme = 'default'
|
||||
html_theme_path = ['.']
|
||||
else:
|
||||
html_theme_path = ["."]
|
||||
html_theme_path = ['.']
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ["_static"]
|
||||
html_static_path = ['_static']
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = "AdafruitAs726xLibrarydoc"
|
||||
htmlhelp_basename = 'AdafruitAs726xLibrarydoc'
|
||||
|
||||
# -- 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,
|
||||
"AdafruitAS726xLibrary.tex",
|
||||
"AdafruitAS726x Library Documentation",
|
||||
author,
|
||||
"manual",
|
||||
),
|
||||
(master_doc, 'AdafruitAS726xLibrary.tex', u'AdafruitAS726x Library Documentation',
|
||||
author, 'manual'),
|
||||
]
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
|
@ -146,13 +136,8 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(
|
||||
master_doc,
|
||||
"AdafruitAS726xlibrary",
|
||||
"Adafruit AS726x Library Documentation",
|
||||
[author],
|
||||
1,
|
||||
)
|
||||
(master_doc, 'AdafruitAS726xlibrary', u'Adafruit AS726x Library Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
|
@ -161,13 +146,7 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(
|
||||
master_doc,
|
||||
"AdafruitAS726xLibrary",
|
||||
"Adafruit AS726x Library Documentation",
|
||||
author,
|
||||
"AdafruitAS726xLibrary",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
(master_doc, 'AdafruitAS726xLibrary', u'Adafruit AS726x Library Documentation',
|
||||
author, 'AdafruitAS726xLibrary', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,45 +3,35 @@ import time
|
|||
import board
|
||||
import busio
|
||||
|
||||
# for I2C use:
|
||||
from adafruit_as726x import AS726x_I2C
|
||||
from adafruit_as726x import Adafruit_AS726x
|
||||
|
||||
# for UART use:
|
||||
# from adafruit_as726x import AS726x_UART
|
||||
|
||||
# maximum value for sensor reading
|
||||
#maximum value for sensor reading
|
||||
max_val = 16000
|
||||
|
||||
# max number of characters in each graph
|
||||
#max number of characters in each graph
|
||||
max_graph = 80
|
||||
|
||||
|
||||
def graph_map(x):
|
||||
return min(int(x * max_graph / max_val), max_graph)
|
||||
|
||||
|
||||
# for I2C use:
|
||||
# Initialize I2C bus and sensor.
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
sensor = AS726x_I2C(i2c)
|
||||
|
||||
# for UART use:
|
||||
# uart = busio.UART(board.TX, board.RX)
|
||||
# sensor = AS726x_UART(uart)
|
||||
sensor = Adafruit_AS726x(i2c)
|
||||
|
||||
sensor.conversion_mode = sensor.MODE_2
|
||||
|
||||
while True:
|
||||
# Wait for data to be ready
|
||||
while not sensor.data_ready:
|
||||
time.sleep(0.1)
|
||||
time.sleep(.1)
|
||||
|
||||
# plot plot the data
|
||||
#plot plot the data
|
||||
print("\n")
|
||||
print("V: " + graph_map(sensor.violet) * "=")
|
||||
print("B: " + graph_map(sensor.blue) * "=")
|
||||
print("G: " + graph_map(sensor.green) * "=")
|
||||
print("Y: " + graph_map(sensor.yellow) * "=")
|
||||
print("O: " + graph_map(sensor.orange) * "=")
|
||||
print("R: " + graph_map(sensor.red) * "=")
|
||||
print("V: " + graph_map(sensor.violet)*'=')
|
||||
print("B: " + graph_map(sensor.blue)*'=')
|
||||
print("G: " + graph_map(sensor.green)*'=')
|
||||
print("Y: " + graph_map(sensor.yellow)*'=')
|
||||
print("O: " + graph_map(sensor.orange)*'=')
|
||||
print("R: " + graph_map(sensor.red)*'=')
|
||||
|
||||
time.sleep(1)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
Adafruit-Blinka
|
||||
adafruit-circuitpython-busdevice
|
||||
adafruit-circuitpython-bus-device
|
||||
adafruit-circuitpython-register
|
||||
|
|
|
|||
56
setup.py
56
setup.py
|
|
@ -1,56 +0,0 @@
|
|||
"""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-as726x",
|
||||
use_scm_version=True,
|
||||
setup_requires=["setuptools_scm"],
|
||||
description="CircuitPython driver for AS726x spectral sensor.",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/x-rst",
|
||||
# The project's main homepage.
|
||||
url="https://github.com/adafruit/Adafruit_CircuitPython_AS726x",
|
||||
# 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 as726x light sensor hardware micropython circuitpython",
|
||||
# You can just specify the packages manually here if your project is
|
||||
# simple. Or you can use find_packages().
|
||||
py_modules=["adafruit_as726x"],
|
||||
)
|
||||
Loading…
Reference in a new issue