Merge pull request #25 from adafruit/pylint-update
Ran black, updated to pylint 2.x
This commit is contained in:
commit
89dbe60bae
7 changed files with 141 additions and 116 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
|
@ -40,7 +40,7 @@ jobs:
|
|||
source actions-ci/install.sh
|
||||
- name: Pip install pylint, black, & Sphinx
|
||||
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
|
||||
run: git describe --dirty --always --tags
|
||||
- name: PyLint
|
||||
|
|
|
|||
|
|
@ -119,7 +119,8 @@ spelling-store-unknown-words=no
|
|||
[MISCELLANEOUS]
|
||||
|
||||
# List of note tags to take in consideration, separated by a comma.
|
||||
notes=FIXME,XXX,TODO
|
||||
# notes=FIXME,XXX,TODO
|
||||
notes=FIXME,XXX
|
||||
|
||||
|
||||
[TYPECHECK]
|
||||
|
|
|
|||
|
|
@ -54,48 +54,51 @@ from micropython import const
|
|||
# Operating Modes
|
||||
# pylint: disable=bad-whitespace
|
||||
_NORMAL_MODE = const(0x00)
|
||||
_SLEEP_MODE = const(0x10)
|
||||
_SLEEP_MODE = const(0x10)
|
||||
_STAND_BY_60 = const(0x20)
|
||||
_STAND_BY_10 = const(0x21)
|
||||
|
||||
# sw resets
|
||||
_FLAG_RESET = const(0x30)
|
||||
_FLAG_RESET = const(0x30)
|
||||
_INITIAL_RESET = const(0x3F)
|
||||
|
||||
# frame rates
|
||||
_FPS_10 = const(0x00)
|
||||
_FPS_1 = const(0x01)
|
||||
_FPS_1 = const(0x01)
|
||||
|
||||
# int enables
|
||||
_INT_DISABLED = const(0x00)
|
||||
_INT_ENABLED = const(0x01)
|
||||
_INT_ENABLED = const(0x01)
|
||||
|
||||
# int modes
|
||||
_DIFFERENCE = const(0x00)
|
||||
_DIFFERENCE = const(0x00)
|
||||
_ABSOLUTE_VALUE = const(0x01)
|
||||
|
||||
_INT_OFFSET = const(0x010)
|
||||
_INT_OFFSET = const(0x010)
|
||||
_PIXEL_OFFSET = const(0x80)
|
||||
|
||||
_PIXEL_ARRAY_WIDTH = const(8)
|
||||
_PIXEL_ARRAY_HEIGHT = const(8)
|
||||
_PIXEL_TEMP_CONVERSION = .25
|
||||
_THERMISTOR_CONVERSION = .0625
|
||||
_PIXEL_TEMP_CONVERSION = 0.25
|
||||
_THERMISTOR_CONVERSION = 0.0625
|
||||
# pylint: enable=bad-whitespace
|
||||
|
||||
|
||||
def _signed_12bit_to_float(val):
|
||||
#take first 11 bits as absolute val
|
||||
abs_val = (val & 0x7FF)
|
||||
# take first 11 bits as absolute val
|
||||
abs_val = val & 0x7FF
|
||||
if val & 0x800:
|
||||
return 0 - float(abs_val)
|
||||
return float(abs_val)
|
||||
|
||||
|
||||
def _twos_comp_to_float(val):
|
||||
val &= 0xfff
|
||||
val &= 0xFFF
|
||||
if val & 0x800:
|
||||
val -= 0x1000
|
||||
return float(val)
|
||||
|
||||
|
||||
class AMG88XX:
|
||||
"""Driver for the AMG88xx GRID-Eye IR 8x8 thermal camera."""
|
||||
|
||||
|
|
@ -130,16 +133,16 @@ class AMG88XX:
|
|||
def __init__(self, i2c, addr=0x69):
|
||||
self.i2c_device = I2CDevice(i2c, addr)
|
||||
|
||||
#enter normal mode
|
||||
# enter normal mode
|
||||
self._pctl = _NORMAL_MODE
|
||||
|
||||
#software reset
|
||||
# software reset
|
||||
self._rst = _INITIAL_RESET
|
||||
|
||||
#disable interrupts by default
|
||||
# disable interrupts by default
|
||||
self._inten = False
|
||||
|
||||
#set to 10 FPS
|
||||
# set to 10 FPS
|
||||
self._fps = _FPS_10
|
||||
|
||||
@property
|
||||
|
|
@ -155,7 +158,7 @@ class AMG88XX:
|
|||
Temperatures are stored in a two dimensional list where the first index is the row and
|
||||
the second is the column. The first row is on the side closest to the writing on the
|
||||
sensor."""
|
||||
retbuf = [[0]*_PIXEL_ARRAY_WIDTH for _ in range(_PIXEL_ARRAY_HEIGHT)]
|
||||
retbuf = [[0] * _PIXEL_ARRAY_WIDTH for _ in range(_PIXEL_ARRAY_HEIGHT)]
|
||||
buf = bytearray(3)
|
||||
|
||||
with self.i2c_device as i2c:
|
||||
|
|
|
|||
109
docs/conf.py
109
docs/conf.py
|
|
@ -18,7 +18,8 @@
|
|||
#
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath('..'))
|
||||
|
||||
sys.path.insert(0, os.path.abspath(".."))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
|
|
@ -30,9 +31,9 @@ sys.path.insert(0, os.path.abspath('..'))
|
|||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.viewcode',
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.intersphinx",
|
||||
"sphinx.ext.viewcode",
|
||||
]
|
||||
|
||||
# Uncomment the below if you use native CircuitPython modules such as
|
||||
|
|
@ -41,34 +42,34 @@ extensions = [
|
|||
# autodoc_mock_imports = ["adafruit_bus_device", "micropython", "adafruit_register"]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Adafruit AMG88xx Library'
|
||||
copyright = u'2017, Dean Miller for Adafruit Industries'
|
||||
author = u'Dean Miller'
|
||||
project = u"Adafruit AMG88xx Library"
|
||||
copyright = u"2017, Dean Miller for Adafruit Industries"
|
||||
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 = u'1.0'
|
||||
version = u"1.0"
|
||||
# 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
|
||||
# for a list of supported languages.
|
||||
|
|
@ -89,7 +90,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.
|
||||
|
|
@ -111,7 +112,7 @@ default_role = "any"
|
|||
# show_authors = False
|
||||
|
||||
# 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
|
||||
|
|
@ -134,18 +135,19 @@ todo_include_todos = False
|
|||
# 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 = ["."]
|
||||
|
||||
# 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
|
||||
|
|
@ -179,7 +181,7 @@ else:
|
|||
# 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"]
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
|
|
@ -259,34 +261,36 @@ html_static_path = ['_static']
|
|||
# html_search_scorer = 'scorer.js'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'AdafruitAMG88xxLibrarydoc'
|
||||
htmlhelp_basename = "AdafruitAMG88xxLibrarydoc"
|
||||
|
||||
# -- 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, 'AdafruitAMG88xxLibrary.tex', u'Adafruit AMG88xx Library Documentation',
|
||||
u'Dean Miller', 'manual'),
|
||||
(
|
||||
master_doc,
|
||||
"AdafruitAMG88xxLibrary.tex",
|
||||
u"Adafruit AMG88xx Library Documentation",
|
||||
u"Dean Miller",
|
||||
"manual",
|
||||
),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
|
@ -327,8 +331,13 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'adafruitAMG88xxLibrary', u'Adafruit AMG88xx Library Documentation',
|
||||
[author], 1)
|
||||
(
|
||||
master_doc,
|
||||
"adafruitAMG88xxLibrary",
|
||||
u"Adafruit AMG88xx Library Documentation",
|
||||
[author],
|
||||
1,
|
||||
)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
|
@ -342,9 +351,15 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'AdafruitAMG88xxLibrary', u'Adafruit AMG88xx Library Documentation',
|
||||
author, 'AdafruitAMG88xxLibrary', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
master_doc,
|
||||
"AdafruitAMG88xxLibrary",
|
||||
u"Adafruit AMG88xx Library Documentation",
|
||||
author,
|
||||
"AdafruitAMG88xxLibrary",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
|
|
@ -363,5 +378,7 @@ texinfo_documents = [
|
|||
#
|
||||
# texinfo_no_detailmenu = False
|
||||
|
||||
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),
|
||||
'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
|
||||
intersphinx_mapping = {
|
||||
"python": ("https://docs.python.org/3.4", None),
|
||||
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,19 +18,19 @@ import adafruit_amg88xx
|
|||
|
||||
i2c_bus = busio.I2C(board.SCL, board.SDA)
|
||||
|
||||
#low range of the sensor (this will be blue on the screen)
|
||||
MINTEMP = 26.
|
||||
# low range of the sensor (this will be blue on the screen)
|
||||
MINTEMP = 26.0
|
||||
|
||||
#high range of the sensor (this will be red on the screen)
|
||||
MAXTEMP = 32.
|
||||
# high range of the sensor (this will be red on the screen)
|
||||
MAXTEMP = 32.0
|
||||
|
||||
#how many color values we can have
|
||||
# how many color values we can have
|
||||
COLORDEPTH = 1024
|
||||
|
||||
os.putenv('SDL_FBDEV', '/dev/fb1')
|
||||
os.putenv("SDL_FBDEV", "/dev/fb1")
|
||||
pygame.init()
|
||||
|
||||
#initialize the sensor
|
||||
# initialize the sensor
|
||||
sensor = adafruit_amg88xx.AMG88XX(i2c_bus)
|
||||
|
||||
# pylint: disable=invalid-slice-index
|
||||
|
|
@ -38,15 +38,15 @@ points = [(math.floor(ix / 8), (ix % 8)) for ix in range(0, 64)]
|
|||
grid_x, grid_y = np.mgrid[0:7:32j, 0:7:32j]
|
||||
# pylint: enable=invalid-slice-index
|
||||
|
||||
#sensor is an 8x8 grid so lets do a square
|
||||
# sensor is an 8x8 grid so lets do a square
|
||||
height = 240
|
||||
width = 240
|
||||
|
||||
#the list of colors we can choose from
|
||||
# the list of colors we can choose from
|
||||
blue = Color("indigo")
|
||||
colors = list(blue.range_to(Color("red"), COLORDEPTH))
|
||||
|
||||
#create the array of colors
|
||||
# create the array of colors
|
||||
colors = [(int(c.red * 255), int(c.green * 255), int(c.blue * 255)) for c in colors]
|
||||
|
||||
displayPixelWidth = width / 30
|
||||
|
|
@ -62,32 +62,41 @@ pygame.mouse.set_visible(False)
|
|||
lcd.fill((0, 0, 0))
|
||||
pygame.display.update()
|
||||
|
||||
#some utility functions
|
||||
# some utility functions
|
||||
def constrain(val, min_val, max_val):
|
||||
return min(max_val, max(min_val, val))
|
||||
|
||||
|
||||
def map_value(x, in_min, in_max, out_min, out_max):
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
|
||||
|
||||
#let the sensor initialize
|
||||
time.sleep(.1)
|
||||
|
||||
# let the sensor initialize
|
||||
time.sleep(0.1)
|
||||
|
||||
while True:
|
||||
|
||||
#read the pixels
|
||||
# read the pixels
|
||||
pixels = []
|
||||
for row in sensor.pixels:
|
||||
pixels = pixels + row
|
||||
pixels = [map_value(p, MINTEMP, MAXTEMP, 0, COLORDEPTH - 1) for p in pixels]
|
||||
|
||||
#perform interpolation
|
||||
bicubic = griddata(points, pixels, (grid_x, grid_y), method='cubic')
|
||||
# perform interpolation
|
||||
bicubic = griddata(points, pixels, (grid_x, grid_y), method="cubic")
|
||||
|
||||
#draw everything
|
||||
# draw everything
|
||||
for ix, row in enumerate(bicubic):
|
||||
for jx, pixel in enumerate(row):
|
||||
pygame.draw.rect(lcd, colors[constrain(int(pixel), 0, COLORDEPTH- 1)],
|
||||
(displayPixelHeight * ix, displayPixelWidth * jx,
|
||||
displayPixelHeight, displayPixelWidth))
|
||||
pygame.draw.rect(
|
||||
lcd,
|
||||
colors[constrain(int(pixel), 0, COLORDEPTH - 1)],
|
||||
(
|
||||
displayPixelHeight * ix,
|
||||
displayPixelWidth * jx,
|
||||
displayPixelHeight,
|
||||
displayPixelWidth,
|
||||
),
|
||||
)
|
||||
|
||||
pygame.display.update()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ amg = adafruit_amg88xx.AMG88XX(i2c)
|
|||
while True:
|
||||
for row in amg.pixels:
|
||||
# Pad to 1 decimal place
|
||||
print(['{0:.1f}'.format(temp) for temp in row])
|
||||
print(["{0:.1f}".format(temp) for temp in row])
|
||||
print("")
|
||||
print("\n")
|
||||
time.sleep(1)
|
||||
|
|
|
|||
57
setup.py
57
setup.py
|
|
@ -7,6 +7,7 @@ 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
|
||||
|
|
@ -14,48 +15,42 @@ 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:
|
||||
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
|
||||
long_description = f.read()
|
||||
|
||||
setup(
|
||||
name='adafruit-circuitpython-amg88xx',
|
||||
|
||||
name="adafruit-circuitpython-amg88xx",
|
||||
use_scm_version=True,
|
||||
setup_requires=['setuptools_scm'],
|
||||
|
||||
description='CircuitPython library for AMG88xx thermal camera.',
|
||||
setup_requires=["setuptools_scm"],
|
||||
description="CircuitPython library for AMG88xx thermal camera.",
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/x-rst',
|
||||
|
||||
long_description_content_type="text/x-rst",
|
||||
# The project's main homepage.
|
||||
url='https://github.com/adafruit/Adafruit_CircuitPython_AMG88xx',
|
||||
|
||||
url="https://github.com/adafruit/Adafruit_CircuitPython_AMG88xx",
|
||||
# Author details
|
||||
author='Adafruit Industries',
|
||||
author_email='circuitpython@adafruit.com',
|
||||
|
||||
install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-register',
|
||||
'adafruit-circuitpython-busdevice'],
|
||||
|
||||
author="Adafruit Industries",
|
||||
author_email="circuitpython@adafruit.com",
|
||||
install_requires=[
|
||||
"Adafruit-Blinka",
|
||||
"adafruit-circuitpython-register",
|
||||
"adafruit-circuitpython-busdevice",
|
||||
],
|
||||
# Choose your license
|
||||
license='MIT',
|
||||
|
||||
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',
|
||||
"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 thermal camera featherwing temperature breakout hardware micropython circuitpython',
|
||||
|
||||
keywords="adafruit thermal camera featherwing temperature breakout 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_amg88xx'],
|
||||
)
|
||||
py_modules=["adafruit_amg88xx"],
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue