Skip to content

Commit 81012cf

Browse files
authored
Merge pull request #7 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 35bfe42 + 072d233 commit 81012cf

File tree

6 files changed

+217
-145
lines changed

6 files changed

+217
-145
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_ssd1305.py

+102-55
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
from micropython import const
5454
from adafruit_bus_device import i2c_device, spi_device
55+
5556
try:
5657
import framebuf
5758
except ImportError:
@@ -60,35 +61,36 @@
6061
__version__ = "0.0.0-auto.0"
6162
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SSD1305.git"
6263

63-
#pylint: disable-msg=bad-whitespace
64+
# pylint: disable-msg=bad-whitespace
6465
# register definitions
65-
SET_CONTRAST = const(0x81)
66-
SET_ENTIRE_ON = const(0xa4)
67-
SET_NORM_INV = const(0xa6)
68-
SET_DISP = const(0xae)
69-
SET_MEM_ADDR = const(0x20)
70-
SET_COL_ADDR = const(0x21)
71-
SET_PAGE_ADDR = const(0x22)
66+
SET_CONTRAST = const(0x81)
67+
SET_ENTIRE_ON = const(0xA4)
68+
SET_NORM_INV = const(0xA6)
69+
SET_DISP = const(0xAE)
70+
SET_MEM_ADDR = const(0x20)
71+
SET_COL_ADDR = const(0x21)
72+
SET_PAGE_ADDR = const(0x22)
7273
SET_DISP_START_LINE = const(0x40)
73-
SET_LUT = const(0x91)
74-
SET_SEG_REMAP = const(0xa0)
75-
SET_MUX_RATIO = const(0xa8)
76-
SET_MASTER_CONFIG = const(0xad)
77-
SET_COM_OUT_DIR = const(0xc0)
78-
SET_COMSCAN_DEC = const(0xc8)
79-
SET_DISP_OFFSET = const(0xd3)
80-
SET_COM_PIN_CFG = const(0xda)
81-
SET_DISP_CLK_DIV = const(0xd5)
82-
SET_AREA_COLOR = const(0xd8)
83-
SET_PRECHARGE = const(0xd9)
84-
SET_VCOM_DESEL = const(0xdb)
85-
SET_CHARGE_PUMP = const(0x8d)
86-
#pylint: enable-msg=bad-whitespace
74+
SET_LUT = const(0x91)
75+
SET_SEG_REMAP = const(0xA0)
76+
SET_MUX_RATIO = const(0xA8)
77+
SET_MASTER_CONFIG = const(0xAD)
78+
SET_COM_OUT_DIR = const(0xC0)
79+
SET_COMSCAN_DEC = const(0xC8)
80+
SET_DISP_OFFSET = const(0xD3)
81+
SET_COM_PIN_CFG = const(0xDA)
82+
SET_DISP_CLK_DIV = const(0xD5)
83+
SET_AREA_COLOR = const(0xD8)
84+
SET_PRECHARGE = const(0xD9)
85+
SET_VCOM_DESEL = const(0xDB)
86+
SET_CHARGE_PUMP = const(0x8D)
87+
# pylint: enable-msg=bad-whitespace
8788

8889

8990
class _SSD1305(framebuf.FrameBuffer):
9091
"""Base class for SSD1305 display driver"""
91-
#pylint: disable-msg=too-many-arguments
92+
93+
# pylint: disable-msg=too-many-arguments
9294
def __init__(self, buffer, width, height, *, external_vcc, reset):
9395
super().__init__(buffer, width, height)
9496
self.width = width
@@ -101,7 +103,7 @@ def __init__(self, buffer, width, height, *, external_vcc, reset):
101103
self.pages = self.height // 8
102104
self._column_offset = 0
103105
if self.height == 32:
104-
self._column_offset = 4 # hardcoded for now...
106+
self._column_offset = 4 # hardcoded for now...
105107
# Note the subclass must initialize self.framebuf to a framebuffer.
106108
# This is necessary because the underlying data buffer is different
107109
# between I2C and SPI implementations (I2C needs an extra byte).
@@ -111,26 +113,43 @@ def __init__(self, buffer, width, height, *, external_vcc, reset):
111113
def init_display(self):
112114
"""Base class to initialize display"""
113115
for cmd in (
114-
SET_DISP | 0x00, # off
115-
# timing and driving scheme
116-
SET_DISP_CLK_DIV, 0x80, #SET_DISP_CLK_DIV
117-
SET_SEG_REMAP | 0x01, # column addr 127 mapped to SEG0 SET_SEG_REMAP
118-
SET_MUX_RATIO, self.height - 1, #SET_MUX_RATIO
119-
SET_DISP_OFFSET, 0x00, #SET_DISP_OFFSET
120-
SET_MASTER_CONFIG, 0x8e, #Set Master Configuration
121-
SET_AREA_COLOR, 0x05, #Set Area Color Mode On/Off & Low Power Display Mode
122-
SET_MEM_ADDR, 0x00, # horizontal SET_MEM_ADDR ADD
123-
SET_DISP_START_LINE | 0x00, 0x2E, #SET_DISP_START_LINE ADD
124-
SET_COMSCAN_DEC, #Set COM Output Scan Direction 64 to 1
125-
SET_COM_PIN_CFG, 0x12, #SET_COM_PIN_CFG
126-
SET_LUT, 0x3f, 0x3f, 0x3f, 0x3f,#Current drive pulse width of BANK0, Color A, B, C
127-
SET_CONTRAST, 0xff, # maximum SET_CONTRAST to maximum
128-
SET_PRECHARGE, 0xd2, #SET_PRECHARGE orig: 0xd9, 0x22 if self.external_vcc else 0xf1,
129-
SET_VCOM_DESEL, 0x34, #SET_VCOM_DESEL 0xdb, 0x30, $ 0.83* Vcc
130-
SET_NORM_INV, # not inverted SET_NORM_INV
131-
SET_ENTIRE_ON, # output follows RAM contents SET_ENTIRE_ON
132-
SET_CHARGE_PUMP, 0x10 if self.external_vcc else 0x14, #SET_CHARGE_PUMP
133-
SET_DISP | 0x01): #//--turn on oled panel
116+
SET_DISP | 0x00, # off
117+
# timing and driving scheme
118+
SET_DISP_CLK_DIV,
119+
0x80, # SET_DISP_CLK_DIV
120+
SET_SEG_REMAP | 0x01, # column addr 127 mapped to SEG0 SET_SEG_REMAP
121+
SET_MUX_RATIO,
122+
self.height - 1, # SET_MUX_RATIO
123+
SET_DISP_OFFSET,
124+
0x00, # SET_DISP_OFFSET
125+
SET_MASTER_CONFIG,
126+
0x8E, # Set Master Configuration
127+
SET_AREA_COLOR,
128+
0x05, # Set Area Color Mode On/Off & Low Power Display Mode
129+
SET_MEM_ADDR,
130+
0x00, # horizontal SET_MEM_ADDR ADD
131+
SET_DISP_START_LINE | 0x00,
132+
0x2E, # SET_DISP_START_LINE ADD
133+
SET_COMSCAN_DEC, # Set COM Output Scan Direction 64 to 1
134+
SET_COM_PIN_CFG,
135+
0x12, # SET_COM_PIN_CFG
136+
SET_LUT,
137+
0x3F,
138+
0x3F,
139+
0x3F,
140+
0x3F, # Current drive pulse width of BANK0, Color A, B, C
141+
SET_CONTRAST,
142+
0xFF, # maximum SET_CONTRAST to maximum
143+
SET_PRECHARGE,
144+
0xD2, # SET_PRECHARGE orig: 0xd9, 0x22 if self.external_vcc else 0xf1,
145+
SET_VCOM_DESEL,
146+
0x34, # SET_VCOM_DESEL 0xdb, 0x30, $ 0.83* Vcc
147+
SET_NORM_INV, # not inverted SET_NORM_INV
148+
SET_ENTIRE_ON, # output follows RAM contents SET_ENTIRE_ON
149+
SET_CHARGE_PUMP,
150+
0x10 if self.external_vcc else 0x14, # SET_CHARGE_PUMP
151+
SET_DISP | 0x01,
152+
): # //--turn on oled panel
134153
self.write_cmd(cmd)
135154
self.fill(0)
136155
self.show()
@@ -183,6 +202,7 @@ def show(self):
183202
self.write_cmd(self.pages - 1)
184203
self.write_framebuf()
185204

205+
186206
class SSD1305_I2C(_SSD1305):
187207
"""
188208
I2C class for SSD1305
@@ -195,7 +215,9 @@ class SSD1305_I2C(_SSD1305):
195215
:param reset: if needed, DigitalInOut designating reset pin
196216
"""
197217

198-
def __init__(self, width, height, i2c, *, addr=0x3c, external_vcc=False, reset=None):
218+
def __init__(
219+
self, width, height, i2c, *, addr=0x3C, external_vcc=False, reset=None
220+
):
199221
self.i2c_device = i2c_device.I2CDevice(i2c, addr)
200222
self.addr = addr
201223
self.temp = bytearray(2)
@@ -206,12 +228,17 @@ def __init__(self, width, height, i2c, *, addr=0x3c, external_vcc=False, reset=N
206228
# buffer).
207229
self.buffer = bytearray(((height // 8) * width) + 1)
208230
self.buffer[0] = 0x40 # Set first byte of data buffer to Co=0, D/C=1
209-
super().__init__(memoryview(self.buffer)[1:], width, height,
210-
external_vcc=external_vcc, reset=reset)
231+
super().__init__(
232+
memoryview(self.buffer)[1:],
233+
width,
234+
height,
235+
external_vcc=external_vcc,
236+
reset=reset,
237+
)
211238

212239
def write_cmd(self, cmd):
213240
"""Send a command to the SPI device"""
214-
self.temp[0] = 0x80 # Co=1, D/C#=0
241+
self.temp[0] = 0x80 # Co=1, D/C#=0
215242
self.temp[1] = cmd
216243
with self.i2c_device:
217244
self.i2c_device.write(self.temp)
@@ -222,7 +249,8 @@ def write_framebuf(self):
222249
with self.i2c_device:
223250
self.i2c_device.write(self.buffer)
224251

225-
#pylint: disable-msg=too-many-arguments
252+
253+
# pylint: disable-msg=too-many-arguments
226254
class SSD1305_SPI(_SSD1305):
227255
"""
228256
SPI class for SSD1305
@@ -234,18 +262,37 @@ class SSD1305_SPI(_SSD1305):
234262
:param reset: the reset pin to use,
235263
:param cs: the chip-select pin to use (sometimes labeled "SS").
236264
"""
265+
237266
# pylint: disable=no-member
238267
# Disable should be reconsidered when refactor can be tested.
239-
def __init__(self, width, height, spi, dc, reset, cs, *,
240-
external_vcc=False, baudrate=8000000, polarity=0, phase=0):
268+
def __init__(
269+
self,
270+
width,
271+
height,
272+
spi,
273+
dc,
274+
reset,
275+
cs,
276+
*,
277+
external_vcc=False,
278+
baudrate=8000000,
279+
polarity=0,
280+
phase=0
281+
):
241282
self.rate = 10 * 1024 * 1024
242283
dc.switch_to_output(value=0)
243-
self.spi_device = spi_device.SPIDevice(spi, cs, baudrate=baudrate,
244-
polarity=polarity, phase=phase)
284+
self.spi_device = spi_device.SPIDevice(
285+
spi, cs, baudrate=baudrate, polarity=polarity, phase=phase
286+
)
245287
self.dc_pin = dc
246288
self.buffer = bytearray((height // 8) * width)
247-
super().__init__(memoryview(self.buffer), width, height,
248-
external_vcc=external_vcc, reset=reset)
289+
super().__init__(
290+
memoryview(self.buffer),
291+
width,
292+
height,
293+
external_vcc=external_vcc,
294+
reset=reset,
295+
)
249296

250297
def write_cmd(self, cmd):
251298
"""Send a command to the SPI device"""

0 commit comments

Comments
 (0)