Skip to content

Commit 332a14a

Browse files
authored
Merge pull request #1 from kattni/linty
Lint etc for release.
2 parents 1bbee58 + a34ebd6 commit 332a14a

File tree

6 files changed

+49
-55
lines changed

6 files changed

+49
-55
lines changed

adafruit_is31fl3741/__init__.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,20 @@ def __init__(self, i2c, address=_IS3741_ADDR_DEFAULT):
7676
self._page = None
7777
self.reset()
7878

79-
8079
def reset(self):
80+
"""Reset"""
8181
self.page = 4
8282
self._reset_reg = 0xAE
8383

8484
def unlock(self):
85+
"""Unlock"""
8586
self._lock_reg = 0xC5
8687

8788
def set_led_scaling(self, scale):
89+
"""Set LED scaling.
90+
91+
param scale: The scale.
92+
"""
8893
scalebuf = [scale] * 181
8994
scalebuf[0] = 0
9095
self.page = 2
@@ -96,40 +101,40 @@ def set_led_scaling(self, scale):
96101

97102
@property
98103
def global_current(self):
104+
"""Global current"""
99105
self.page = 4
100106
return self._gcurrent_reg
101107

102108
@global_current.setter
103-
def global_current(self, gc):
109+
def global_current(self, current):
104110
self.page = 4
105-
self._gcurrent_reg = gc
106-
111+
self._gcurrent_reg = current
107112

108113
@property
109114
def enable(self):
115+
"""Enable"""
110116
self.page = 4
111117
return self._shutdown_bit
112118

113119
@enable.setter
114-
def enable(self, en):
120+
def enable(self, enable):
115121
self.page = 4
116-
self._shutdown_bit = en
117-
122+
self._shutdown_bit = enable
123+
118124
@property
119125
def page(self):
126+
"""Page"""
120127
return self._page
121128

122129
@page.setter
123-
def page(self, p):
124-
if p == self._page:
130+
def page(self, page_value):
131+
if page_value == self._page:
125132
return # already set
126-
if p > 4:
133+
if page_value > 4:
127134
raise ValueError("Page must be 0 ~ 4")
128-
self._page = p # cache
135+
self._page = page_value # cache
129136
self.unlock()
130-
self._page_reg = p
131-
132-
137+
self._page_reg = page_value
133138

134139
def __getitem__(self, led):
135140
if not 0 <= led <= 350:
@@ -142,18 +147,18 @@ def __getitem__(self, led):
142147
self._buf[0] = led - 180
143148

144149
with self.i2c_device as i2c:
145-
i2c.write_then_readinto(self._buf, self._buf,
146-
out_start=0, out_end=1,
147-
in_start=1, in_end=2)
150+
i2c.write_then_readinto(
151+
self._buf, self._buf, out_start=0, out_end=1, in_start=1, in_end=2
152+
)
148153
return self._buf[1]
149154

150155
def __setitem__(self, led, pwm):
151156
if not 0 <= led <= 350:
152157
raise ValueError("LED must be 0 ~ 350")
153158
if not 0 <= pwm <= 255:
154159
raise ValueError("PWM must be 0 ~ 255")
155-
#print(led, pwm)
156-
160+
# print(led, pwm)
161+
157162
if led < 180:
158163
self.page = 0
159164
self._buf[0] = led
@@ -170,7 +175,6 @@ def pixel_addrs(x, y):
170175
"""Calulate the offset into the device array for x,y pixel"""
171176
raise NotImplementedError("Supported in subclasses only")
172177

173-
174178
# pylint: disable-msg=too-many-arguments
175179
def pixel(self, x, y, color=None):
176180
"""
@@ -185,7 +189,7 @@ def pixel(self, x, y, color=None):
185189
if not 0 <= y <= self.height:
186190
return None
187191
addrs = self.pixel_addrs(x, y)
188-
#print(addrs)
192+
# print(addrs)
189193
if color is not None: # set the color
190194
self[addrs[0]] = (color >> 16) & 0xFF
191195
self[addrs[1]] = (color >> 8) & 0xFF
@@ -201,13 +205,11 @@ def pixel(self, x, y, color=None):
201205

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

204-
def image(self, img, blink=None, frame=None):
208+
def image(self, img):
205209
"""Set buffer to value of Python Imaging Library image. The image should
206210
be in 8-bit mode (L) and a size equal to the display size.
207211
208212
:param img: Python Imaging Library image
209-
:param blink: True to blink
210-
:param frame: the frame to set the image
211213
"""
212214
if img.mode != "RGB":
213215
raise ValueError("Image must be in mode RGB.")

adafruit_is31fl3741/adafruit_rgbmatrixqt.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,26 @@ def pixel_addrs(x, y):
4747

4848
if row <= 5:
4949
if col < 10:
50-
offset = 0x1E*row + col*3
50+
offset = 0x1E * row + col * 3
5151
else:
52-
offset = 0xB4 + 0x5A + 9*row + (col - 10)*3
52+
offset = 0xB4 + 0x5A + 9 * row + (col - 10) * 3
5353
else:
5454
if col < 10:
55-
offset = 0xB4 + (row-6)*0x1E + col*3
55+
offset = 0xB4 + (row - 6) * 0x1E + col * 3
5656
else:
57-
offset = 0xB4 + 0x5A + 9*row + (col - 10)*3
58-
59-
#print(x, ",", y, "->", hex(offset))
57+
offset = 0xB4 + 0x5A + 9 * row + (col - 10) * 3
58+
59+
# print(x, ",", y, "->", hex(offset))
6060
r_off = 0
6161
g_off = 1
6262
b_off = 2
6363
if col == 12 or col % 2 == 1: # odds + last col
6464
r_off = 2
6565
g_off = 1
6666
b_off = 0
67-
else: # evens
67+
else: # evens
6868
r_off = 0
6969
g_off = 2
7070
b_off = 1
71-
72-
return (offset+r_off, offset+g_off, offset+b_off)
71+
72+
return (offset + r_off, offset + g_off, offset + b_off)

adafruit_is31fl3741/issi_evb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ def pixel_addrs(x, y):
4444
else:
4545
offset = (x + y * 10) * 3
4646

47-
return (offset+2, offset+1, offset)
47+
return (offset + 2, offset + 1, offset)

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# Uncomment the below if you use native CircuitPython modules such as
2424
# digitalio, micropython and busio. List the modules you use. Without it, the
2525
# autodoc module docs will fail to generate with a warning.
26-
# autodoc_mock_imports = ["micropython"]
26+
autodoc_mock_imports = ["adafruit_bus_device", "adafruit_register"]
2727

2828
intersphinx_mapping = {
2929
"python": ("https://docs.python.org/3.4", None),

examples/is31fl3741_rgbswirl.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
1-
"""CircuitPython Essentials I2C Scan example"""
2-
# If you run this and it seems to hang, try manually unlocking
3-
# your I2C bus from the REPL with
4-
# >>> import board
5-
# >>> board.I2C().unlock()
1+
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
63

7-
import time
84
import board
9-
import adafruit_is31fl3741
105
from rainbowio import colorwheel
116

12-
#from adafruit_is31fl3741.issi_evb import ISSI_EVB
137
from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
148

15-
i2c = board.I2C()
16-
17-
is31 = Adafruit_RGBMatrixQT(i2c)
9+
is31 = Adafruit_RGBMatrixQT(board.I2C())
1810
is31.set_led_scaling(0xFF)
1911
is31.global_current = 0xFF
20-
#print("global current is", is31.global_current)
12+
# print("global current is", is31.global_current)
2113
is31.enable = True
22-
#print("Enabled?", is31.enable)
14+
# print("Enabled?", is31.enable)
2315

2416
wheeloffset = 0
2517
while True:
2618

27-
for y in range (9):
28-
for x in range (13):
29-
is31.pixel(x, y, colorwheel((y*13 + x)*2 + wheeloffset))
19+
for y in range(9):
20+
for x in range(13):
21+
is31.pixel(x, y, colorwheel((y * 13 + x) * 2 + wheeloffset))
3022
wheeloffset += 1

examples/is31fl3741_simpletest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
i2c = board.I2C()
99

10-
is31 = adafruit_is31fl3741.IS31FL3741(i2c)
10+
is31 = adafruit_is31fl3741.IS31FL3741(i2c)
1111

12-
is31.set_led_scaling(0xFF) # turn on LEDs all the way
13-
is31.global_current = 0xFE # set current to max
14-
is31.enable = True # enable!
12+
is31.set_led_scaling(0xFF) # turn on LEDs all the way
13+
is31.global_current = 0xFE # set current to max
14+
is31.enable = True # enable!
1515

1616
# light up every LED, one at a time
1717
while True:

0 commit comments

Comments
 (0)