Compare commits
22 commits
dherrada-p
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fd13d292d | ||
|
|
e9411c4244 | ||
|
|
32f706fc21 | ||
|
|
0c9b28a8b3 | ||
|
|
3abe3b753f | ||
|
|
a489e58f48 | ||
|
|
5297ceb3d0 | ||
|
|
db076c2646 | ||
|
|
b2fd81d73c | ||
|
|
f02dc38d7d | ||
|
|
ceaa1953b3 | ||
|
|
6348879c86 | ||
|
|
edd71b8c31 | ||
|
|
2d90646065 | ||
|
|
99e9c32584 | ||
|
|
25c92aa020 | ||
|
|
1128d6f638 | ||
|
|
e306f233a4 | ||
|
|
28a7ae6add | ||
|
|
4c2ebba50e | ||
|
|
0b0d1e999a | ||
|
|
805d41a021 |
11 changed files with 245 additions and 185 deletions
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
|
|
@ -34,15 +34,22 @@ jobs:
|
||||||
with:
|
with:
|
||||||
repository: adafruit/actions-ci-circuitpython-libs
|
repository: adafruit/actions-ci-circuitpython-libs
|
||||||
path: actions-ci
|
path: actions-ci
|
||||||
- name: Install deps
|
- name: Install dependencies
|
||||||
|
# (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.)
|
||||||
run: |
|
run: |
|
||||||
source actions-ci/install.sh
|
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
|
- name: Library version
|
||||||
run: git describe --dirty --always --tags
|
run: git describe --dirty --always --tags
|
||||||
|
- name: Check formatting
|
||||||
|
run: |
|
||||||
|
black --check --target-version=py35 .
|
||||||
- name: PyLint
|
- name: PyLint
|
||||||
run: |
|
run: |
|
||||||
pylint $( find . -path './adafruit*.py' )
|
pylint $( find . -path './adafruit*.py' )
|
||||||
([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*.py)
|
([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*.py" ))
|
||||||
- name: Build assets
|
- name: Build assets
|
||||||
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
|
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
|
||||||
- name: Build docs
|
- name: Build docs
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -119,7 +119,8 @@ spelling-store-unknown-words=no
|
||||||
[MISCELLANEOUS]
|
[MISCELLANEOUS]
|
||||||
|
|
||||||
# List of note tags to take in consideration, separated by a comma.
|
# List of note tags to take in consideration, separated by a comma.
|
||||||
notes=FIXME,XXX,TODO
|
# notes=FIXME,XXX,TODO
|
||||||
|
notes=FIXME,XXX
|
||||||
|
|
||||||
|
|
||||||
[TYPECHECK]
|
[TYPECHECK]
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,15 @@ Examples of unacceptable behavior by participants include:
|
||||||
* Excessive or unwelcome helping; answering outside the scope of the question
|
* Excessive or unwelcome helping; answering outside the scope of the question
|
||||||
asked
|
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
|
* Other conduct which could reasonably be considered inappropriate
|
||||||
|
|
||||||
The goal of the standards and moderation guidelines outlined here is to build
|
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
|
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.
|
"technically unimpeachable", but rather try to be your best self.
|
||||||
|
|
||||||
We value many things beyond technical expertise, including collaboration and
|
We value many things beyond technical expertise, including collaboration and
|
||||||
|
|
@ -72,10 +74,10 @@ You may report in the following ways:
|
||||||
In any situation, you may send an email to <support@adafruit.com>.
|
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
|
On the Adafruit Discord, you may send an open message from any channel
|
||||||
to all Community Helpers by tagging @community helpers. You may also send an
|
to all Community Moderators by tagging @community moderators. You may
|
||||||
open message from any channel, or a direct message to @kattni#1507,
|
also send an open message from any channel, or a direct message to
|
||||||
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
|
@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442,
|
||||||
@Andon#8175.
|
@sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175.
|
||||||
|
|
||||||
Email and direct message reports will be kept confidential.
|
Email and direct message reports will be kept confidential.
|
||||||
|
|
||||||
|
|
@ -83,7 +85,7 @@ In situations on Discord where the issue is particularly egregious, possibly
|
||||||
illegal, requires immediate action, or violates the Discord terms of service,
|
illegal, requires immediate action, or violates the Discord terms of service,
|
||||||
you should also report the message directly to Discord.
|
you should also report the message directly to Discord.
|
||||||
|
|
||||||
These are the steps for upholding our community’s standards of conduct.
|
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
|
1. Any member of the community may report any situation that violates the
|
||||||
Adafruit Community Code of Conduct. All reports will be reviewed and
|
Adafruit Community Code of Conduct. All reports will be reviewed and
|
||||||
|
|
@ -124,4 +126,4 @@ For other projects adopting the Adafruit Community Code of
|
||||||
Conduct, please contact the maintainers of those projects for enforcement.
|
Conduct, please contact the maintainers of those projects for enforcement.
|
||||||
If you wish to use this code of conduct for your own project, consider
|
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
|
explicitly mentioning your moderation policy or making a copy with your
|
||||||
own moderation policy so as to avoid confusion.
|
own moderation policy so as to avoid confusion.
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@ Adafruit CircuitPython BusDevice
|
||||||
================================
|
================================
|
||||||
|
|
||||||
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-busdevice/badge/?version=latest
|
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-busdevice/badge/?version=latest
|
||||||
:target: https://circuitpython.readthedocs.io/projects/bus_device/en/latest/
|
:target: https://circuitpython.readthedocs.io/projects/busdevice/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://adafru.it/discord
|
||||||
:alt: Discord
|
:alt: Discord
|
||||||
|
|
||||||
.. image:: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice/workflows/Build%20CI/badge.svg
|
.. image:: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice/workflows/Build%20CI/badge.svg
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
__version__ = "0.0.0-auto.0"
|
__version__ = "0.0.0-auto.0"
|
||||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BusDevice.git"
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BusDevice.git"
|
||||||
|
|
||||||
|
|
||||||
class I2CDevice:
|
class I2CDevice:
|
||||||
"""
|
"""
|
||||||
Represents a single I2C device and manages locking the bus and the device
|
Represents a single I2C device and manages locking the bus and the device
|
||||||
|
|
@ -61,12 +62,13 @@ class I2CDevice:
|
||||||
def __init__(self, i2c, device_address, probe=True):
|
def __init__(self, i2c, device_address, probe=True):
|
||||||
|
|
||||||
self.i2c = i2c
|
self.i2c = i2c
|
||||||
|
self._has_write_read = hasattr(self.i2c, "writeto_then_readfrom")
|
||||||
self.device_address = device_address
|
self.device_address = device_address
|
||||||
|
|
||||||
if probe:
|
if probe:
|
||||||
self.__probe_for_device()
|
self.__probe_for_device()
|
||||||
|
|
||||||
def readinto(self, buf, **kwargs):
|
def readinto(self, buf, *, start=0, end=None):
|
||||||
"""
|
"""
|
||||||
Read into ``buf`` from the device. The number of bytes read will be the
|
Read into ``buf`` from the device. The number of bytes read will be the
|
||||||
length of ``buf``.
|
length of ``buf``.
|
||||||
|
|
@ -77,11 +79,13 @@ class I2CDevice:
|
||||||
|
|
||||||
:param bytearray buffer: buffer to write into
|
:param bytearray buffer: buffer to write into
|
||||||
:param int start: Index to start writing at
|
:param int start: Index to start writing at
|
||||||
:param int end: Index to write up to but not include
|
:param int end: Index to write up to but not include; if None, use ``len(buf)``
|
||||||
"""
|
"""
|
||||||
self.i2c.readfrom_into(self.device_address, buf, **kwargs)
|
if end is None:
|
||||||
|
end = len(buf)
|
||||||
|
self.i2c.readfrom_into(self.device_address, buf, start=start, end=end)
|
||||||
|
|
||||||
def write(self, buf, **kwargs):
|
def write(self, buf, *, start=0, end=None, stop=True):
|
||||||
"""
|
"""
|
||||||
Write the bytes from ``buffer`` to the device. Transmits a stop bit if
|
Write the bytes from ``buffer`` to the device. Transmits a stop bit if
|
||||||
``stop`` is set.
|
``stop`` is set.
|
||||||
|
|
@ -92,14 +96,25 @@ class I2CDevice:
|
||||||
|
|
||||||
:param bytearray buffer: buffer containing the bytes to write
|
:param bytearray buffer: buffer containing the bytes to write
|
||||||
:param int start: Index to start writing from
|
:param int start: Index to start writing from
|
||||||
:param int end: Index to read up to but not include
|
:param int end: Index to read up to but not include; if None, use ``len(buf)``
|
||||||
:param bool stop: If true, output an I2C stop condition after the buffer is written
|
:param bool stop: If true, output an I2C stop condition after the buffer is written
|
||||||
"""
|
"""
|
||||||
self.i2c.writeto(self.device_address, buf, **kwargs)
|
if end is None:
|
||||||
|
end = len(buf)
|
||||||
|
self.i2c.writeto(self.device_address, buf, start=start, end=end, stop=stop)
|
||||||
|
|
||||||
#pylint: disable-msg=too-many-arguments
|
# pylint: disable-msg=too-many-arguments
|
||||||
def write_then_readinto(self, out_buffer, in_buffer, *,
|
def write_then_readinto(
|
||||||
out_start=0, out_end=None, in_start=0, in_end=None, stop=False):
|
self,
|
||||||
|
out_buffer,
|
||||||
|
in_buffer,
|
||||||
|
*,
|
||||||
|
out_start=0,
|
||||||
|
out_end=None,
|
||||||
|
in_start=0,
|
||||||
|
in_end=None,
|
||||||
|
stop=False
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Write the bytes from ``out_buffer`` to the device, then immediately
|
Write the bytes from ``out_buffer`` to the device, then immediately
|
||||||
reads into ``in_buffer`` from the device. The number of bytes read
|
reads into ``in_buffer`` from the device. The number of bytes read
|
||||||
|
|
@ -118,9 +133,9 @@ class I2CDevice:
|
||||||
:param bytearray out_buffer: buffer containing the bytes to write
|
:param bytearray out_buffer: buffer containing the bytes to write
|
||||||
:param bytearray in_buffer: buffer containing the bytes to read into
|
:param bytearray in_buffer: buffer containing the bytes to read into
|
||||||
:param int out_start: Index to start writing from
|
:param int out_start: Index to start writing from
|
||||||
:param int out_end: Index to read up to but not include
|
:param int out_end: Index to read up to but not include; if None, use ``len(out_buffer)``
|
||||||
:param int in_start: Index to start writing at
|
:param int in_start: Index to start writing at
|
||||||
:param int in_end: Index to write up to but not include
|
:param int in_end: Index to write up to but not include; if None, use ``len(in_buffer)``
|
||||||
:param bool stop: Deprecated
|
:param bool stop: Deprecated
|
||||||
"""
|
"""
|
||||||
if out_end is None:
|
if out_end is None:
|
||||||
|
|
@ -129,25 +144,31 @@ class I2CDevice:
|
||||||
in_end = len(in_buffer)
|
in_end = len(in_buffer)
|
||||||
if stop:
|
if stop:
|
||||||
raise ValueError("Stop must be False. Use writeto instead.")
|
raise ValueError("Stop must be False. Use writeto instead.")
|
||||||
if hasattr(self.i2c, 'writeto_then_readfrom'):
|
if self._has_write_read:
|
||||||
# In linux, at least, this is a special kernel function call
|
# In linux, at least, this is a special kernel function call
|
||||||
self.i2c.writeto_then_readfrom(self.device_address, out_buffer, in_buffer,
|
self.i2c.writeto_then_readfrom(
|
||||||
out_start=out_start, out_end=out_end,
|
self.device_address,
|
||||||
in_start=in_start, in_end=in_end)
|
out_buffer,
|
||||||
|
in_buffer,
|
||||||
|
out_start=out_start,
|
||||||
|
out_end=out_end,
|
||||||
|
in_start=in_start,
|
||||||
|
in_end=in_end,
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# If we don't have a special implementation, we can fake it with two calls
|
# If we don't have a special implementation, we can fake it with two calls
|
||||||
self.write(out_buffer, start=out_start, end=out_end, stop=False)
|
self.write(out_buffer, start=out_start, end=out_end, stop=False)
|
||||||
self.readinto(in_buffer, start=in_start, end=in_end)
|
self.readinto(in_buffer, start=in_start, end=in_end)
|
||||||
|
|
||||||
#pylint: enable-msg=too-many-arguments
|
# pylint: enable-msg=too-many-arguments
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
while not self.i2c.try_lock():
|
while not self.i2c.try_lock():
|
||||||
pass
|
pass
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, *exc):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
self.i2c.unlock()
|
self.i2c.unlock()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -160,7 +181,7 @@ class I2CDevice:
|
||||||
while not self.i2c.try_lock():
|
while not self.i2c.try_lock():
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.i2c.writeto(self.device_address, b'')
|
self.i2c.writeto(self.device_address, b"")
|
||||||
except OSError:
|
except OSError:
|
||||||
# some OS's dont like writing an empty bytesting...
|
# some OS's dont like writing an empty bytesting...
|
||||||
# Retry by reading a byte
|
# Retry by reading a byte
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
__version__ = "0.0.0-auto.0"
|
__version__ = "0.0.0-auto.0"
|
||||||
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BusDevice.git"
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BusDevice.git"
|
||||||
|
|
||||||
|
|
||||||
class SPIDevice:
|
class SPIDevice:
|
||||||
"""
|
"""
|
||||||
Represents a single SPI device and manages locking the bus and the device
|
Represents a single SPI device and manages locking the bus and the device
|
||||||
|
|
@ -65,8 +66,17 @@ class SPIDevice:
|
||||||
with device as spi:
|
with device as spi:
|
||||||
spi.write(bytes_read)
|
spi.write(bytes_read)
|
||||||
"""
|
"""
|
||||||
def __init__(self, spi, chip_select=None, *,
|
|
||||||
baudrate=100000, polarity=0, phase=0, extra_clocks=0):
|
def __init__(
|
||||||
|
self,
|
||||||
|
spi,
|
||||||
|
chip_select=None,
|
||||||
|
*,
|
||||||
|
baudrate=100000,
|
||||||
|
polarity=0,
|
||||||
|
phase=0,
|
||||||
|
extra_clocks=0
|
||||||
|
):
|
||||||
self.spi = spi
|
self.spi = spi
|
||||||
self.baudrate = baudrate
|
self.baudrate = baudrate
|
||||||
self.polarity = polarity
|
self.polarity = polarity
|
||||||
|
|
@ -79,18 +89,19 @@ class SPIDevice:
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
while not self.spi.try_lock():
|
while not self.spi.try_lock():
|
||||||
pass
|
pass
|
||||||
self.spi.configure(baudrate=self.baudrate, polarity=self.polarity,
|
self.spi.configure(
|
||||||
phase=self.phase)
|
baudrate=self.baudrate, polarity=self.polarity, phase=self.phase
|
||||||
|
)
|
||||||
if self.chip_select:
|
if self.chip_select:
|
||||||
self.chip_select.value = False
|
self.chip_select.value = False
|
||||||
return self.spi
|
return self.spi
|
||||||
|
|
||||||
def __exit__(self, *exc):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
if self.chip_select:
|
if self.chip_select:
|
||||||
self.chip_select.value = True
|
self.chip_select.value = True
|
||||||
if self.extra_clocks > 0:
|
if self.extra_clocks > 0:
|
||||||
buf = bytearray(1)
|
buf = bytearray(1)
|
||||||
buf[0] = 0xff
|
buf[0] = 0xFF
|
||||||
clocks = self.extra_clocks // 8
|
clocks = self.extra_clocks // 8
|
||||||
if self.extra_clocks % 8 != 0:
|
if self.extra_clocks % 8 != 0:
|
||||||
clocks += 1
|
clocks += 1
|
||||||
|
|
|
||||||
116
docs/conf.py
116
docs/conf.py
|
|
@ -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,46 @@ 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
|
# Uncomment the below if you use native CircuitPython modules such as
|
||||||
# digitalio, micropython and busio. List the modules you use. Without it, the
|
# digitalio, micropython and busio. List the modules you use. Without it, the
|
||||||
# autodoc module docs will fail to generate with a warning.
|
# autodoc module docs will fail to generate with a warning.
|
||||||
#autodoc_mock_imports = ["adafruit_bus_device", "micropython"]
|
# autodoc_mock_imports = ["adafruit_bus_device", "micropython"]
|
||||||
|
|
||||||
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/bus_device/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
|
intersphinx_mapping = {
|
||||||
|
"python": ("https://docs.python.org/3.4", None),
|
||||||
|
"BusDevice": (
|
||||||
|
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
"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 = 'index'
|
master_doc = "index"
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'Adafruit CircuitPython Bus Device'
|
project = "Adafruit CircuitPython Bus Device"
|
||||||
copyright = u'2016-2017 Scott Shawcroft and Tony Dicola for Adafruit Industries'
|
copyright = "2016-2017 Scott Shawcroft and Tony Dicola for Adafruit Industries"
|
||||||
author = u'Scott Shawcroft and Tony Dicola'
|
author = "Scott Shawcroft and Tony Dicola"
|
||||||
|
|
||||||
# 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 +62,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', '.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
|
# The reST default role (used for this markup: `text`) to use for all
|
||||||
# documents.
|
# documents.
|
||||||
|
|
@ -66,7 +74,7 @@ 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
|
||||||
|
|
@ -80,59 +88,62 @@ todo_emit_warnings = True
|
||||||
# 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 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
|
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||||
# pixels large.
|
# pixels large.
|
||||||
#
|
#
|
||||||
html_favicon = '_static/favicon.ico'
|
html_favicon = "_static/favicon.ico"
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = 'AdafruitBusDeviceLibrarydoc'
|
htmlhelp_basename = "AdafruitBusDeviceLibrarydoc"
|
||||||
|
|
||||||
# -- 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, 'AdafruitBusDeviceLibrary.tex', u'Adafruit Bus Device Library Documentation',
|
(
|
||||||
author, 'manual'),
|
master_doc,
|
||||||
|
"AdafruitBusDeviceLibrary.tex",
|
||||||
|
"Adafruit Bus Device Library Documentation",
|
||||||
|
author,
|
||||||
|
"manual",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
# -- Options for manual page output ---------------------------------------
|
# -- Options for manual page output ---------------------------------------
|
||||||
|
|
@ -140,8 +151,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, 'AdafruitBusDeviceLibrary', u'Adafruit Bus Device Library Documentation',
|
(
|
||||||
[author], 1)
|
master_doc,
|
||||||
|
"AdafruitBusDeviceLibrary",
|
||||||
|
"Adafruit Bus Device Library Documentation",
|
||||||
|
[author],
|
||||||
|
1,
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
# -- Options for Texinfo output -------------------------------------------
|
# -- Options for Texinfo output -------------------------------------------
|
||||||
|
|
@ -150,7 +166,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, 'AdafruitBusDeviceLibrary', u'Adafruit Bus Device Library Documentation',
|
(
|
||||||
author, 'AdafruitBusDeviceLibrary', 'One line description of project.',
|
master_doc,
|
||||||
'Miscellaneous'),
|
"AdafruitBusDeviceLibrary",
|
||||||
|
"Adafruit Bus Device Library Documentation",
|
||||||
|
author,
|
||||||
|
"AdafruitBusDeviceLibrary",
|
||||||
|
"One line description of project.",
|
||||||
|
"Miscellaneous",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
134
docs/conf_old.py
134
docs/conf_old.py
|
|
@ -21,62 +21,63 @@ from recommonmark.parser import CommonMarkParser
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
sys.path.insert(0, os.path.abspath('.'))
|
sys.path.insert(0, os.path.abspath("."))
|
||||||
|
|
||||||
|
|
||||||
# Specify a custom master document based on the port name
|
# Specify a custom master document based on the port name
|
||||||
master_doc = 'README'
|
master_doc = "README"
|
||||||
|
|
||||||
# -- General configuration ------------------------------------------------
|
# -- General configuration ------------------------------------------------
|
||||||
|
|
||||||
# If your documentation needs a minimal Sphinx version, state it here.
|
# If your documentation needs a minimal Sphinx version, state it here.
|
||||||
needs_sphinx = '1.3'
|
needs_sphinx = "1.3"
|
||||||
|
|
||||||
# Add any Sphinx extension module names here, as strings. They can be
|
# Add any Sphinx extension module names here, as strings. They can be
|
||||||
# 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.doctest',
|
"sphinx.ext.doctest",
|
||||||
'sphinx.ext.intersphinx',
|
"sphinx.ext.intersphinx",
|
||||||
'sphinx.ext.todo',
|
"sphinx.ext.todo",
|
||||||
'sphinx.ext.coverage'
|
"sphinx.ext.coverage",
|
||||||
]
|
]
|
||||||
|
|
||||||
# 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"]
|
||||||
|
|
||||||
# The suffix of source filenames.
|
# The suffix of source filenames.
|
||||||
source_suffix = ['.rst', '.md']
|
source_suffix = [".rst", ".md"]
|
||||||
|
|
||||||
source_parsers = {'.md': CommonMarkParser }
|
source_parsers = {".md": CommonMarkParser}
|
||||||
|
|
||||||
# The encoding of source files.
|
# The encoding of source files.
|
||||||
#source_encoding = 'utf-8-sig'
|
# source_encoding = 'utf-8-sig'
|
||||||
|
|
||||||
# The master toctree document.
|
# The master toctree document.
|
||||||
#master_doc = 'index'
|
# master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = 'Adafruit CircuitPython Bus Device'
|
project = "Adafruit CircuitPython Bus Device"
|
||||||
copyright = '2016-2017 Scott Shawcroft and Tony Dicola for Adafruit Industries'
|
copyright = "2016-2017 Scott Shawcroft and Tony Dicola for Adafruit Industries"
|
||||||
|
|
||||||
from pkg_resources import get_distribution
|
from pkg_resources import get_distribution
|
||||||
release = get_distribution('adafruit-circuitpython-bus_device').version
|
|
||||||
|
release = get_distribution("adafruit-circuitpython-bus_device").version
|
||||||
# for example take major/minor
|
# for example take major/minor
|
||||||
version = '.'.join(release.split('.')[:2])
|
version = ".".join(release.split(".")[:2])
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '0.1'
|
release = "0.1"
|
||||||
|
|
||||||
# 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.
|
||||||
#language = None
|
# language = None
|
||||||
|
|
||||||
# There are two options for replacing |today|: either, you set today to some
|
# There are two options for replacing |today|: either, you set today to some
|
||||||
# non-false value, then it is used:
|
# non-false value, then it is used:
|
||||||
#today = ''
|
# today = ''
|
||||||
# Else, today_fmt is used as the format for a strftime call.
|
# Else, today_fmt is used as the format for a strftime call.
|
||||||
#today_fmt = '%B %d, %Y'
|
# today_fmt = '%B %d, %Y'
|
||||||
|
|
||||||
# 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.
|
||||||
|
|
@ -86,7 +87,7 @@ release = '0.1'
|
||||||
default_role = "any"
|
default_role = "any"
|
||||||
|
|
||||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||||
#add_function_parentheses = True
|
# add_function_parentheses = True
|
||||||
|
|
||||||
# If true, the current module name will be prepended to all description
|
# If true, the current module name will be prepended to all description
|
||||||
# unit titles (such as .. function::).
|
# unit titles (such as .. function::).
|
||||||
|
|
@ -94,111 +95,112 @@ add_module_names = False
|
||||||
|
|
||||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||||
# output. They are ignored by default.
|
# output. They are ignored by default.
|
||||||
#show_authors = False
|
# show_authors = False
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
# A list of ignored prefixes for module index sorting.
|
# A list of ignored prefixes for module index sorting.
|
||||||
#modindex_common_prefix = []
|
# modindex_common_prefix = []
|
||||||
|
|
||||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||||
#keep_warnings = False
|
# keep_warnings = False
|
||||||
|
|
||||||
|
|
||||||
# -- Options for HTML output ----------------------------------------------
|
# -- Options for HTML output ----------------------------------------------
|
||||||
|
|
||||||
# on_rtd is whether we are on readthedocs.org
|
# on_rtd is whether we are on readthedocs.org
|
||||||
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 = ["."]
|
||||||
|
|
||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
# Theme options are theme-specific and customize the look and feel of a theme
|
||||||
# further. For a list of options available for each theme, see the
|
# further. For a list of options available for each theme, see the
|
||||||
# documentation.
|
# documentation.
|
||||||
#html_theme_options = {}
|
# html_theme_options = {}
|
||||||
|
|
||||||
# Add any paths that contain custom themes here, relative to this directory.
|
# Add any paths that contain custom themes here, relative to this directory.
|
||||||
# html_theme_path = ['.']
|
# html_theme_path = ['.']
|
||||||
|
|
||||||
# The name for this set of Sphinx documents. If None, it defaults to
|
# The name for this set of Sphinx documents. If None, it defaults to
|
||||||
# "<project> v<release> documentation".
|
# "<project> v<release> documentation".
|
||||||
#html_title = None
|
# html_title = None
|
||||||
|
|
||||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||||
#html_short_title = None
|
# html_short_title = None
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top
|
# The name of an image file (relative to this directory) to place at the top
|
||||||
# of the sidebar.
|
# of the sidebar.
|
||||||
#html_logo = '../../logo/trans-logo.png'
|
# html_logo = '../../logo/trans-logo.png'
|
||||||
|
|
||||||
# The name of an image file (within the static path) to use as favicon of the
|
# The name of an image file (within the static path) to use as favicon of the
|
||||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||||
# pixels large.
|
# pixels large.
|
||||||
#html_favicon = None
|
# html_favicon = None
|
||||||
|
|
||||||
# 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 = ['docs/static']
|
html_static_path = ["docs/static"]
|
||||||
|
|
||||||
# Add any extra paths that contain custom files (such as robots.txt or
|
# Add any extra paths that contain custom files (such as robots.txt or
|
||||||
# .htaccess) here, relative to this directory. These files are copied
|
# .htaccess) here, relative to this directory. These files are copied
|
||||||
# directly to the root of the documentation.
|
# directly to the root of the documentation.
|
||||||
#html_extra_path = []
|
# html_extra_path = []
|
||||||
|
|
||||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||||
# using the given strftime format.
|
# using the given strftime format.
|
||||||
html_last_updated_fmt = '%d %b %Y'
|
html_last_updated_fmt = "%d %b %Y"
|
||||||
|
|
||||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||||
# typographically correct entities.
|
# typographically correct entities.
|
||||||
#html_use_smartypants = True
|
# html_use_smartypants = True
|
||||||
|
|
||||||
# Custom sidebar templates, maps document names to template names.
|
# Custom sidebar templates, maps document names to template names.
|
||||||
#html_sidebars = {}
|
# html_sidebars = {}
|
||||||
|
|
||||||
# Additional templates that should be rendered to pages, maps page names to
|
# Additional templates that should be rendered to pages, maps page names to
|
||||||
# template names.
|
# template names.
|
||||||
#html_additional_pages = {"index": "topindex.html"}
|
# html_additional_pages = {"index": "topindex.html"}
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#html_domain_indices = True
|
# html_domain_indices = True
|
||||||
|
|
||||||
# If false, no index is generated.
|
# If false, no index is generated.
|
||||||
#html_use_index = True
|
# html_use_index = True
|
||||||
|
|
||||||
# If true, the index is split into individual pages for each letter.
|
# If true, the index is split into individual pages for each letter.
|
||||||
#html_split_index = False
|
# html_split_index = False
|
||||||
|
|
||||||
# If true, links to the reST sources are added to the pages.
|
# If true, links to the reST sources are added to the pages.
|
||||||
#html_show_sourcelink = True
|
# html_show_sourcelink = True
|
||||||
|
|
||||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||||
#html_show_sphinx = True
|
# html_show_sphinx = True
|
||||||
|
|
||||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||||
#html_show_copyright = True
|
# html_show_copyright = True
|
||||||
|
|
||||||
# If true, an OpenSearch description file will be output, and all pages will
|
# If true, an OpenSearch description file will be output, and all pages will
|
||||||
# contain a <link> tag referring to it. The value of this option must be the
|
# contain a <link> tag referring to it. The value of this option must be the
|
||||||
# base URL from which the finished HTML is served.
|
# base URL from which the finished HTML is served.
|
||||||
#html_use_opensearch = ''
|
# html_use_opensearch = ''
|
||||||
|
|
||||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||||
#html_file_suffix = None
|
# html_file_suffix = None
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = 'MicroPythondoc'
|
htmlhelp_basename = "MicroPythondoc"
|
||||||
|
|
||||||
|
|
||||||
# -- Options for LaTeX output ---------------------------------------------
|
# -- Options for LaTeX output ---------------------------------------------
|
||||||
|
|
@ -224,23 +226,23 @@ htmlhelp_basename = 'MicroPythondoc'
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
# The name of an image file (relative to this directory) to place at the top of
|
||||||
# the title page.
|
# the title page.
|
||||||
#latex_logo = None
|
# latex_logo = None
|
||||||
|
|
||||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||||
# not chapters.
|
# not chapters.
|
||||||
#latex_use_parts = False
|
# latex_use_parts = False
|
||||||
|
|
||||||
# If true, show page references after internal links.
|
# If true, show page references after internal links.
|
||||||
#latex_show_pagerefs = False
|
# latex_show_pagerefs = False
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
# If true, show URL addresses after external links.
|
||||||
#latex_show_urls = False
|
# latex_show_urls = False
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
# Documents to append as an appendix to all manuals.
|
||||||
#latex_appendices = []
|
# latex_appendices = []
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#latex_domain_indices = True
|
# latex_domain_indices = True
|
||||||
|
|
||||||
|
|
||||||
# -- Options for manual page output ---------------------------------------
|
# -- Options for manual page output ---------------------------------------
|
||||||
|
|
@ -253,7 +255,7 @@ htmlhelp_basename = 'MicroPythondoc'
|
||||||
# ]
|
# ]
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
# If true, show URL addresses after external links.
|
||||||
#man_show_urls = False
|
# man_show_urls = False
|
||||||
|
|
||||||
|
|
||||||
# -- Options for Texinfo output -------------------------------------------
|
# -- Options for Texinfo output -------------------------------------------
|
||||||
|
|
@ -268,18 +270,20 @@ htmlhelp_basename = 'MicroPythondoc'
|
||||||
# ]
|
# ]
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
# Documents to append as an appendix to all manuals.
|
||||||
#texinfo_appendices = []
|
# texinfo_appendices = []
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#texinfo_domain_indices = True
|
# texinfo_domain_indices = True
|
||||||
|
|
||||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||||
#texinfo_show_urls = 'footnote'
|
# texinfo_show_urls = 'footnote'
|
||||||
|
|
||||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||||
#texinfo_no_detailmenu = False
|
# texinfo_no_detailmenu = False
|
||||||
|
|
||||||
|
|
||||||
# Example configuration for intersphinx: refer to the Python standard library.
|
# Example configuration for intersphinx: refer to the Python standard library.
|
||||||
intersphinx_mapping = {'https://docs.python.org/3/': None,
|
intersphinx_mapping = {
|
||||||
'https://circuitpython.readthedocs.io/en/latest/': None}
|
"https://docs.python.org/3/": None,
|
||||||
|
"https://circuitpython.readthedocs.io/en/latest/": None,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ import busio
|
||||||
import board
|
import board
|
||||||
from adafruit_bus_device.i2c_device import I2CDevice
|
from adafruit_bus_device.i2c_device import I2CDevice
|
||||||
|
|
||||||
DEVICE_ADDRESS = 0x68 # device address of DS3231 board
|
DEVICE_ADDRESS = 0x68 # device address of DS3231 board
|
||||||
A_DEVICE_REGISTER = 0x0E # device id register on the DS3231 board
|
A_DEVICE_REGISTER = 0x0E # device id register on the DS3231 board
|
||||||
|
|
||||||
# The follow is for I2C communications
|
# The follow is for I2C communications
|
||||||
comm_port = busio.I2C(board.SCL, board.SDA)
|
comm_port = busio.I2C(board.SCL, board.SDA)
|
||||||
|
|
@ -14,4 +14,4 @@ with device as bus_device:
|
||||||
result = bytearray(1)
|
result = bytearray(1)
|
||||||
bus_device.readinto(result)
|
bus_device.readinto(result)
|
||||||
|
|
||||||
print(''.join('{:02x}'.format(x) for x in result))
|
print("".join("{:02x}".format(x) for x in result))
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,18 @@ import board
|
||||||
import digitalio
|
import digitalio
|
||||||
from adafruit_bus_device.spi_device import SPIDevice
|
from adafruit_bus_device.spi_device import SPIDevice
|
||||||
|
|
||||||
DEVICE_ADDRESS = 0x68 # device address of BMP280 board
|
DEVICE_ADDRESS = 0x68 # device address of BMP280 board
|
||||||
A_DEVICE_REGISTER = 0xD0 # device id register on the BMP280 board
|
A_DEVICE_REGISTER = 0xD0 # device id register on the BMP280 board
|
||||||
|
|
||||||
# The follow is for SPI communications
|
# The follow is for SPI communications
|
||||||
cs = digitalio.DigitalInOut(board.A2)
|
cs = digitalio.DigitalInOut(board.A2)
|
||||||
comm_port = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
|
comm_port = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
|
||||||
device = SPIDevice(comm_port, cs)
|
device = SPIDevice(comm_port, cs)
|
||||||
|
|
||||||
#pylint: disable-msg=no-member
|
# pylint: disable-msg=no-member
|
||||||
with device as bus_device:
|
with device as bus_device:
|
||||||
bus_device.write(bytes([A_DEVICE_REGISTER]))
|
bus_device.write(bytes([A_DEVICE_REGISTER]))
|
||||||
result = bytearray(1)
|
result = bytearray(1)
|
||||||
bus_device.readinto(result)
|
bus_device.readinto(result)
|
||||||
|
|
||||||
print(''.join('{:02x}'.format(x) for x in result))
|
print("".join("{:02x}".format(x) for x in result))
|
||||||
|
|
|
||||||
50
setup.py
50
setup.py
|
|
@ -7,6 +7,7 @@ https://github.com/pypa/sampleproject
|
||||||
|
|
||||||
# Always prefer setuptools over distutils
|
# Always prefer setuptools over distutils
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
# To use a consistent encoding
|
# To use a consistent encoding
|
||||||
from codecs import open
|
from codecs import open
|
||||||
from os import path
|
from os import path
|
||||||
|
|
@ -14,47 +15,38 @@ from os import path
|
||||||
here = path.abspath(path.dirname(__file__))
|
here = path.abspath(path.dirname(__file__))
|
||||||
|
|
||||||
# Get the long description from the README file
|
# Get the long description from the README file
|
||||||
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
|
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
|
||||||
long_description = f.read()
|
long_description = f.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='adafruit-circuitpython-busdevice',
|
name="adafruit-circuitpython-busdevice",
|
||||||
|
|
||||||
use_scm_version=True,
|
use_scm_version=True,
|
||||||
setup_requires=['setuptools_scm'],
|
setup_requires=["setuptools_scm"],
|
||||||
|
description="CircuitPython bus device classes to manage bus sharing.",
|
||||||
description='CircuitPython bus device classes to manage bus sharing.',
|
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type='text/x-rst',
|
long_description_content_type="text/x-rst",
|
||||||
|
|
||||||
# The project's main homepage.
|
# The project's main homepage.
|
||||||
url='https://github.com/adafruit/Adafruit_CircuitPython_BusDevice',
|
url="https://github.com/adafruit/Adafruit_CircuitPython_BusDevice",
|
||||||
|
|
||||||
# Author details
|
# Author details
|
||||||
author='Adafruit Industries',
|
author="Adafruit Industries",
|
||||||
author_email='circuitpython@adafruit.com',
|
author_email="circuitpython@adafruit.com",
|
||||||
|
install_requires=["Adafruit-Blinka"],
|
||||||
install_requires=['Adafruit-Blinka'],
|
|
||||||
|
|
||||||
# Choose your license
|
# Choose your license
|
||||||
license='MIT',
|
license="MIT",
|
||||||
|
|
||||||
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 3 - Alpha',
|
"Development Status :: 3 - Alpha",
|
||||||
'Intended Audience :: Developers',
|
"Intended Audience :: Developers",
|
||||||
'Topic :: Software Development :: Libraries',
|
"Topic :: Software Development :: Libraries",
|
||||||
'Topic :: System :: Hardware',
|
"Topic :: System :: Hardware",
|
||||||
'License :: OSI Approved :: MIT License',
|
"License :: OSI Approved :: MIT License",
|
||||||
'Programming Language :: Python :: 3',
|
"Programming Language :: Python :: 3",
|
||||||
'Programming Language :: Python :: 3.4',
|
"Programming Language :: Python :: 3.4",
|
||||||
'Programming Language :: Python :: 3.5',
|
"Programming Language :: Python :: 3.5",
|
||||||
],
|
],
|
||||||
|
|
||||||
# What does your project relate to?
|
# What does your project relate to?
|
||||||
keywords='adafruit spi i2c bus device micropython circuitpython',
|
keywords="adafruit spi i2c bus device micropython circuitpython",
|
||||||
|
|
||||||
# You can just specify the packages manually here if your project is
|
# You can just specify the packages manually here if your project is
|
||||||
# simple. Or you can use find_packages().
|
# simple. Or you can use find_packages().
|
||||||
packages=['adafruit_bus_device'],
|
packages=["adafruit_bus_device"],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue