Skip to content

Commit 8b20eea

Browse files
committed
lint && black
1 parent 9b0033c commit 8b20eea

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

adafruit_seesaw/seesaw.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,18 @@ def __init__(self, i2c_bus, addr=0x49, drdy=None, reset=True):
150150
self.sw_reset()
151151

152152
self.chip_id = self.read8(_STATUS_BASE, _STATUS_HW_ID)
153-
if self.chip_id not in (_ATTINY806_HW_ID_CODE,_ATTINY807_HW_ID_CODE,
154-
_ATTINY816_HW_ID_CODE,_ATTINY817_HW_ID_CODE,
155-
_ATTINY1616_HW_ID_CODE,_ATTINY1617_HW_ID_CODE,
156-
_SAMD09_HW_ID_CODE):
153+
if self.chip_id not in (
154+
_ATTINY806_HW_ID_CODE,
155+
_ATTINY807_HW_ID_CODE,
156+
_ATTINY816_HW_ID_CODE,
157+
_ATTINY817_HW_ID_CODE,
158+
_ATTINY1616_HW_ID_CODE,
159+
_ATTINY1617_HW_ID_CODE,
160+
_SAMD09_HW_ID_CODE,
161+
):
157162
raise RuntimeError(
158-
"Seesaw hardware ID returned (0x{:x}) is not "
159-
"correct! Please check your wiring.".format(self.chip_id,)
163+
f"Seesaw hardware ID returned 0x{self.chip_id} is not "
164+
"correct! Please check your wiring."
160165
)
161166

162167
pid = self.get_version() >> 16
@@ -169,20 +174,22 @@ def __init__(self, i2c_bus, addr=0x49, drdy=None, reset=True):
169174
from adafruit_seesaw.robohat import MM1_Pinmap
170175

171176
self.pin_mapping = MM1_Pinmap
172-
elif (pid in (_5690_PID, _5681_PID, _5743_PID)) or (self.chip_id in
173-
(_ATTINY816_HW_ID_CODE,
174-
_ATTINY806_HW_ID_CODE,
175-
_ATTINY1616_HW_ID_CODE)):
177+
elif (pid in (_5690_PID, _5681_PID, _5743_PID)) or (
178+
self.chip_id
179+
in (_ATTINY816_HW_ID_CODE, _ATTINY806_HW_ID_CODE, _ATTINY1616_HW_ID_CODE)
180+
):
176181
from adafruit_seesaw.attinyx16 import ATtinyx16_Pinmap
177182

178183
self.pin_mapping = ATtinyx16_Pinmap
179184
elif self.chip_id == _SAMD09_HW_ID_CODE:
180185
from adafruit_seesaw.samd09 import SAMD09_Pinmap
181186

182187
self.pin_mapping = SAMD09_Pinmap
183-
elif self.chip_id in (_ATTINY817_HW_ID_CODE,
184-
_ATTINY807_HW_ID_CODE,
185-
_ATTINY1617_HW_ID_CODE):
188+
elif self.chip_id in (
189+
_ATTINY817_HW_ID_CODE,
190+
_ATTINY807_HW_ID_CODE,
191+
_ATTINY1617_HW_ID_CODE,
192+
):
186193
from adafruit_seesaw.attiny8x7 import ATtiny8x7_Pinmap
187194

188195
self.pin_mapping = ATtiny8x7_Pinmap

examples/seesaw_quadrotary.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
import adafruit_seesaw.rotaryio
1111
import adafruit_seesaw.digitalio
1212

13-
# For use with the STEMMA connector on QT Py RP2040
14-
import busio
15-
from adafruit_debug_i2c import DebugI2C
16-
1713
# For boards/chips that don't handle clock-stretching well, try running I2C at 50KHz
18-
i2c = busio.I2C(board.SCL, board.SDA, frequency=50000)
19-
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
14+
# import busio
15+
# i2c = busio.I2C(board.SCL, board.SDA, frequency=50000)
16+
# For using the built-in STEMMA QT connector on a microcontroller
17+
i2c = board.STEMMA_I2C()
2018
seesaw = adafruit_seesaw.seesaw.Seesaw(i2c, 0x49)
2119

2220
encoders = [adafruit_seesaw.rotaryio.IncrementalEncoder(seesaw, n) for n in range(4)]
@@ -35,14 +33,15 @@
3533
# negate the position to make clockwise rotation positive
3634
positions = [encoder.position for encoder in encoders]
3735
print(positions)
38-
continue
3936
for n, rotary_pos in enumerate(positions):
4037
if rotary_pos != last_positions[n]:
4138
print(f"Rotary #{n}: {rotary_pos}")
4239
last_positions[n] = rotary_pos
4340

44-
if switches[n].value: # Change the LED color if switch is not pressed
45-
if rotary_pos > last_positions[n]: # Advance forward through the colorwheel.
41+
if switches[n].value: # Change the LED color if switch is not pressed
42+
if (
43+
rotary_pos > last_positions[n]
44+
): # Advance forward through the colorwheel.
4645
colors[n] += 8
4746
else:
4847
colors[n] -= 8 # Advance backward through the colorwheel.

0 commit comments

Comments
 (0)