Skip to content

Commit 0380e97

Browse files
authored
Merge pull request #11 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 1f10736 + 367f848 commit 0380e97

File tree

6 files changed

+126
-104
lines changed

6 files changed

+126
-104
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
source actions-ci/install.sh
4141
- name: Pip install pylint, black, & Sphinx
4242
run: |
43-
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
43+
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

adafruit_sharpmemorydisplay.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,22 @@
5656
_SHARPMEM_BIT_VCOM = const(0x40) # in lsb
5757
_SHARPMEM_BIT_CLEAR = const(0x20) # in lsb
5858

59+
5960
def reverse_bit(num):
6061
"""Turn an LSB byte to an MSB byte, and vice versa. Used for SPI as
6162
it is LSB for the SHARP, but 99% of SPI implementations are MSB only!"""
6263
result = 0
6364
for _ in range(8):
6465
result <<= 1
65-
result += (num & 1)
66+
result += num & 1
6667
num >>= 1
6768
return result
6869

6970

7071
class SharpMemoryDisplay(adafruit_framebuf.FrameBuffer):
7172
"""A driver for sharp memory displays, you can use any size but the
7273
full display must be buffered in memory!"""
74+
7375
# pylint: disable=too-many-instance-attributes,abstract-method
7476

7577
def __init__(self, spi, scs_pin, width, height, *, baudrate=8000000):
@@ -108,11 +110,11 @@ def show(self):
108110
self._spi.write(self._buf)
109111

110112
slice_from = 0
111-
line_len = self.width//8
113+
line_len = self.width // 8
112114
for line in range(self.height):
113-
self._buf[0] = reverse_bit(line+1)
115+
self._buf[0] = reverse_bit(line + 1)
114116
self._spi.write(self._buf)
115-
self._spi.write(memoryview(self.buffer[slice_from:slice_from+line_len]))
117+
self._spi.write(memoryview(self.buffer[slice_from : slice_from + line_len]))
116118
slice_from += line_len
117119
self._buf[0] = 0
118120
self._spi.write(self._buf)

docs/conf.py

+65-47
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
import os
44
import sys
5-
sys.path.insert(0, os.path.abspath('..'))
5+
6+
sys.path.insert(0, os.path.abspath(".."))
67

78
# -- General configuration ------------------------------------------------
89

910
# Add any Sphinx extension module names here, as strings. They can be
1011
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
1112
# ones.
1213
extensions = [
13-
'sphinx.ext.autodoc',
14-
'sphinx.ext.intersphinx',
15-
'sphinx.ext.napoleon',
16-
'sphinx.ext.todo',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
16+
"sphinx.ext.napoleon",
17+
"sphinx.ext.todo",
1718
]
1819

1920
# TODO: Please Read!
@@ -23,29 +24,32 @@
2324
# autodoc_mock_imports = ["digitalio", "busio"]
2425

2526

26-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
27+
intersphinx_mapping = {
28+
"python": ("https://docs.python.org/3.4", None),
29+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
30+
}
2731

2832
# Add any paths that contain templates here, relative to this directory.
29-
templates_path = ['_templates']
33+
templates_path = ["_templates"]
3034

31-
source_suffix = '.rst'
35+
source_suffix = ".rst"
3236

3337
# The master toctree document.
34-
master_doc = 'index'
38+
master_doc = "index"
3539

3640
# General information about the project.
37-
project = u'Adafruit SHARPMemoryDisplay Library'
38-
copyright = u'2018 ladyada'
39-
author = u'ladyada'
41+
project = u"Adafruit SHARPMemoryDisplay Library"
42+
copyright = u"2018 ladyada"
43+
author = u"ladyada"
4044

4145
# The version info for the project you're documenting, acts as replacement for
4246
# |version| and |release|, also used in various other places throughout the
4347
# built documents.
4448
#
4549
# The short X.Y version.
46-
version = u'1.0'
50+
version = u"1.0"
4751
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
52+
release = u"1.0"
4953

5054
# The language for content autogenerated by Sphinx. Refer to documentation
5155
# for a list of supported languages.
@@ -57,7 +61,7 @@
5761
# List of patterns, relative to source directory, that match files and
5862
# directories to ignore when looking for source files.
5963
# This patterns also effect to html_static_path and html_extra_path
60-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
64+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6165

6266
# The reST default role (used for this markup: `text`) to use for all
6367
# documents.
@@ -69,7 +73,7 @@
6973
add_function_parentheses = True
7074

7175
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
76+
pygments_style = "sphinx"
7377

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

8993
if not on_rtd: # only import and set the theme if we're building docs locally
9094
try:
9195
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
96+
97+
html_theme = "sphinx_rtd_theme"
98+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
9499
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
100+
html_theme = "default"
101+
html_theme_path = ["."]
97102
else:
98-
html_theme_path = ['.']
103+
html_theme_path = ["."]
99104

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

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

111116
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitSharpmemorydisplayLibrarydoc'
117+
htmlhelp_basename = "AdafruitSharpmemorydisplayLibrarydoc"
113118

114119
# -- Options for LaTeX output ---------------------------------------------
115120

116121
latex_elements = {
117-
# The paper size ('letterpaper' or 'a4paper').
118-
#
119-
# 'papersize': 'letterpaper',
120-
121-
# The font size ('10pt', '11pt' or '12pt').
122-
#
123-
# 'pointsize': '10pt',
124-
125-
# Additional stuff for the LaTeX preamble.
126-
#
127-
# 'preamble': '',
128-
129-
# Latex figure (float) alignment
130-
#
131-
# 'figure_align': 'htbp',
122+
# The paper size ('letterpaper' or 'a4paper').
123+
#
124+
# 'papersize': 'letterpaper',
125+
# The font size ('10pt', '11pt' or '12pt').
126+
#
127+
# 'pointsize': '10pt',
128+
# Additional stuff for the LaTeX preamble.
129+
#
130+
# 'preamble': '',
131+
# Latex figure (float) alignment
132+
#
133+
# 'figure_align': 'htbp',
132134
}
133135

134136
# Grouping the document tree into LaTeX files. List of tuples
135137
# (source start file, target name, title,
136138
# author, documentclass [howto, manual, or own class]).
137139
latex_documents = [
138-
(master_doc, 'AdafruitSHARPMemoryDisplayLibrary.tex', u'AdafruitSHARPMemoryDisplay Library Documentation',
139-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitSHARPMemoryDisplayLibrary.tex",
143+
u"AdafruitSHARPMemoryDisplay Library Documentation",
144+
author,
145+
"manual",
146+
),
140147
]
141148

142149
# -- Options for manual page output ---------------------------------------
143150

144151
# One entry per manual page. List of tuples
145152
# (source start file, name, description, authors, manual section).
146153
man_pages = [
147-
(master_doc, 'AdafruitSHARPMemoryDisplaylibrary', u'Adafruit SHARPMemoryDisplay Library Documentation',
148-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitSHARPMemoryDisplaylibrary",
157+
u"Adafruit SHARPMemoryDisplay Library Documentation",
158+
[author],
159+
1,
160+
)
149161
]
150162

151163
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +166,13 @@
154166
# (source start file, target name, title, author,
155167
# dir menu entry, description, category)
156168
texinfo_documents = [
157-
(master_doc, 'AdafruitSHARPMemoryDisplayLibrary', u'Adafruit SHARPMemoryDisplay Library Documentation',
158-
author, 'AdafruitSHARPMemoryDisplayLibrary', 'One line description of project.',
159-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitSHARPMemoryDisplayLibrary",
172+
u"Adafruit SHARPMemoryDisplay Library Documentation",
173+
author,
174+
"AdafruitSHARPMemoryDisplayLibrary",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
160178
]

examples/sharpmemorydisplay_pillow_demo.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
FONTSIZE = 10
2323

2424
spi = busio.SPI(board.SCK, MOSI=board.MOSI)
25-
scs = digitalio.DigitalInOut(board.D6) # inverted chip select
25+
scs = digitalio.DigitalInOut(board.D6) # inverted chip select
2626

27-
#display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96)
27+
# display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96)
2828
display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 144, 168)
2929

3030
# Clear display.
@@ -33,7 +33,7 @@
3333

3434
# Create blank image for drawing.
3535
# Make sure to create image with mode '1' for 1-bit color.
36-
image = Image.new('1', (display.width, display.height))
36+
image = Image.new("1", (display.width, display.height))
3737

3838
# Get drawing object to draw on image.
3939
draw = ImageDraw.Draw(image)
@@ -42,17 +42,24 @@
4242
draw.rectangle((0, 0, display.width, display.height), outline=BLACK, fill=BLACK)
4343

4444
# Draw a smaller inner rectangle
45-
draw.rectangle((BORDER, BORDER, display.width - BORDER - 1, display.height - BORDER - 1),
46-
outline=WHITE, fill=WHITE)
45+
draw.rectangle(
46+
(BORDER, BORDER, display.width - BORDER - 1, display.height - BORDER - 1),
47+
outline=WHITE,
48+
fill=WHITE,
49+
)
4750

4851
# Load a TTF font.
49-
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', FONTSIZE)
52+
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", FONTSIZE)
5053

5154
# Draw Some Text
5255
text = "Hello World!"
5356
(font_width, font_height) = font.getsize(text)
54-
draw.text((display.width//2 - font_width//2, display.height//2 - font_height//2),
55-
text, font=font, fill=BLACK)
57+
draw.text(
58+
(display.width // 2 - font_width // 2, display.height // 2 - font_height // 2),
59+
text,
60+
font=font,
61+
fill=BLACK,
62+
)
5663

5764
# Display image
5865
display.image(image)

examples/sharpmemorydisplay_simpletest.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# Initialize SPI bus and control pins
99
spi = busio.SPI(board.SCK, MOSI=board.MOSI)
10-
scs = digitalio.DigitalInOut(board.D6) # inverted chip select
10+
scs = digitalio.DigitalInOut(board.D6) # inverted chip select
1111

1212
# pass in the display size, width and height, as well
1313
# display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96)
@@ -23,22 +23,25 @@
2323
# Set a pixel in the origin 0,0 position.
2424
display.pixel(0, 0, 0)
2525
# Set a pixel in the middle position.
26-
display.pixel(display.width//2, display.width//2, 0)
26+
display.pixel(display.width // 2, display.width // 2, 0)
2727
# Set a pixel in the opposite corner position.
28-
display.pixel(display.width-1, display.height-1, 0)
28+
display.pixel(display.width - 1, display.height - 1, 0)
2929
display.show()
3030
time.sleep(2)
3131

3232
print("Lines test")
3333
# we'll draw from corner to corner, lets define all the pair coordinates here
34-
corners = ((0, 0), (0, display.height-1), (display.width-1, 0),
35-
(display.width-1, display.height-1))
34+
corners = (
35+
(0, 0),
36+
(0, display.height - 1),
37+
(display.width - 1, 0),
38+
(display.width - 1, display.height - 1),
39+
)
3640

3741
display.fill(1)
3842
for corner_from in corners:
3943
for corner_to in corners:
40-
display.line(corner_from[0], corner_from[1],
41-
corner_to[0], corner_to[1], 0)
44+
display.line(corner_from[0], corner_from[1], corner_to[0], corner_to[1], 0)
4245
display.show()
4346
time.sleep(2)
4447

@@ -47,16 +50,16 @@
4750
w_delta = display.width / 10
4851
h_delta = display.height / 10
4952
for i in range(11):
50-
display.rect(0, 0, int(w_delta*i), int(h_delta*i), 0)
53+
display.rect(0, 0, int(w_delta * i), int(h_delta * i), 0)
5154
display.show()
5255
time.sleep(2)
5356

5457
print("Text test")
5558
display.fill(1)
56-
display.text(' hello world!', 0, 0, 0)
57-
display.text(' This is the', 0, 8, 0)
58-
display.text(' CircuitPython', 0, 16, 0)
59-
display.text('adafruit library', 0, 24, 0)
60-
display.text(' for the SHARP', 0, 32, 0)
61-
display.text(' Memory Display :) ', 0, 40, 0)
59+
display.text(" hello world!", 0, 0, 0)
60+
display.text(" This is the", 0, 8, 0)
61+
display.text(" CircuitPython", 0, 16, 0)
62+
display.text("adafruit library", 0, 24, 0)
63+
display.text(" for the SHARP", 0, 32, 0)
64+
display.text(" Memory Display :) ", 0, 40, 0)
6265
display.show()

0 commit comments

Comments
 (0)