Skip to content

Ran black, updated to pylint 2.x #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 20 additions & 17 deletions adafruit_max7219/bcddigits.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
_SHUTDOWN = const(12)
_DISPLAYTEST = const(15)


class BCDDigits(max7219.MAX7219):
"""
Basic support for display on a 7-Segment BCD display controlled
Expand All @@ -45,18 +46,20 @@ class BCDDigits(max7219.MAX7219):
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
:param int nDigits: number of led 7-segment digits; default 1; max 8
"""

def __init__(self, spi, cs, nDigits=1):
self._ndigits = nDigits
super().__init__(self._ndigits, 8, spi, cs)

def init_display(self):

for cmd, data in ((_SHUTDOWN, 0),
(_DISPLAYTEST, 0),
(_SCANLIMIT, 7),
(_DECODEMODE, (2**self._ndigits)-1),
(_SHUTDOWN, 1),
):
for cmd, data in (
(_SHUTDOWN, 0),
(_DISPLAYTEST, 0),
(_SCANLIMIT, 7),
(_DECODEMODE, (2 ** self._ndigits) - 1),
(_SHUTDOWN, 1),
):
self.write_cmd(cmd, data)

self.clear_all()
Expand All @@ -71,7 +74,7 @@ def set_digit(self, dpos, value):
"""
dpos = self._ndigits - dpos - 1
for i in range(4):
#print('digit {} pixel {} value {}'.format(dpos,i+4,v & 0x01))
# print('digit {} pixel {} value {}'.format(dpos,i+4,v & 0x01))
self.pixel(dpos, i, value & 0x01)
value >>= 1

Expand All @@ -83,7 +86,7 @@ def set_digits(self, start, values):
:param list ds: list of integer values ranging from 0->15
"""
for value in values:
#print('set digit {} start {}'.format(d,start))
# print('set digit {} start {}'.format(d,start))
self.set_digit(start, value)
start += 1

Expand All @@ -94,9 +97,9 @@ def show_dot(self, dpos, bit_value=None):
:param int dpos: the digit to set the decimal point zero-based
:param int value: value > zero lights the decimal point, else unlights the point
"""
if dpos < self._ndigits and dpos >= 0:
#print('set dot {} = {}'.format((self._ndigits - d -1),col))
self.pixel(self._ndigits-dpos-1, 7, bit_value)
if 0 <= dpos < self._ndigits:
# print('set dot {} = {}'.format((self._ndigits - d -1),col))
self.pixel(self._ndigits - dpos - 1, 7, bit_value)

def clear_all(self):
"""
Expand All @@ -116,13 +119,13 @@ def show_str(self, start, strg):
cpos = start
for char in strg:
# print('c {}'.format(c))
value = 0x0f # assume blank
if char >= '0' and char <= '9':
value = 0x0F # assume blank
if "0" <= char <= "9":
value = int(char)
elif char == '-':
value = 10 # minus sign
elif char == '.':
self.show_dot(cpos-1, 1)
elif char == "-":
value = 10 # minus sign
elif char == ".":
self.show_dot(cpos - 1, 1)
continue
self.set_digit(cpos, value)
cpos += 1
Expand Down
15 changes: 9 additions & 6 deletions adafruit_max7219/matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,26 @@
_SHUTDOWN = const(12)
_DISPLAYTEST = const(15)


class Matrix8x8(max7219.MAX7219):
"""
Driver for a 8x8 LED matrix based on the MAX7219 chip.

:param object spi: an spi busio or spi bitbangio object
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
"""

def __init__(self, spi, cs):
super().__init__(8, 8, spi, cs)

def init_display(self):
for cmd, data in ((_SHUTDOWN, 0),
(_DISPLAYTEST, 0),
(_SCANLIMIT, 7),
(_DECODEMODE, 0),
(_SHUTDOWN, 1),
):
for cmd, data in (
(_SHUTDOWN, 0),
(_DISPLAYTEST, 0),
(_SCANLIMIT, 7),
(_DECODEMODE, 0),
(_SHUTDOWN, 1),
):
self.write_cmd(cmd, data)

self.fill(0)
Expand Down
14 changes: 8 additions & 6 deletions adafruit_max7219/max7219.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ class MAX7219:
:param polarity: for SPIDevice polarity (default 0)
:param phase: for SPIDevice phase (default 0)
"""
def __init__(self, width, height, spi, cs, *,
baudrate=8000000, polarity=0, phase=0):

def __init__(
self, width, height, spi, cs, *, baudrate=8000000, polarity=0, phase=0
):

self._chip_select = cs
self._chip_select.direction = digitalio.Direction.OUTPUT

self._spi_device = spi_device.SPIDevice(spi, cs, baudrate=baudrate,
polarity=polarity, phase=phase)
self._spi_device = spi_device.SPIDevice(
spi, cs, baudrate=baudrate, polarity=polarity, phase=phase
)

self._buffer = bytearray((height // 8) * width)
self.framebuf = framebuf.FrameBuffer1(self._buffer, width, height)
Expand All @@ -98,7 +101,6 @@ def __init__(self, width, height, spi, cs, *,

def init_display(self):
"""Must be implemented by derived class (``matrices``, ``bcddigits``)"""
pass

def brightness(self, value):
"""
Expand Down Expand Up @@ -143,7 +145,7 @@ def scroll(self, delta_x, delta_y):
def write_cmd(self, cmd, data):
# pylint: disable=no-member
"""Writes a command to spi device."""
#print('cmd {} data {}'.format(cmd,data))
# print('cmd {} data {}'.format(cmd,data))
self._chip_select.value = False
with self._spi_device as my_spi_device:
my_spi_device.write(bytearray([cmd, data]))
114 changes: 68 additions & 46 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,55 @@

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))

# -- General configuration ------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# 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
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
autodoc_mock_imports = ["framebuf"]

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)}
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.
templates_path = ['_templates']
templates_path = ["_templates"]

source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'Adafruit MAX7219 Library'
copyright = u'2017, Adafruit CiruitPython and Bundle contributors'
author = u'Michael McWethy'
project = u"Adafruit MAX7219 Library"
copyright = u"2017, Adafruit CiruitPython and Bundle contributors"
author = u"Michael McWethy"

# 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.
Expand All @@ -54,7 +62,7 @@
# 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.
Expand All @@ -66,7 +74,7 @@
add_function_parentheses = True

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -80,68 +88,76 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
on_rtd = os.environ.get("READTHEDOCS", None) == "True"

if not on_rtd: # only import and set the theme if we're building docs locally
try:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']

html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
except:
html_theme = 'default'
html_theme_path = ['.']
html_theme = "default"
html_theme_path = ["."]
else:
html_theme_path = ['.']
html_theme_path = ["."]

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#
html_favicon = '_static/favicon.ico'
html_favicon = "_static/favicon.ico"

# Output file base name for HTML help builder.
htmlhelp_basename = 'AdafruitMAX7219Librarydoc'
htmlhelp_basename = "AdafruitMAX7219Librarydoc"

# -- 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, 'AdafruitMAX7219Library.tex', u'Adafruit MAX7219 Library Documentation',
author, 'manual'),
(
master_doc,
"AdafruitMAX7219Library.tex",
u"Adafruit MAX7219 Library Documentation",
author,
"manual",
),
]

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'adafruitMAX7219library', u'Adafruit MAX7219 Library Documentation',
[author], 1)
(
master_doc,
"adafruitMAX7219library",
u"Adafruit MAX7219 Library Documentation",
[author],
1,
)
]

# -- Options for Texinfo output -------------------------------------------
Expand All @@ -150,7 +166,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'AdafruitMAX7219Library', u'Adafruit MAX7219 Library Documentation',
author, 'AdafruitMAX7219Library', 'Python driver classes for MAX7219 chip',
'Miscellaneous'),
(
master_doc,
"AdafruitMAX7219Library",
u"Adafruit MAX7219 Library Documentation",
author,
"AdafruitMAX7219Library",
"Python driver classes for MAX7219 chip",
"Miscellaneous",
),
]
Loading