Ran black, updated to pylint 2.x
This commit is contained in:
parent
566dbbd8ab
commit
f334edadec
12 changed files with 183 additions and 162 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
|
@ -40,7 +40,7 @@ jobs:
|
||||||
source actions-ci/install.sh
|
source actions-ci/install.sh
|
||||||
- name: Pip install pylint, black, & Sphinx
|
- name: Pip install pylint, black, & Sphinx
|
||||||
run: |
|
run: |
|
||||||
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
|
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: PyLint
|
- name: PyLint
|
||||||
|
|
|
||||||
|
|
@ -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]
|
||||||
|
|
|
||||||
|
|
@ -28,18 +28,19 @@ CircuitPython driver for ADS1015 ADCs.
|
||||||
* Author(s): Carter Nelson
|
* Author(s): Carter Nelson
|
||||||
"""
|
"""
|
||||||
import struct
|
import struct
|
||||||
#pylint: disable=unused-import
|
|
||||||
|
# pylint: disable=unused-import
|
||||||
from .ads1x15 import ADS1x15, Mode
|
from .ads1x15 import ADS1x15, Mode
|
||||||
|
|
||||||
# Data sample rates
|
# Data sample rates
|
||||||
_ADS1015_CONFIG_DR = {
|
_ADS1015_CONFIG_DR = {
|
||||||
128: 0x0000,
|
128: 0x0000,
|
||||||
250: 0x0020,
|
250: 0x0020,
|
||||||
490: 0x0040,
|
490: 0x0040,
|
||||||
920: 0x0060,
|
920: 0x0060,
|
||||||
1600: 0x0080,
|
1600: 0x0080,
|
||||||
2400: 0x00A0,
|
2400: 0x00A0,
|
||||||
3300: 0x00C0
|
3300: 0x00C0,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pins
|
# Pins
|
||||||
|
|
@ -48,6 +49,7 @@ P1 = 1
|
||||||
P2 = 2
|
P2 = 2
|
||||||
P3 = 3
|
P3 = 3
|
||||||
|
|
||||||
|
|
||||||
class ADS1015(ADS1x15):
|
class ADS1015(ADS1x15):
|
||||||
"""Class for the ADS1015 12 bit ADC."""
|
"""Class for the ADS1015 12 bit ADC."""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,19 +28,20 @@ CircuitPython driver for 1115 ADCs.
|
||||||
* Author(s): Carter Nelson
|
* Author(s): Carter Nelson
|
||||||
"""
|
"""
|
||||||
import struct
|
import struct
|
||||||
#pylint: disable=unused-import
|
|
||||||
|
# pylint: disable=unused-import
|
||||||
from .ads1x15 import ADS1x15, Mode
|
from .ads1x15 import ADS1x15, Mode
|
||||||
|
|
||||||
# Data sample rates
|
# Data sample rates
|
||||||
_ADS1115_CONFIG_DR = {
|
_ADS1115_CONFIG_DR = {
|
||||||
8: 0x0000,
|
8: 0x0000,
|
||||||
16: 0x0020,
|
16: 0x0020,
|
||||||
32: 0x0040,
|
32: 0x0040,
|
||||||
64: 0x0060,
|
64: 0x0060,
|
||||||
128: 0x0080,
|
128: 0x0080,
|
||||||
250: 0x00A0,
|
250: 0x00A0,
|
||||||
475: 0x00C0,
|
475: 0x00C0,
|
||||||
860: 0x00E0
|
860: 0x00E0,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pins
|
# Pins
|
||||||
|
|
@ -49,6 +50,7 @@ P1 = 1
|
||||||
P2 = 2
|
P2 = 2
|
||||||
P3 = 3
|
P3 = 3
|
||||||
|
|
||||||
|
|
||||||
class ADS1115(ADS1x15):
|
class ADS1115(ADS1x15):
|
||||||
"""Class for the ADS1115 16 bit ADC."""
|
"""Class for the ADS1115 16 bit ADC."""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,37 +35,45 @@ from micropython import const
|
||||||
from adafruit_bus_device.i2c_device import I2CDevice
|
from adafruit_bus_device.i2c_device import I2CDevice
|
||||||
|
|
||||||
# pylint: disable=bad-whitespace
|
# pylint: disable=bad-whitespace
|
||||||
_ADS1X15_DEFAULT_ADDRESS = const(0x48)
|
_ADS1X15_DEFAULT_ADDRESS = const(0x48)
|
||||||
_ADS1X15_POINTER_CONVERSION = const(0x00)
|
_ADS1X15_POINTER_CONVERSION = const(0x00)
|
||||||
_ADS1X15_POINTER_CONFIG = const(0x01)
|
_ADS1X15_POINTER_CONFIG = const(0x01)
|
||||||
_ADS1X15_CONFIG_OS_SINGLE = const(0x8000)
|
_ADS1X15_CONFIG_OS_SINGLE = const(0x8000)
|
||||||
_ADS1X15_CONFIG_MUX_OFFSET = const(12)
|
_ADS1X15_CONFIG_MUX_OFFSET = const(12)
|
||||||
_ADS1X15_CONFIG_COMP_QUE_DISABLE = const(0x0003)
|
_ADS1X15_CONFIG_COMP_QUE_DISABLE = const(0x0003)
|
||||||
_ADS1X15_CONFIG_GAIN = {
|
_ADS1X15_CONFIG_GAIN = {
|
||||||
2/3: 0x0000,
|
2 / 3: 0x0000,
|
||||||
1: 0x0200,
|
1: 0x0200,
|
||||||
2: 0x0400,
|
2: 0x0400,
|
||||||
4: 0x0600,
|
4: 0x0600,
|
||||||
8: 0x0800,
|
8: 0x0800,
|
||||||
16: 0x0A00
|
16: 0x0A00,
|
||||||
}
|
}
|
||||||
# pylint: enable=bad-whitespace
|
# pylint: enable=bad-whitespace
|
||||||
|
|
||||||
|
|
||||||
class Mode:
|
class Mode:
|
||||||
"""An enum-like class representing possible ADC operating modes."""
|
"""An enum-like class representing possible ADC operating modes."""
|
||||||
|
|
||||||
# See datasheet "Operating Modes" section
|
# See datasheet "Operating Modes" section
|
||||||
# values here are masks for setting MODE bit in Config Register
|
# values here are masks for setting MODE bit in Config Register
|
||||||
#pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
CONTINUOUS = 0x0000
|
CONTINUOUS = 0x0000
|
||||||
SINGLE = 0x0100
|
SINGLE = 0x0100
|
||||||
|
|
||||||
|
|
||||||
class ADS1x15(object):
|
class ADS1x15:
|
||||||
"""Base functionality for ADS1x15 analog to digital converters."""
|
"""Base functionality for ADS1x15 analog to digital converters."""
|
||||||
|
|
||||||
def __init__(self, i2c, gain=1, data_rate=None, mode=Mode.SINGLE,
|
def __init__(
|
||||||
address=_ADS1X15_DEFAULT_ADDRESS):
|
self,
|
||||||
#pylint: disable=too-many-arguments
|
i2c,
|
||||||
|
gain=1,
|
||||||
|
data_rate=None,
|
||||||
|
mode=Mode.SINGLE,
|
||||||
|
address=_ADS1X15_DEFAULT_ADDRESS,
|
||||||
|
):
|
||||||
|
# pylint: disable=too-many-arguments
|
||||||
self._last_pin_read = None
|
self._last_pin_read = None
|
||||||
self.buf = bytearray(3)
|
self.buf = bytearray(3)
|
||||||
self._data_rate = self._gain = self._mode = None
|
self._data_rate = self._gain = self._mode = None
|
||||||
|
|
@ -89,12 +97,12 @@ class ADS1x15(object):
|
||||||
@property
|
@property
|
||||||
def rates(self):
|
def rates(self):
|
||||||
"""Possible data rate settings."""
|
"""Possible data rate settings."""
|
||||||
raise NotImplementedError('Subclass must implement rates property.')
|
raise NotImplementedError("Subclass must implement rates property.")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rate_config(self):
|
def rate_config(self):
|
||||||
"""Rate configuration masks."""
|
"""Rate configuration masks."""
|
||||||
raise NotImplementedError('Subclass must implement rate_config property.')
|
raise NotImplementedError("Subclass must implement rate_config property.")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gain(self):
|
def gain(self):
|
||||||
|
|
@ -122,7 +130,7 @@ class ADS1x15(object):
|
||||||
|
|
||||||
@mode.setter
|
@mode.setter
|
||||||
def mode(self, mode):
|
def mode(self, mode):
|
||||||
if mode != Mode.CONTINUOUS and mode != Mode.SINGLE:
|
if mode not in (Mode.CONTINUOUS, Mode.SINGLE):
|
||||||
raise ValueError("Unsupported mode.")
|
raise ValueError("Unsupported mode.")
|
||||||
self._mode = mode
|
self._mode = mode
|
||||||
|
|
||||||
|
|
@ -140,33 +148,32 @@ class ADS1x15(object):
|
||||||
"""Retrieve the default data rate for this ADC (in samples per second).
|
"""Retrieve the default data rate for this ADC (in samples per second).
|
||||||
Should be implemented by subclasses.
|
Should be implemented by subclasses.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError('Subclasses must implement _data_rate_default!')
|
raise NotImplementedError("Subclasses must implement _data_rate_default!")
|
||||||
|
|
||||||
def _conversion_value(self, raw_adc):
|
def _conversion_value(self, raw_adc):
|
||||||
"""Subclasses should override this function that takes the 16 raw ADC
|
"""Subclasses should override this function that takes the 16 raw ADC
|
||||||
values of a conversion result and returns a signed integer value.
|
values of a conversion result and returns a signed integer value.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError('Subclass must implement _conversion_value function!')
|
raise NotImplementedError("Subclass must implement _conversion_value function!")
|
||||||
|
|
||||||
def _read(self, pin):
|
def _read(self, pin):
|
||||||
"""Perform an ADC read. Returns the signed integer result of the read."""
|
"""Perform an ADC read. Returns the signed integer result of the read."""
|
||||||
if self.mode == Mode.CONTINUOUS and self._last_pin_read == pin:
|
if self.mode == Mode.CONTINUOUS and self._last_pin_read == pin:
|
||||||
return self._conversion_value(self.get_last_result(True))
|
return self._conversion_value(self.get_last_result(True))
|
||||||
else:
|
self._last_pin_read = pin
|
||||||
self._last_pin_read = pin
|
config = _ADS1X15_CONFIG_OS_SINGLE
|
||||||
config = _ADS1X15_CONFIG_OS_SINGLE
|
config |= (pin & 0x07) << _ADS1X15_CONFIG_MUX_OFFSET
|
||||||
config |= (pin & 0x07) << _ADS1X15_CONFIG_MUX_OFFSET
|
config |= _ADS1X15_CONFIG_GAIN[self.gain]
|
||||||
config |= _ADS1X15_CONFIG_GAIN[self.gain]
|
config |= self.mode
|
||||||
config |= self.mode
|
config |= self.rate_config[self.data_rate]
|
||||||
config |= self.rate_config[self.data_rate]
|
config |= _ADS1X15_CONFIG_COMP_QUE_DISABLE
|
||||||
config |= _ADS1X15_CONFIG_COMP_QUE_DISABLE
|
self._write_register(_ADS1X15_POINTER_CONFIG, config)
|
||||||
self._write_register(_ADS1X15_POINTER_CONFIG, config)
|
|
||||||
|
|
||||||
if self.mode == Mode.SINGLE:
|
if self.mode == Mode.SINGLE:
|
||||||
while not self._conversion_complete():
|
while not self._conversion_complete():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return self._conversion_value(self.get_last_result(False))
|
return self._conversion_value(self.get_last_result(False))
|
||||||
|
|
||||||
def _conversion_complete(self):
|
def _conversion_complete(self):
|
||||||
"""Return status of ADC conversion."""
|
"""Return status of ADC conversion."""
|
||||||
|
|
|
||||||
|
|
@ -29,23 +29,12 @@ differential ADC readings.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# pylint: disable=bad-whitespace
|
# pylint: disable=bad-whitespace
|
||||||
_ADS1X15_DIFF_CHANNELS = {
|
_ADS1X15_DIFF_CHANNELS = {(0, 1): 0, (0, 3): 1, (1, 3): 2, (2, 3): 3}
|
||||||
(0, 1): 0,
|
_ADS1X15_PGA_RANGE = {2 / 3: 6.144, 1: 4.096, 2: 2.048, 4: 1.024, 8: 0.512, 16: 0.256}
|
||||||
(0, 3): 1,
|
|
||||||
(1, 3): 2,
|
|
||||||
(2, 3): 3
|
|
||||||
}
|
|
||||||
_ADS1X15_PGA_RANGE = {
|
|
||||||
2/3: 6.144,
|
|
||||||
1: 4.096,
|
|
||||||
2: 2.048,
|
|
||||||
4: 1.024,
|
|
||||||
8: 0.512,
|
|
||||||
16: 0.256
|
|
||||||
}
|
|
||||||
# pylint: enable=bad-whitespace
|
# pylint: enable=bad-whitespace
|
||||||
|
|
||||||
class AnalogIn():
|
|
||||||
|
class AnalogIn:
|
||||||
"""AnalogIn Mock Implementation for ADC Reads."""
|
"""AnalogIn Mock Implementation for ADC Reads."""
|
||||||
|
|
||||||
def __init__(self, ads, positive_pin, negative_pin=None):
|
def __init__(self, ads, positive_pin, negative_pin=None):
|
||||||
|
|
@ -62,16 +51,20 @@ class AnalogIn():
|
||||||
if negative_pin is not None:
|
if negative_pin is not None:
|
||||||
pins = (self._pin_setting, self._negative_pin)
|
pins = (self._pin_setting, self._negative_pin)
|
||||||
if pins not in _ADS1X15_DIFF_CHANNELS:
|
if pins not in _ADS1X15_DIFF_CHANNELS:
|
||||||
raise ValueError("Differential channels must be one of: {}"
|
raise ValueError(
|
||||||
.format(list(_ADS1X15_DIFF_CHANNELS.keys())))
|
"Differential channels must be one of: {}".format(
|
||||||
|
list(_ADS1X15_DIFF_CHANNELS.keys())
|
||||||
|
)
|
||||||
|
)
|
||||||
self._pin_setting = _ADS1X15_DIFF_CHANNELS[pins]
|
self._pin_setting = _ADS1X15_DIFF_CHANNELS[pins]
|
||||||
self.is_differential = True
|
self.is_differential = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def value(self):
|
def value(self):
|
||||||
"""Returns the value of an ADC pin as an integer."""
|
"""Returns the value of an ADC pin as an integer."""
|
||||||
return self._ads.read(self._pin_setting,
|
return self._ads.read(
|
||||||
is_differential=self.is_differential) << (16 - self._ads.bits)
|
self._pin_setting, is_differential=self.is_differential
|
||||||
|
) << (16 - self._ads.bits)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def voltage(self):
|
def voltage(self):
|
||||||
|
|
|
||||||
118
docs/conf.py
118
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,34 +11,45 @@ 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",
|
||||||
]
|
]
|
||||||
|
|
||||||
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
|
intersphinx_mapping = {
|
||||||
|
"python": ("https://docs.python.org/3.4", None),
|
||||||
|
"BusDevice": (
|
||||||
|
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
"Register": (
|
||||||
|
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
|
||||||
|
}
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# 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_ADS1X15 Library'
|
project = u"Adafruit CIRCUITPYTHON_ADS1X15 Library"
|
||||||
copyright = u'2017 Carter Nelson'
|
copyright = u"2017 Carter Nelson"
|
||||||
author = u'Carter Nelson'
|
author = u"Carter Nelson"
|
||||||
|
|
||||||
# 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 = u"1.0"
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = u'1.0'
|
release = u"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.
|
||||||
|
|
@ -49,7 +61,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.
|
||||||
|
|
@ -61,7 +73,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
|
||||||
|
|
@ -75,59 +87,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 = 'AdafruitCIRCUITPYTHON_ADS1X15Librarydoc'
|
htmlhelp_basename = "AdafruitCIRCUITPYTHON_ADS1X15Librarydoc"
|
||||||
|
|
||||||
# -- 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, 'AdafruitCIRCUITPYTHON_ADS1X15Library.tex', u'Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation',
|
(
|
||||||
author, 'manual'),
|
master_doc,
|
||||||
|
"AdafruitCIRCUITPYTHON_ADS1X15Library.tex",
|
||||||
|
u"Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation",
|
||||||
|
author,
|
||||||
|
"manual",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
# -- Options for manual page output ---------------------------------------
|
# -- Options for manual page output ---------------------------------------
|
||||||
|
|
@ -135,8 +150,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, 'adafruitCIRCUITPYTHON_ADS1X15library', u'Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation',
|
(
|
||||||
[author], 1)
|
master_doc,
|
||||||
|
"adafruitCIRCUITPYTHON_ADS1X15library",
|
||||||
|
u"Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation",
|
||||||
|
[author],
|
||||||
|
1,
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
# -- Options for Texinfo output -------------------------------------------
|
# -- Options for Texinfo output -------------------------------------------
|
||||||
|
|
@ -145,7 +165,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, 'AdafruitCIRCUITPYTHON_ADS1X15Library', u'Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation',
|
(
|
||||||
author, 'AdafruitCIRCUITPYTHON_ADS1X15Library', 'One line description of project.',
|
master_doc,
|
||||||
'Miscellaneous'),
|
"AdafruitCIRCUITPYTHON_ADS1X15Library",
|
||||||
|
u"Adafruit CIRCUITPYTHON_ADS1X15 Library Documentation",
|
||||||
|
author,
|
||||||
|
"AdafruitCIRCUITPYTHON_ADS1X15Library",
|
||||||
|
"One line description of project.",
|
||||||
|
"Miscellaneous",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -10,15 +10,15 @@ i2c = busio.I2C(board.SCL, board.SDA)
|
||||||
# Create the ADC object using the I2C bus
|
# Create the ADC object using the I2C bus
|
||||||
ads = ADS.ADS1115(i2c)
|
ads = ADS.ADS1115(i2c)
|
||||||
# you can specify an I2C adress instead of the default 0x48
|
# you can specify an I2C adress instead of the default 0x48
|
||||||
#ads = ADS.ADS1115(i2c, address=0x49)
|
# ads = ADS.ADS1115(i2c, address=0x49)
|
||||||
|
|
||||||
# Create single-ended input on channel 0
|
# Create single-ended input on channel 0
|
||||||
chan = AnalogIn(ads, ADS.P0)
|
chan = AnalogIn(ads, ADS.P0)
|
||||||
|
|
||||||
# Create differential input between channel 0 and 1
|
# Create differential input between channel 0 and 1
|
||||||
#chan = AnalogIn(ads, ADS.P0, ADS.P1)
|
# chan = AnalogIn(ads, ADS.P0, ADS.P1)
|
||||||
|
|
||||||
print("{:>5}\t{:>5}".format('raw', 'v'))
|
print("{:>5}\t{:>5}".format("raw", "v"))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
|
print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ chan0 = AnalogIn(ads, ADS.P0)
|
||||||
ads.mode = Mode.CONTINUOUS
|
ads.mode = Mode.CONTINUOUS
|
||||||
ads.data_rate = RATE
|
ads.data_rate = RATE
|
||||||
|
|
||||||
data = [None]*SAMPLES
|
data = [None] * SAMPLES
|
||||||
|
|
||||||
start = time.monotonic()
|
start = time.monotonic()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import time
|
import time
|
||||||
import board
|
import board
|
||||||
import busio
|
import busio
|
||||||
#import adafruit_ads1x15.ads1015 as ADS
|
|
||||||
|
# import adafruit_ads1x15.ads1015 as ADS
|
||||||
import adafruit_ads1x15.ads1115 as ADS
|
import adafruit_ads1x15.ads1115 as ADS
|
||||||
from adafruit_ads1x15.analog_in import AnalogIn
|
from adafruit_ads1x15.analog_in import AnalogIn
|
||||||
|
|
||||||
|
|
@ -9,7 +10,7 @@ from adafruit_ads1x15.analog_in import AnalogIn
|
||||||
i2c = busio.I2C(board.SCL, board.SDA)
|
i2c = busio.I2C(board.SCL, board.SDA)
|
||||||
|
|
||||||
# Create the ADS object
|
# Create the ADS object
|
||||||
#ads = ADS.ADS1015(i2c)
|
# ads = ADS.ADS1015(i2c)
|
||||||
ads = ADS.ADS1115(i2c)
|
ads = ADS.ADS1115(i2c)
|
||||||
|
|
||||||
# Create a sinlge ended channel on Pin 0
|
# Create a sinlge ended channel on Pin 0
|
||||||
|
|
@ -28,13 +29,13 @@ chan = AnalogIn(ads, ADS.P0)
|
||||||
# 8 +/- 0.512
|
# 8 +/- 0.512
|
||||||
# 16 +/- 0.256
|
# 16 +/- 0.256
|
||||||
#
|
#
|
||||||
gains = (2/3, 1, 2, 4, 8, 16)
|
gains = (2 / 3, 1, 2, 4, 8, 16)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
ads.gain = gains[0]
|
ads.gain = gains[0]
|
||||||
print('{:5} {:5.3f}'.format(chan.value, chan.voltage), end='')
|
print("{:5} {:5.3f}".format(chan.value, chan.voltage), end="")
|
||||||
for gain in gains[1:]:
|
for gain in gains[1:]:
|
||||||
ads.gain = gain
|
ads.gain = gain
|
||||||
print(' | {:5} {:5.3f}'.format(chan.value, chan.voltage), end='')
|
print(" | {:5} {:5.3f}".format(chan.value, chan.voltage), end="")
|
||||||
print()
|
print()
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ ads = ADS.ADS1015(i2c)
|
||||||
chan = AnalogIn(ads, ADS.P0)
|
chan = AnalogIn(ads, ADS.P0)
|
||||||
|
|
||||||
# Create differential input between channel 0 and 1
|
# Create differential input between channel 0 and 1
|
||||||
#chan = AnalogIn(ads, ADS.P0, ADS.P1)
|
# chan = AnalogIn(ads, ADS.P0, ADS.P1)
|
||||||
|
|
||||||
print("{:>5}\t{:>5}".format('raw', 'v'))
|
print("{:>5}\t{:>5}".format("raw", "v"))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
|
print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
|
||||||
|
|
|
||||||
53
setup.py
53
setup.py
|
|
@ -6,6 +6,7 @@ https://github.com/pypa/sampleproject
|
||||||
"""
|
"""
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -13,50 +14,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-ads1x15',
|
name="adafruit-circuitpython-ads1x15",
|
||||||
|
|
||||||
use_scm_version=True,
|
use_scm_version=True,
|
||||||
setup_requires=['setuptools_scm'],
|
setup_requires=["setuptools_scm"],
|
||||||
|
description="CircuitPython library for controlling an ADS1x15 ADC.",
|
||||||
description='CircuitPython library for controlling an ADS1x15 ADC.',
|
|
||||||
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_ADS1x15',
|
url="https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15",
|
||||||
|
|
||||||
# Author details
|
# Author details
|
||||||
author='Adafruit Industries',
|
author="Adafruit Industries",
|
||||||
author_email='circuitpython@adafruit.com',
|
author_email="circuitpython@adafruit.com",
|
||||||
|
install_requires=["Adafruit-Blinka", "adafruit-circuitpython-busdevice"],
|
||||||
install_requires=[
|
|
||||||
'Adafruit-Blinka',
|
|
||||||
'adafruit-circuitpython-busdevice'
|
|
||||||
],
|
|
||||||
|
|
||||||
# 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 ads1x115 adc hardware micropython circuitpython',
|
keywords="adafruit ads1x115 adc hardware 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_ads1x15'],
|
packages=["adafruit_ads1x15"],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue