Skip to content

Commit af5feeb

Browse files
authored
Merge pull request #50 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 56909af + f2aa379 commit af5feeb

17 files changed

+323
-190
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_seesaw/analoginput.py

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
__version__ = "0.0.0-auto.0"
3030
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"
3131

32+
3233
class AnalogInput:
3334
"""CircuitPython-compatible class for analog inputs
3435
@@ -37,6 +38,7 @@ class AnalogInput:
3738
:param ~adafruit_seesaw.seesaw.Seesaw seesaw: The device
3839
:param int pin: The pin number on the device
3940
"""
41+
4042
def __init__(self, seesaw, pin):
4143
self._seesaw = seesaw
4244
self._pin = pin

adafruit_seesaw/crickit.py

+33-10
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
try:
3030
from micropython import const
3131
except ImportError:
32+
3233
def const(x):
3334
return x
3435

36+
3537
__version__ = "0.0.0-auto.0"
3638
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"
3739

@@ -75,28 +77,49 @@ def const(x):
7577
# PA<nn> pins are nn
7678
# PB<nn> pins are 32+nn
7779

80+
7881
class Crickit_Pinmap:
7982
# seesaw firmware analog pin map:
8083
# analog[0]: 2 analog[1]: 3 analog[2]:40 analog[3]:41
8184
# analog[4]:11 analog[5]:10 analog[6]: 9 analog[7]: 8
8285
# no special remapping: same order as constants above
83-
analog_pins = (_CRICKIT_SIGNAL1, _CRICKIT_SIGNAL2,
84-
_CRICKIT_SIGNAL3, _CRICKIT_SIGNAL4,
85-
_CRICKIT_SIGNAL5, _CRICKIT_SIGNAL6,
86-
_CRICKIT_SIGNAL7, _CRICKIT_SIGNAL8)
86+
analog_pins = (
87+
_CRICKIT_SIGNAL1,
88+
_CRICKIT_SIGNAL2,
89+
_CRICKIT_SIGNAL3,
90+
_CRICKIT_SIGNAL4,
91+
_CRICKIT_SIGNAL5,
92+
_CRICKIT_SIGNAL6,
93+
_CRICKIT_SIGNAL7,
94+
_CRICKIT_SIGNAL8,
95+
)
8796

8897
pwm_width = 16
8998

9099
# seesaw firmware pwm pin map:
91100
# pwm[0]:14 pwm[1]:15 pwm[2]:16 pwm[3]:17 pwm[4]:18 pwm[5]:19
92101
# pwm[6]:22 pwm[7]:23 pwm[8]:42 pwm[9]:43 pwm[10]:12 pwm[11]:13
93102
# Note that servo pins are in reverse order (17-14), and motor pins are shuffled.
94-
pwm_pins = (_CRICKIT_SERVO4, _CRICKIT_SERVO3, _CRICKIT_SERVO2, _CRICKIT_SERVO1,
95-
_CRICKIT_MOTOR2B, _CRICKIT_MOTOR2A,
96-
_CRICKIT_MOTOR1A, _CRICKIT_MOTOR1B,
97-
_CRICKIT_DRIVE4, _CRICKIT_DRIVE3,
98-
_CRICKIT_DRIVE2, _CRICKIT_DRIVE1)
103+
pwm_pins = (
104+
_CRICKIT_SERVO4,
105+
_CRICKIT_SERVO3,
106+
_CRICKIT_SERVO2,
107+
_CRICKIT_SERVO1,
108+
_CRICKIT_MOTOR2B,
109+
_CRICKIT_MOTOR2A,
110+
_CRICKIT_MOTOR1A,
111+
_CRICKIT_MOTOR1B,
112+
_CRICKIT_DRIVE4,
113+
_CRICKIT_DRIVE3,
114+
_CRICKIT_DRIVE2,
115+
_CRICKIT_DRIVE1,
116+
)
99117

100118
# seesaw firmware touch pin map:
101119
# touch[0]: 4 touch[1]: 5 touch[2]: 6 touch[3]: 7
102-
touch_pins = (_CRICKIT_CAPTOUCH1, _CRICKIT_CAPTOUCH2, _CRICKIT_CAPTOUCH3, _CRICKIT_CAPTOUCH4)
120+
touch_pins = (
121+
_CRICKIT_CAPTOUCH1,
122+
_CRICKIT_CAPTOUCH2,
123+
_CRICKIT_CAPTOUCH3,
124+
_CRICKIT_CAPTOUCH4,
125+
)

adafruit_seesaw/digitalio.py

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
__version__ = "0.0.0-auto.0"
3232
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"
3333

34+
3435
class DigitalIO:
3536
"""CircuitPython-compatible class for digital I/O pins
3637
@@ -41,6 +42,7 @@ class DigitalIO:
4142
:param ~adafruit_seesaw.seesaw.Seesaw seesaw: The device
4243
:param int pin: The pin number on the device
4344
"""
45+
4446
def __init__(self, seesaw, pin):
4547
self._seesaw = seesaw
4648
self._pin = pin

adafruit_seesaw/keypad.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@
2929
try:
3030
from micropython import const
3131
except ImportError:
32+
3233
def const(x):
3334
return x
35+
36+
3437
from adafruit_seesaw.seesaw import Seesaw
3538

3639
__version__ = "0.0.0-auto.0"
@@ -52,11 +55,15 @@ class KeyEvent:
5255
:param int num: The number of the key
5356
:param int edge: One of the EDGE propertes of `adafruit_seesaw.keypad.Keypad`
5457
"""
58+
5559
def __init__(self, num, edge):
5660
self.number = int(num)
5761
self.edge = int(edge)
62+
63+
5864
# pylint: enable=too-few-public-methods
5965

66+
6067
class Keypad(Seesaw):
6168
"""On compatible SeeSaw devices, reads from a keypad.
6269
@@ -102,6 +109,7 @@ def count(self):
102109
@count.setter
103110
def count(self, value):
104111
raise AttributeError("count is read only")
112+
105113
# pylint: enable=unused-argument, no-self-use
106114

107115
def set_event(self, key, edge, enable):
@@ -118,7 +126,7 @@ def set_event(self, key, edge, enable):
118126

119127
cmd = bytearray(2)
120128
cmd[0] = key
121-
cmd[1] = (1 << (edge+1)) | enable
129+
cmd[1] = (1 << (edge + 1)) | enable
122130

123131
self.write(_KEYPAD_BASE, _KEYPAD_EVENT, cmd)
124132

adafruit_seesaw/neopixel.py

+19-5
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@
3333
try:
3434
from micropython import const
3535
except ImportError:
36+
3637
def const(x):
3738
return x
3839

40+
3941
__version__ = "1.2.3"
4042
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"
4143

@@ -58,6 +60,7 @@ def const(x):
5860
GRBW = (1, 0, 2, 3)
5961
"""Green Red Blue White"""
6062

63+
6164
class NeoPixel:
6265
"""Control NeoPixels connected to a seesaw
6366
@@ -70,7 +73,18 @@ class NeoPixel:
7073
:param tuple pixel_order: The layout of the pixels.
7174
Use one of the order constants such as RGBW.
7275
"""
73-
def __init__(self, seesaw, pin, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None):
76+
77+
def __init__(
78+
self,
79+
seesaw,
80+
pin,
81+
n,
82+
*,
83+
bpp=3,
84+
brightness=1.0,
85+
auto_write=True,
86+
pixel_order=None
87+
):
7488
# TODO: brightness not yet implemented.
7589
self._seesaw = seesaw
7690
self._pin = pin
@@ -82,7 +96,7 @@ def __init__(self, seesaw, pin, n, *, bpp=3, brightness=1.0, auto_write=True, pi
8296

8397
cmd = bytearray([pin])
8498
self._seesaw.write(_NEOPIXEL_BASE, _NEOPIXEL_PIN, cmd)
85-
cmd = struct.pack(">H", n*self._bpp)
99+
cmd = struct.pack(">H", n * self._bpp)
86100
self._seesaw.write(_NEOPIXEL_BASE, _NEOPIXEL_BUF_LENGTH, cmd)
87101

88102
@property
@@ -109,9 +123,9 @@ def __setitem__(self, key, color):
109123
struct.pack_into(">H", cmd, 0, key * self._bpp)
110124
if isinstance(color, int):
111125
w = color >> 24
112-
r = (color >> 16) & 0xff
113-
g = (color >> 8) & 0xff
114-
b = color & 0xff
126+
r = (color >> 16) & 0xFF
127+
g = (color >> 8) & 0xFF
128+
b = color & 0xFF
115129
else:
116130
if self._bpp == 3:
117131
r, g, b = color

adafruit_seesaw/pwmout.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
__version__ = "0.0.0-auto.0"
3030
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"
3131

32+
3233
class PWMOut:
3334
"""A single seesaw channel that matches the :py:class:`~pulseio.PWMOut` API."""
35+
3436
def __init__(self, seesaw, pin):
3537
self._seesaw = seesaw
3638
self._pin = pin
@@ -57,7 +59,7 @@ def duty_cycle(self):
5759

5860
@duty_cycle.setter
5961
def duty_cycle(self, value):
60-
if not 0 <= value <= 0xffff:
62+
if not 0 <= value <= 0xFFFF:
6163
raise ValueError("Must be 0 to 65535")
6264
self._seesaw.analog_write(self._pin, value)
6365
self._dc = value

adafruit_seesaw/robohat.py

+32-17
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
try:
3030
from micropython import const
3131
except ImportError:
32+
3233
def const(x):
3334
return x
3435

36+
3537
__version__ = "0.0.0-auto.0"
3638
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"
3739

@@ -40,20 +42,20 @@ def const(x):
4042
# The ordering here reflects the seesaw firmware (mm1_hat) pinmap for Robo HAT MM1,
4143
# not logical ordering of the HAT terminals.
4244

43-
_MM1_D0 = const(55) # (RX to RPI_TX)
44-
_MM1_D1 = const(54) # (TX to RPI_RX)
45-
_MM1_D2 = const(34) # ADC (GPS_TX)
46-
_MM1_D3 = const(35) # ADC (GPS_RX)
47-
_MM1_D4 = const(0) # (GPS_SDA)
48-
_MM1_D5 = const(1) # (GPS_SCL)
49-
_MM1_D6 = const(28) # (POWER_ENABLE)
50-
_MM1_D7 = const(2) # (BATTERY)
51-
_MM1_D8 = const(20) # (NEOPIXEL)
52-
_MM1_D9 = const(43) # PWM (SPI_SCK)
53-
_MM1_D10 = const(41) # PWM (SPI_SS)
54-
_MM1_D11 = const(42) # PWM (SPI_MOSI)
55-
_MM1_D12 = const(40) # PWM (SPI_MISO)
56-
_MM1_D13 = const(21) # LED
45+
_MM1_D0 = const(55) # (RX to RPI_TX)
46+
_MM1_D1 = const(54) # (TX to RPI_RX)
47+
_MM1_D2 = const(34) # ADC (GPS_TX)
48+
_MM1_D3 = const(35) # ADC (GPS_RX)
49+
_MM1_D4 = const(0) # (GPS_SDA)
50+
_MM1_D5 = const(1) # (GPS_SCL)
51+
_MM1_D6 = const(28) # (POWER_ENABLE)
52+
_MM1_D7 = const(2) # (BATTERY)
53+
_MM1_D8 = const(20) # (NEOPIXEL)
54+
_MM1_D9 = const(43) # PWM (SPI_SCK)
55+
_MM1_D10 = const(41) # PWM (SPI_SS)
56+
_MM1_D11 = const(42) # PWM (SPI_MOSI)
57+
_MM1_D12 = const(40) # PWM (SPI_MISO)
58+
_MM1_D13 = const(21) # LED
5759
_MM1_D14 = const(3) # (POWER_OFF)
5860

5961
_MM1_SERVO8 = const(8)
@@ -81,11 +83,13 @@ def const(x):
8183
# PA<nn> pins are nn
8284
# PB<nn> pins are 32+nn
8385

86+
8487
class MM1_Pinmap:
8588
"""This class is automatically used by `adafruit_seesaw.seesaw.Seesaw` when
8689
a RoboHAT board is detected.
8790
8891
It is also a reference for the capabilities of each pin."""
92+
8993
# seesaw firmware (mm1_hat) analog pin map:
9094
# analog[0]:47 analog[1]:48 analog[2]: analog[3]:
9195
# analog[4]: analog[5]: analog[6]: analog[7]:
@@ -101,9 +105,20 @@ class MM1_Pinmap:
101105
# pwm[6]:9 pwm[7]:8 pwm[8]:40 pwm[9]:41 pwm[10]:42 pwm[11]:43
102106
#
103107
#: The pins capable of PWM output
104-
pwm_pins = (_MM1_SERVO1, _MM1_SERVO2, _MM1_SERVO3, _MM1_SERVO4,
105-
_MM1_SERVO5, _MM1_SERVO6, _MM1_SERVO7, _MM1_SERVO8,
106-
_MM1_D12, _MM1_D10, _MM1_D11, _MM1_D9)
108+
pwm_pins = (
109+
_MM1_SERVO1,
110+
_MM1_SERVO2,
111+
_MM1_SERVO3,
112+
_MM1_SERVO4,
113+
_MM1_SERVO5,
114+
_MM1_SERVO6,
115+
_MM1_SERVO7,
116+
_MM1_SERVO8,
117+
_MM1_D12,
118+
_MM1_D10,
119+
_MM1_D11,
120+
_MM1_D9,
121+
)
107122

108123
# seesaw firmware touch pin map:
109124
# touch[0]: 7 touch[1]: 6 touch[2]: 5 touch[3]: 4

adafruit_seesaw/samd09.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
try:
3030
from micropython import const
3131
except ImportError:
32+
3233
def const(x):
3334
return x
3435

36+
3537
__version__ = "0.0.0-auto.0"
3638
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"
3739

@@ -45,15 +47,20 @@ def const(x):
4547
_PWM_2_PIN = const(0x06)
4648
_PWM_3_PIN = const(0x07)
4749

50+
4851
class SAMD09_Pinmap:
4952
"""This class is automatically used by `adafruit_seesaw.seesaw.Seesaw` when
5053
a SAMD09 Breakout is detected.
5154
5255
It is also a reference for the capabilities of each pin."""
5356

5457
#: The pins capable of analog output
55-
analog_pins = (_ADC_INPUT_0_PIN, _ADC_INPUT_1_PIN,
56-
_ADC_INPUT_2_PIN, _ADC_INPUT_3_PIN)
58+
analog_pins = (
59+
_ADC_INPUT_0_PIN,
60+
_ADC_INPUT_1_PIN,
61+
_ADC_INPUT_2_PIN,
62+
_ADC_INPUT_3_PIN,
63+
)
5764

5865
"""The effective bit resolution of the PWM pins"""
5966
pwm_width = 8

0 commit comments

Comments
 (0)