Skip to content

Commit

Permalink
Merge pull request #50 from adafruit/pylint-update
Browse files Browse the repository at this point in the history
Ran black, updated to pylint 2.x
  • Loading branch information
kattni committed Mar 17, 2020
2 parents 56909af + f2aa379 commit af5feeb
Show file tree
Hide file tree
Showing 17 changed files with 323 additions and 190 deletions.
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
2 changes: 2 additions & 0 deletions adafruit_seesaw/analoginput.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"


class AnalogInput:
"""CircuitPython-compatible class for analog inputs
Expand All @@ -37,6 +38,7 @@ class AnalogInput:
:param ~adafruit_seesaw.seesaw.Seesaw seesaw: The device
:param int pin: The pin number on the device
"""

def __init__(self, seesaw, pin):
self._seesaw = seesaw
self._pin = pin
Expand Down
43 changes: 33 additions & 10 deletions adafruit_seesaw/crickit.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
try:
from micropython import const
except ImportError:

def const(x):
return x


__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"

Expand Down Expand Up @@ -75,28 +77,49 @@ def const(x):
# PA<nn> pins are nn
# PB<nn> pins are 32+nn


class Crickit_Pinmap:
# seesaw firmware analog pin map:
# analog[0]: 2 analog[1]: 3 analog[2]:40 analog[3]:41
# analog[4]:11 analog[5]:10 analog[6]: 9 analog[7]: 8
# no special remapping: same order as constants above
analog_pins = (_CRICKIT_SIGNAL1, _CRICKIT_SIGNAL2,
_CRICKIT_SIGNAL3, _CRICKIT_SIGNAL4,
_CRICKIT_SIGNAL5, _CRICKIT_SIGNAL6,
_CRICKIT_SIGNAL7, _CRICKIT_SIGNAL8)
analog_pins = (
_CRICKIT_SIGNAL1,
_CRICKIT_SIGNAL2,
_CRICKIT_SIGNAL3,
_CRICKIT_SIGNAL4,
_CRICKIT_SIGNAL5,
_CRICKIT_SIGNAL6,
_CRICKIT_SIGNAL7,
_CRICKIT_SIGNAL8,
)

pwm_width = 16

# seesaw firmware pwm pin map:
# pwm[0]:14 pwm[1]:15 pwm[2]:16 pwm[3]:17 pwm[4]:18 pwm[5]:19
# pwm[6]:22 pwm[7]:23 pwm[8]:42 pwm[9]:43 pwm[10]:12 pwm[11]:13
# Note that servo pins are in reverse order (17-14), and motor pins are shuffled.
pwm_pins = (_CRICKIT_SERVO4, _CRICKIT_SERVO3, _CRICKIT_SERVO2, _CRICKIT_SERVO1,
_CRICKIT_MOTOR2B, _CRICKIT_MOTOR2A,
_CRICKIT_MOTOR1A, _CRICKIT_MOTOR1B,
_CRICKIT_DRIVE4, _CRICKIT_DRIVE3,
_CRICKIT_DRIVE2, _CRICKIT_DRIVE1)
pwm_pins = (
_CRICKIT_SERVO4,
_CRICKIT_SERVO3,
_CRICKIT_SERVO2,
_CRICKIT_SERVO1,
_CRICKIT_MOTOR2B,
_CRICKIT_MOTOR2A,
_CRICKIT_MOTOR1A,
_CRICKIT_MOTOR1B,
_CRICKIT_DRIVE4,
_CRICKIT_DRIVE3,
_CRICKIT_DRIVE2,
_CRICKIT_DRIVE1,
)

# seesaw firmware touch pin map:
# touch[0]: 4 touch[1]: 5 touch[2]: 6 touch[3]: 7
touch_pins = (_CRICKIT_CAPTOUCH1, _CRICKIT_CAPTOUCH2, _CRICKIT_CAPTOUCH3, _CRICKIT_CAPTOUCH4)
touch_pins = (
_CRICKIT_CAPTOUCH1,
_CRICKIT_CAPTOUCH2,
_CRICKIT_CAPTOUCH3,
_CRICKIT_CAPTOUCH4,
)
2 changes: 2 additions & 0 deletions adafruit_seesaw/digitalio.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"


class DigitalIO:
"""CircuitPython-compatible class for digital I/O pins
Expand All @@ -41,6 +42,7 @@ class DigitalIO:
:param ~adafruit_seesaw.seesaw.Seesaw seesaw: The device
:param int pin: The pin number on the device
"""

def __init__(self, seesaw, pin):
self._seesaw = seesaw
self._pin = pin
Expand Down
10 changes: 9 additions & 1 deletion adafruit_seesaw/keypad.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
try:
from micropython import const
except ImportError:

def const(x):
return x


from adafruit_seesaw.seesaw import Seesaw

__version__ = "0.0.0-auto.0"
Expand All @@ -52,11 +55,15 @@ class KeyEvent:
:param int num: The number of the key
:param int edge: One of the EDGE propertes of `adafruit_seesaw.keypad.Keypad`
"""

def __init__(self, num, edge):
self.number = int(num)
self.edge = int(edge)


# pylint: enable=too-few-public-methods


class Keypad(Seesaw):
"""On compatible SeeSaw devices, reads from a keypad.
Expand Down Expand Up @@ -102,6 +109,7 @@ def count(self):
@count.setter
def count(self, value):
raise AttributeError("count is read only")

# pylint: enable=unused-argument, no-self-use

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

cmd = bytearray(2)
cmd[0] = key
cmd[1] = (1 << (edge+1)) | enable
cmd[1] = (1 << (edge + 1)) | enable

self.write(_KEYPAD_BASE, _KEYPAD_EVENT, cmd)

Expand Down
24 changes: 19 additions & 5 deletions adafruit_seesaw/neopixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
try:
from micropython import const
except ImportError:

def const(x):
return x


__version__ = "1.2.3"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"

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


class NeoPixel:
"""Control NeoPixels connected to a seesaw
Expand All @@ -70,7 +73,18 @@ class NeoPixel:
:param tuple pixel_order: The layout of the pixels.
Use one of the order constants such as RGBW.
"""
def __init__(self, seesaw, pin, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None):

def __init__(
self,
seesaw,
pin,
n,
*,
bpp=3,
brightness=1.0,
auto_write=True,
pixel_order=None
):
# TODO: brightness not yet implemented.
self._seesaw = seesaw
self._pin = pin
Expand All @@ -82,7 +96,7 @@ def __init__(self, seesaw, pin, n, *, bpp=3, brightness=1.0, auto_write=True, pi

cmd = bytearray([pin])
self._seesaw.write(_NEOPIXEL_BASE, _NEOPIXEL_PIN, cmd)
cmd = struct.pack(">H", n*self._bpp)
cmd = struct.pack(">H", n * self._bpp)
self._seesaw.write(_NEOPIXEL_BASE, _NEOPIXEL_BUF_LENGTH, cmd)

@property
Expand All @@ -109,9 +123,9 @@ def __setitem__(self, key, color):
struct.pack_into(">H", cmd, 0, key * self._bpp)
if isinstance(color, int):
w = color >> 24
r = (color >> 16) & 0xff
g = (color >> 8) & 0xff
b = color & 0xff
r = (color >> 16) & 0xFF
g = (color >> 8) & 0xFF
b = color & 0xFF
else:
if self._bpp == 3:
r, g, b = color
Expand Down
4 changes: 3 additions & 1 deletion adafruit_seesaw/pwmout.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"


class PWMOut:
"""A single seesaw channel that matches the :py:class:`~pulseio.PWMOut` API."""

def __init__(self, seesaw, pin):
self._seesaw = seesaw
self._pin = pin
Expand All @@ -57,7 +59,7 @@ def duty_cycle(self):

@duty_cycle.setter
def duty_cycle(self, value):
if not 0 <= value <= 0xffff:
if not 0 <= value <= 0xFFFF:
raise ValueError("Must be 0 to 65535")
self._seesaw.analog_write(self._pin, value)
self._dc = value
Expand Down
49 changes: 32 additions & 17 deletions adafruit_seesaw/robohat.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
try:
from micropython import const
except ImportError:

def const(x):
return x


__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"

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

_MM1_D0 = const(55) # (RX to RPI_TX)
_MM1_D1 = const(54) # (TX to RPI_RX)
_MM1_D2 = const(34) # ADC (GPS_TX)
_MM1_D3 = const(35) # ADC (GPS_RX)
_MM1_D4 = const(0) # (GPS_SDA)
_MM1_D5 = const(1) # (GPS_SCL)
_MM1_D6 = const(28) # (POWER_ENABLE)
_MM1_D7 = const(2) # (BATTERY)
_MM1_D8 = const(20) # (NEOPIXEL)
_MM1_D9 = const(43) # PWM (SPI_SCK)
_MM1_D10 = const(41) # PWM (SPI_SS)
_MM1_D11 = const(42) # PWM (SPI_MOSI)
_MM1_D12 = const(40) # PWM (SPI_MISO)
_MM1_D13 = const(21) # LED
_MM1_D0 = const(55) # (RX to RPI_TX)
_MM1_D1 = const(54) # (TX to RPI_RX)
_MM1_D2 = const(34) # ADC (GPS_TX)
_MM1_D3 = const(35) # ADC (GPS_RX)
_MM1_D4 = const(0) # (GPS_SDA)
_MM1_D5 = const(1) # (GPS_SCL)
_MM1_D6 = const(28) # (POWER_ENABLE)
_MM1_D7 = const(2) # (BATTERY)
_MM1_D8 = const(20) # (NEOPIXEL)
_MM1_D9 = const(43) # PWM (SPI_SCK)
_MM1_D10 = const(41) # PWM (SPI_SS)
_MM1_D11 = const(42) # PWM (SPI_MOSI)
_MM1_D12 = const(40) # PWM (SPI_MISO)
_MM1_D13 = const(21) # LED
_MM1_D14 = const(3) # (POWER_OFF)

_MM1_SERVO8 = const(8)
Expand Down Expand Up @@ -81,11 +83,13 @@ def const(x):
# PA<nn> pins are nn
# PB<nn> pins are 32+nn


class MM1_Pinmap:
"""This class is automatically used by `adafruit_seesaw.seesaw.Seesaw` when
a RoboHAT board is detected.
It is also a reference for the capabilities of each pin."""

# seesaw firmware (mm1_hat) analog pin map:
# analog[0]:47 analog[1]:48 analog[2]: analog[3]:
# analog[4]: analog[5]: analog[6]: analog[7]:
Expand All @@ -101,9 +105,20 @@ class MM1_Pinmap:
# pwm[6]:9 pwm[7]:8 pwm[8]:40 pwm[9]:41 pwm[10]:42 pwm[11]:43
#
#: The pins capable of PWM output
pwm_pins = (_MM1_SERVO1, _MM1_SERVO2, _MM1_SERVO3, _MM1_SERVO4,
_MM1_SERVO5, _MM1_SERVO6, _MM1_SERVO7, _MM1_SERVO8,
_MM1_D12, _MM1_D10, _MM1_D11, _MM1_D9)
pwm_pins = (
_MM1_SERVO1,
_MM1_SERVO2,
_MM1_SERVO3,
_MM1_SERVO4,
_MM1_SERVO5,
_MM1_SERVO6,
_MM1_SERVO7,
_MM1_SERVO8,
_MM1_D12,
_MM1_D10,
_MM1_D11,
_MM1_D9,
)

# seesaw firmware touch pin map:
# touch[0]: 7 touch[1]: 6 touch[2]: 5 touch[3]: 4
Expand Down
11 changes: 9 additions & 2 deletions adafruit_seesaw/samd09.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
try:
from micropython import const
except ImportError:

def const(x):
return x


__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"

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


class SAMD09_Pinmap:
"""This class is automatically used by `adafruit_seesaw.seesaw.Seesaw` when
a SAMD09 Breakout is detected.
It is also a reference for the capabilities of each pin."""

#: The pins capable of analog output
analog_pins = (_ADC_INPUT_0_PIN, _ADC_INPUT_1_PIN,
_ADC_INPUT_2_PIN, _ADC_INPUT_3_PIN)
analog_pins = (
_ADC_INPUT_0_PIN,
_ADC_INPUT_1_PIN,
_ADC_INPUT_2_PIN,
_ADC_INPUT_3_PIN,
)

"""The effective bit resolution of the PWM pins"""
pwm_width = 8
Expand Down

0 comments on commit af5feeb

Please sign in to comment.