Skip to content

Ran black, updated to pylint 2.x #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_featherwing/alphanum_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
import adafruit_ht16k33.segments as segments
from adafruit_featherwing.led_segments import Segments


class AlphaNumFeatherWing(Segments):
"""Class representing an `Adafruit 14-segment AlphaNumeric FeatherWing
<https://www.adafruit.com/product/3139>`_.

Automatically uses the feather's I2C bus."""

def __init__(self, address=0x70, i2c=None):
super().__init__()
if i2c is None:
Expand Down
11 changes: 9 additions & 2 deletions adafruit_featherwing/dotstar_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
import adafruit_dotstar as dotstar
from adafruit_featherwing.pixelmatrix import PixelMatrix


class DotStarFeatherWing(PixelMatrix):
"""Class representing a `DotStar FeatherWing
<https://www.adafruit.com/product/3449>`_.

The feather uses pins D13 and D11"""

def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
"""
:param pin clock: The clock pin for the featherwing
Expand All @@ -49,5 +51,10 @@ def __init__(self, clock=board.D13, data=board.D11, brightness=0.2):
super().__init__()
self.rows = 6
self.columns = 12
self._matrix = dotstar.DotStar(clock, data, self.rows * self.columns,
brightness=brightness, auto_write=False)
self._matrix = dotstar.DotStar(
clock,
data,
self.rows * self.columns,
brightness=brightness,
auto_write=False,
)
8 changes: 6 additions & 2 deletions adafruit_featherwing/gps_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
import busio
import adafruit_gps


class GPSFeatherWing:
"""Class representing an `Ultimate GPS FeatherWing
<https://www.adafruit.com/product/3133>`_.

Automatically uses the feather's UART bus."""

def __init__(self, update_period=1000, baudrate=9600):
"""
:param int update_period: (Optional) The amount of time in milliseconds between
Expand All @@ -57,8 +59,10 @@ def __init__(self, update_period=1000, baudrate=9600):
self._uart = busio.UART(board.TX, board.RX, baudrate=baudrate, timeout=timeout)
self._gps = adafruit_gps.GPS(self._uart, debug=False)
# Turn on the basic GGA and RMC info
self._gps.send_command(bytes('PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', 'utf-8'))
self._gps.send_command(bytes('PMTK220,{}'.format(update_period), 'utf-8'))
self._gps.send_command(
bytes("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", "utf-8")
)
self._gps.send_command(bytes("PMTK220,{}".format(update_period), "utf-8"))

def update(self):
"""
Expand Down
2 changes: 2 additions & 0 deletions adafruit_featherwing/ina219_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
import board
import adafruit_ina219


class INA219FeatherWing:
"""Class representing an `Adafruit INA219 FeatherWing
<https://www.adafruit.com/product/3650>`_.

Automatically uses the feather's I2C bus."""

def __init__(self, i2c=None):
if i2c is None:
i2c = board.I2C()
Expand Down
7 changes: 5 additions & 2 deletions adafruit_featherwing/joy_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ class JoyFeatherWing:
"""Class representing an `Adafruit Joy FeatherWing <https://www.adafruit.com/product/3632>`_.

Automatically uses the feather's I2C bus."""

def __init__(self, i2c=None):
if i2c is None:
i2c = board.I2C()
self._seesaw = adafruit_seesaw.seesaw.Seesaw(i2c)
self._seesaw.pin_mode_bulk(BUTTON_A | BUTTON_B | BUTTON_Y | BUTTON_X | BUTTON_SELECT,
self._seesaw.INPUT_PULLUP)
self._seesaw.pin_mode_bulk(
BUTTON_A | BUTTON_B | BUTTON_Y | BUTTON_X | BUTTON_SELECT,
self._seesaw.INPUT_PULLUP,
)

# Initialise joystick_offset
self._joystick_offset = (0, 0)
Expand Down
6 changes: 4 additions & 2 deletions adafruit_featherwing/led_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"

#pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
# pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation


class Segments:
"""Class representing an `Adafruit 14-segment AlphaNumeric FeatherWing
<https://www.adafruit.com/product/3139>`_.

Automatically uses the feather's I2C bus."""

def __init__(self):
self._segments = None

Expand Down Expand Up @@ -74,7 +76,7 @@ def fill(self, fill):
self._segments.fill(1 if fill else 0)
self._segments.show()
else:
raise ValueError('Must set to either True or False.')
raise ValueError("Must set to either True or False.")

@property
def blink_rate(self):
Expand Down
4 changes: 3 additions & 1 deletion adafruit_featherwing/matrix_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
import board
import adafruit_ht16k33.matrix as matrix


class MatrixFeatherWing:
"""Class representing an `Adafruit 8x16 LED Matrix FeatherWing
<https://www.adafruit.com/product/3155>`_.

Automatically uses the feather's I2C bus."""

def __init__(self, address=0x70, i2c=None):
if i2c is None:
i2c = board.I2C()
Expand Down Expand Up @@ -102,7 +104,7 @@ def fill(self, fill):
self._matrix.fill(1 if fill else 0)
self._update()
else:
raise ValueError('Must set to either True or False.')
raise ValueError("Must set to either True or False.")

def shift_right(self, rotate=False):
"""
Expand Down
61 changes: 44 additions & 17 deletions adafruit_featherwing/minitft_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,23 @@

Buttons = namedtuple("Buttons", "up down left right a b select")


class MiniTFTFeatherWing:
"""Class representing an `Mini Color TFT with Joystick FeatherWing
<https://www.adafruit.com/product/3321>`_.

Automatically uses the feather's I2C bus."""

_button_mask = ((1 << BUTTON_RIGHT) |
(1 << BUTTON_DOWN) |
(1 << BUTTON_LEFT) |
(1 << BUTTON_UP) |
(1 << BUTTON_SEL) |
(1 << BUTTON_A) |
(1 << BUTTON_B))
#pylint: disable-msg=too-many-arguments
_button_mask = (
(1 << BUTTON_RIGHT)
| (1 << BUTTON_DOWN)
| (1 << BUTTON_LEFT)
| (1 << BUTTON_UP)
| (1 << BUTTON_SEL)
| (1 << BUTTON_A)
| (1 << BUTTON_B)
)
# pylint: disable-msg=too-many-arguments
def __init__(self, address=0x5E, i2c=None, spi=None, cs=None, dc=None):
displayio.release_displays()
if i2c is None:
Expand All @@ -81,9 +84,11 @@ def __init__(self, address=0x5E, i2c=None, spi=None, cs=None, dc=None):
self._backlight = PWMOut(self._ss, 5)
self._backlight.duty_cycle = 0
display_bus = displayio.FourWire(spi, command=dc, chip_select=cs)
self.display = ST7735R(display_bus, width=160, height=80, colstart=24,
rotation=270, bgr=True)
#pylint: enable-msg=too-many-arguments
self.display = ST7735R(
display_bus, width=160, height=80, colstart=24, rotation=270, bgr=True
)

# pylint: enable-msg=too-many-arguments

@property
def backlight(self):
Expand All @@ -107,9 +112,31 @@ def buttons(self):
try:
button_values = self._ss.digital_read_bulk(self._button_mask)
except OSError:
return Buttons(*[False for button in
(BUTTON_UP, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT,
BUTTON_A, BUTTON_B, BUTTON_SEL)])
return Buttons(*[not button_values & (1 << button) for button in
(BUTTON_UP, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT,
BUTTON_A, BUTTON_B, BUTTON_SEL)])
return Buttons(
*[
False
for button in (
BUTTON_UP,
BUTTON_DOWN,
BUTTON_LEFT,
BUTTON_RIGHT,
BUTTON_A,
BUTTON_B,
BUTTON_SEL,
)
]
)
return Buttons(
*[
not button_values & (1 << button)
for button in (
BUTTON_UP,
BUTTON_DOWN,
BUTTON_LEFT,
BUTTON_RIGHT,
BUTTON_A,
BUTTON_B,
BUTTON_SEL,
)
]
)
16 changes: 11 additions & 5 deletions adafruit_featherwing/neopixel_featherwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
import neopixel
from adafruit_featherwing.pixelmatrix import PixelMatrix


class NeoPixelFeatherWing(PixelMatrix):
"""Class representing a `NeoPixel FeatherWing
<https://www.adafruit.com/product/2945>`_.
The feather uses pins D6 by default"""

def __init__(self, pixel_pin=board.D6, brightness=0.1):
"""
:param pin pixel_pin: The pin for the featherwing
Expand All @@ -48,9 +50,13 @@ def __init__(self, pixel_pin=board.D6, brightness=0.1):
super().__init__()
self.rows = 4
self.columns = 8
self._matrix = neopixel.NeoPixel(pixel_pin, self.rows * self.columns,
brightness=brightness, auto_write=False,
pixel_order=neopixel.GRB)
self._matrix = neopixel.NeoPixel(
pixel_pin,
self.rows * self.columns,
brightness=brightness,
auto_write=False,
pixel_order=neopixel.GRB,
)

def shift_up(self, rotate=False):
"""
Expand Down Expand Up @@ -83,7 +89,7 @@ def shift_up(self, rotate=False):
time.sleep(.1)
"""
super().shift_down(rotate) # Up and down are reversed
super().shift_down(rotate) # Up and down are reversed

def shift_down(self, rotate=False):
"""
Expand Down Expand Up @@ -116,4 +122,4 @@ def shift_down(self, rotate=False):
time.sleep(.1)
"""
super().shift_up(rotate) # Up and down are reversed
super().shift_up(rotate) # Up and down are reversed
32 changes: 22 additions & 10 deletions adafruit_featherwing/pixelmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"

#pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation
# pylint: disable-msg=unsubscriptable-object, unsupported-assignment-operation


class PixelMatrix:
"""Base Class for DotStar and NeoPixel FeatherWings

The feather uses pins D13 and D11"""

def __init__(self):
self.rows = 0
self.columns = 0
Expand Down Expand Up @@ -74,18 +76,18 @@ def _get_index(self, indices):
"""
if isinstance(indices, int):
if not 0 <= indices < self.rows * self.columns:
raise ValueError('The index of {} is out of range'.format(indices))
raise ValueError("The index of {} is out of range".format(indices))
return indices
if isinstance(indices, slice):
return indices
if len(indices) == 2:
x, y = indices
if not 0 <= x < self.columns:
raise ValueError('The X value of {} is out of range'.format(x))
raise ValueError("The X value of {} is out of range".format(x))
if not 0 <= y < self.rows:
raise ValueError('The Y value of {} is out of range'.format(y))
raise ValueError("The Y value of {} is out of range".format(y))
return y * self.columns + x
raise ValueError('Index must be 1 or 2 number')
raise ValueError("Index must be 1 or 2 number")

def _update(self):
"""
Expand Down Expand Up @@ -120,7 +122,9 @@ def shift_right(self, rotate=False):
for y in range(0, self.rows):
last_pixel = self._matrix[(y + 1) * self.columns - 1] if rotate else 0
for x in range(self.columns - 1, 0, -1):
self._matrix[y * self.columns + x] = self._matrix[y * self.columns + x - 1]
self._matrix[y * self.columns + x] = self._matrix[
y * self.columns + x - 1
]
self._matrix[y * self.columns] = last_pixel
self._update()

Expand All @@ -133,7 +137,9 @@ def shift_left(self, rotate=False):
for y in range(0, self.rows):
last_pixel = self._matrix[y * self.columns] if rotate else 0
for x in range(0, self.columns - 1):
self._matrix[y * self.columns + x] = self._matrix[y * self.columns + x + 1]
self._matrix[y * self.columns + x] = self._matrix[
y * self.columns + x + 1
]
self._matrix[(y + 1) * self.columns - 1] = last_pixel
self._update()

Expand All @@ -144,9 +150,13 @@ def shift_up(self, rotate=False):
:param rotate: (Optional) Rotate the shifted pixels to bottom (default=False)
"""
for x in range(0, self.columns):
last_pixel = self._matrix[(self.rows - 1) * self.columns + x] if rotate else 0
last_pixel = (
self._matrix[(self.rows - 1) * self.columns + x] if rotate else 0
)
for y in range(self.rows - 1, 0, -1):
self._matrix[y * self.columns + x] = self._matrix[(y - 1) * self.columns + x]
self._matrix[y * self.columns + x] = self._matrix[
(y - 1) * self.columns + x
]
self._matrix[x] = last_pixel
self._update()

Expand All @@ -159,7 +169,9 @@ def shift_down(self, rotate=False):
for x in range(0, self.columns):
last_pixel = self._matrix[x] if rotate else 0
for y in range(0, self.rows - 1):
self._matrix[y * self.columns + x] = self._matrix[(y + 1) * self.columns + x]
self._matrix[y * self.columns + x] = self._matrix[
(y + 1) * self.columns + x
]
self._matrix[(self.rows - 1) * self.columns + x] = last_pixel
self._update()

Expand Down
Loading