Skip to content

Commit b63b75e

Browse files
authored
Merge pull request #9 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents a92c130 + 9a2b515 commit b63b75e

File tree

5 files changed

+109
-85
lines changed

5 files changed

+109
-85
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
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 pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

adafruit_displayio_ssd1306.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@
5353

5454
# Sequence from page 19 here: https://cdn-shop.adafruit.com/datasheets/UG-2864HSWEG01+user+guide.pdf
5555
_INIT_SEQUENCE = (
56-
b"\xAE\x00" # DISPLAY_OFF
56+
b"\xAE\x00" # DISPLAY_OFF
5757
b"\x20\x01\x00" # Set memory addressing to horizontal mode.
58-
b"\x81\x01\xcf" # set contrast control
59-
b"\xA1\x00" # Column 127 is segment 0
60-
b"\xA6\x00" # Normal display
61-
b"\xc8\x00" # Normal display
58+
b"\x81\x01\xcf" # set contrast control
59+
b"\xA1\x00" # Column 127 is segment 0
60+
b"\xA6\x00" # Normal display
61+
b"\xc8\x00" # Normal display
6262
b"\xA8\x01\x3f" # Mux ratio is 1/64
6363
b"\xd5\x01\x80" # Set divide ratio
6464
b"\xd9\x01\xf1" # Set pre-charge period
@@ -71,17 +71,27 @@
7171
# pylint: disable=too-few-public-methods
7272
class SSD1306(displayio.Display):
7373
"""SSD1306 driver"""
74+
7475
def __init__(self, bus, **kwargs):
7576
# Patch the init sequence for 32 pixel high displays.
7677
init_sequence = bytearray(_INIT_SEQUENCE)
7778
height = kwargs["height"]
7879
if "rotation" in kwargs and kwargs["rotation"] % 180 != 0:
7980
height = kwargs["width"]
80-
init_sequence[16] = height - 1 # patch mux ratio
81+
init_sequence[16] = height - 1 # patch mux ratio
8182
if kwargs["height"] == 32:
82-
init_sequence[25] = 0x02 # patch com configuration
83-
super().__init__(bus, init_sequence, **kwargs, color_depth=1, grayscale=True,
84-
pixels_in_byte_share_row=False,
85-
set_column_command=0x21, set_row_command=0x22, data_as_commands=True,
86-
set_vertical_scroll=0xd3, brightness_command=0x81,
87-
single_byte_bounds=True)
83+
init_sequence[25] = 0x02 # patch com configuration
84+
super().__init__(
85+
bus,
86+
init_sequence,
87+
**kwargs,
88+
color_depth=1,
89+
grayscale=True,
90+
pixels_in_byte_share_row=False,
91+
set_column_command=0x21,
92+
set_row_command=0x22,
93+
data_as_commands=True,
94+
set_vertical_scroll=0xD3,
95+
brightness_command=0x81,
96+
single_byte_bounds=True,
97+
)

docs/conf.py

Lines changed: 65 additions & 47 deletions
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 = ["displayio"]
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 DisplayIO_SSD1306 Library'
38-
copyright = u'2019 Scott Shawcroft'
39-
author = u'Scott Shawcroft'
41+
project = "Adafruit DisplayIO_SSD1306 Library"
42+
copyright = "2019 Scott Shawcroft"
43+
author = "Scott Shawcroft"
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 = "1.0"
4751
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
52+
release = "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 = 'AdafruitDisplayio_ssd1306Librarydoc'
117+
htmlhelp_basename = "AdafruitDisplayio_ssd1306Librarydoc"
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, 'AdafruitDisplayIO_SSD1306Library.tex', u'AdafruitDisplayIO_SSD1306 Library Documentation',
139-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitDisplayIO_SSD1306Library.tex",
143+
"AdafruitDisplayIO_SSD1306 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, 'AdafruitDisplayIO_SSD1306library', u'Adafruit DisplayIO_SSD1306 Library Documentation',
148-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitDisplayIO_SSD1306library",
157+
"Adafruit DisplayIO_SSD1306 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, 'AdafruitDisplayIO_SSD1306Library', u'Adafruit DisplayIO_SSD1306 Library Documentation',
158-
author, 'AdafruitDisplayIO_SSD1306Library', 'One line description of project.',
159-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitDisplayIO_SSD1306Library",
172+
"Adafruit DisplayIO_SSD1306 Library Documentation",
173+
author,
174+
"AdafruitDisplayIO_SSD1306Library",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
160178
]

examples/displayio_ssd1306_featherwing.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
displayio.release_displays()
1313

1414
i2c = board.I2C()
15-
display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)
15+
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)
1616
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
1717

1818
# Make the display context
@@ -21,20 +21,16 @@
2121

2222
color_bitmap = displayio.Bitmap(128, 32, 1)
2323
color_palette = displayio.Palette(1)
24-
color_palette[0] = 0xFFFFFF # White
24+
color_palette[0] = 0xFFFFFF # White
2525

26-
bg_sprite = displayio.TileGrid(color_bitmap,
27-
pixel_shader=color_palette,
28-
x=0, y=0)
26+
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
2927
splash.append(bg_sprite)
3028

3129
# Draw a smaller inner rectangle
3230
inner_bitmap = displayio.Bitmap(118, 24, 1)
3331
inner_palette = displayio.Palette(1)
34-
inner_palette[0] = 0x000000 # Black
35-
inner_sprite = displayio.TileGrid(inner_bitmap,
36-
pixel_shader=inner_palette,
37-
x=5, y=4)
32+
inner_palette[0] = 0x000000 # Black
33+
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=5, y=4)
3834
splash.append(inner_sprite)
3935

4036
# Draw a label

examples/displayio_ssd1306_simpletest.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515

1616
# Use for I2C
1717
i2c = board.I2C()
18-
display_bus = displayio.I2CDisplay(i2c, device_address=0x3c, reset=oled_reset)
18+
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C, reset=oled_reset)
1919

2020
# Use for SPI
21-
#spi = board.SPI()
22-
#oled_cs = board.D5
23-
#oled_dc = board.D6
24-
#display_bus = displayio.FourWire(spi, command=oled_dc, chip_select=oled_cs,
21+
# spi = board.SPI()
22+
# oled_cs = board.D5
23+
# oled_dc = board.D6
24+
# display_bus = displayio.FourWire(spi, command=oled_dc, chip_select=oled_cs,
2525
# reset=oled_reset, baudrate=1000000)
2626

2727
WIDTH = 128
28-
HEIGHT = 32 # Change to 64 if needed
28+
HEIGHT = 32 # Change to 64 if needed
2929
BORDER = 5
3030

3131
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=WIDTH, height=HEIGHT)
@@ -36,25 +36,25 @@
3636

3737
color_bitmap = displayio.Bitmap(WIDTH, HEIGHT, 1)
3838
color_palette = displayio.Palette(1)
39-
color_palette[0] = 0xFFFFFF # White
39+
color_palette[0] = 0xFFFFFF # White
4040

41-
bg_sprite = displayio.TileGrid(color_bitmap,
42-
pixel_shader=color_palette,
43-
x=0, y=0)
41+
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
4442
splash.append(bg_sprite)
4543

4644
# Draw a smaller inner rectangle
47-
inner_bitmap = displayio.Bitmap(WIDTH-BORDER*2, HEIGHT-BORDER*2, 1)
45+
inner_bitmap = displayio.Bitmap(WIDTH - BORDER * 2, HEIGHT - BORDER * 2, 1)
4846
inner_palette = displayio.Palette(1)
49-
inner_palette[0] = 0x000000 # Black
50-
inner_sprite = displayio.TileGrid(inner_bitmap,
51-
pixel_shader=inner_palette,
52-
x=BORDER, y=BORDER)
47+
inner_palette[0] = 0x000000 # Black
48+
inner_sprite = displayio.TileGrid(
49+
inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER
50+
)
5351
splash.append(inner_sprite)
5452

5553
# Draw a label
5654
text = "Hello World!"
57-
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFFFF, x=28, y=HEIGHT//2-1)
55+
text_area = label.Label(
56+
terminalio.FONT, text=text, color=0xFFFFFF, x=28, y=HEIGHT // 2 - 1
57+
)
5858
splash.append(text_area)
5959

6060
while True:

0 commit comments

Comments
 (0)