Skip to content

Commit 57e186f

Browse files
committed
updated from pylint
1 parent 4f8dbbb commit 57e186f

16 files changed

+230
-199
lines changed

README.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ CircuitPython library for Sparkfun Qwiic Twist RGB Rotary Encoder. This library
2828
:alt: SparkFun Qwiic Twist RGB Rotary Encorder (DEV-15083)
2929

3030
`SparkFun Qwiic Twist RGB Rotary Encoder (DEV-15083) <https://www.sparkfun.com/products/15083>`_
31-
31+
3232
Dependencies
3333
=============
3434
This driver depends on:
@@ -47,7 +47,7 @@ Raspberry Pi Setup
4747
------------------
4848
Adafruit has an excellent tutorial on `Installing CircuitPython Libraries on Raspberry Pi
4949
<https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi/>`_.
50-
50+
5151
Quick Start Summary:
5252

5353
* Start with the latest version of Raspbian with Wifi configured.
@@ -197,15 +197,12 @@ Then run the build:
197197
198198
License Information
199199
-----------------------
200-
This product is **open source**!
200+
This product is **open source**!
201201

202-
Please review the LICENSE.md file for license information.
202+
Please review the LICENSE.md file for license information.
203203

204-
Please use, reuse, and modify these files as you see fit.
204+
Please use, reuse, and modify these files as you see fit.
205205

206206
Please maintain the attributions to SparkFun Electronics and Adafruit and release any derivative under the same license.
207207

208208
Distributed as-is; no warranty is given.
209-
210-
211-

docs/conf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@
2828

2929

3030
intersphinx_mapping = {
31-
"python": ("https://docs.python.org/3.4", None),"BusDevice": ("https://circuitpython.readthedocs.io/projects/busdevice/en/latest/", None),
32-
31+
"python": ("https://docs.python.org/3.4", None),
32+
"BusDevice": (
33+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
34+
None,
35+
),
3336
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
3437
}
3538

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26-
Sparkfun Qwiic Single Twist Hookup Guide <https://learn.sparkfun.com/tutorials/qwiic-twist-hookup-guide>
26+
Sparkfun Qwiic Single Twist Hookup Guide <https://learn.sparkfun.com/tutorials/qwiic-twist-hookup-guide>
2727

2828
.. toctree::
2929
:caption: Related Products

examples/example10_i2c_scanner.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2+
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
3+
#
4+
# SPDX-License-Identifier: MIT
5+
16
# This is example is for the SparkFun Qwiic Twist.
27
# SparkFun sells these at its website: www.sparkfun.com
38
# Do you like this library? Help support SparkFun. Buy a board!
@@ -19,19 +24,20 @@
1924
import time
2025

2126
import board
22-
import busio
2327

24-
i2c = busio.I2C(board.SCL, board.SDA)
28+
i2c = board.I2C()
2529

2630
while not i2c.try_lock():
2731
pass
2832

29-
print('Press Ctrl-C to exit program')
33+
print("Press Ctrl-C to exit program")
3034

3135
try:
3236
while True:
33-
print('I2C addresses found:',
34-
[hex(device_address) for device_address in i2c.scan()])
37+
print(
38+
"I2C addresses found:",
39+
[hex(device_address) for device_address in i2c.scan()],
40+
)
3541
time.sleep(5)
3642
except KeyboardInterrupt:
3743
pass

examples/example1_basic_readings.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
2+
#
3+
# SPDX-License-Identifier: MIT
4+
15
# This is example is for the SparkFun Qwiic Single Twist.
26
# SparkFun sells these at its website: www.sparkfun.com
37
# Do you like this library? Help support SparkFun. Buy a board!
@@ -15,34 +19,33 @@
1519
control the Qwiic Twist RGB Rotrary Encoder over I2C and print
1620
the number of steps the encoder has been twisted.
1721
"""
18-
22+
import sys
1923
from time import sleep
2024
import board
21-
import busio
2225
import sparkfun_qwiictwist
2326

2427
# Create bus object using our board's I2C port
25-
i2c = busio.I2C(board.SCL, board.SDA)
28+
i2c = board.I2C()
2629

2730
# Create twist object
2831
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)
2932

30-
print('Qwicc Twist Example 1 Basic Readings')
33+
print("Qwicc Twist Example 1 Basic Readings")
3134

3235
# Check if connected
3336
if twist.connected:
34-
print('Twist connected.')
37+
print("Twist connected.")
3538
else:
36-
print('Twist does not appear to be connected. Please check wiring.')
37-
exit()
39+
print("Twist does not appear to be connected. Please check wiring.")
40+
sys.exit()
3841

39-
print('Type Ctrl-C to exit program.')
42+
print("Type Ctrl-C to exit program.")
4043

4144
try:
4245
while True:
43-
print('Count: ' + str(twist.count))
46+
print("Count: " + str(twist.count))
4447
if twist.pressed:
45-
print('Pressed!')
48+
print("Pressed!")
4649
sleep(0.5)
4750

4851
except KeyboardInterrupt:

examples/example2_set_color.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
2+
#
3+
# SPDX-License-Identifier: MIT
4+
15
# This is example is for the SparkFun Qwiic Single Twist.
26
# SparkFun sells these at its website: www.sparkfun.com
37
# Do you like this library? Help support SparkFun. Buy a board!
@@ -16,28 +20,27 @@
1620
the knob color to pink. This value is stored in the Qwiic Twist
1721
and will be loaded after each power-on.
1822
"""
19-
23+
import sys
2024
from time import sleep
2125
import board
22-
import busio
2326
import sparkfun_qwiictwist
2427

2528
# Create bus object using our board's I2C port
26-
i2c = busio.I2C(board.SCL, board.SDA)
29+
i2c = board.I2C()
2730

2831
# Create twist object
2932
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)
3033

31-
print('Qwicc Twist Example 2 Set Color')
34+
print("Qwicc Twist Example 2 Set Color")
3235

3336
# Check if connected
3437
if twist.connected:
35-
print('Twist connected.')
38+
print("Twist connected.")
3639
else:
37-
print('Twist does not appear to be connected. Please check wiring.')
38-
exit()
40+
print("Twist does not appear to be connected. Please check wiring.")
41+
sys.exit()
3942

40-
print('Type Ctrl-C to exit program.')
43+
print("Type Ctrl-C to exit program.")
4144

4245
# Turn off any color connections
4346
twist.connect_color(0, 0, 0)
@@ -50,17 +53,17 @@
5053

5154
try:
5255
while True:
53-
print('Count: ' + str(twist.count))
56+
print("Count: " + str(twist.count))
5457
if twist.pressed:
55-
print('Pressed!')
58+
print("Pressed!")
5659
if is_pink:
5760
# Set the knob color to blue (r =10, g=10, b=100)
58-
print('Change color to blue.')
61+
print("Change color to blue.")
5962
twist.set_color(10, 10, 100)
6063
is_pink = False
6164
else:
6265
# Set the knob color to pink (r =100, g=10, b=50)
63-
print('Change color to pink.')
66+
print("Change color to pink.")
6467
twist.set_color(100, 10, 50)
6568
is_pink = True
6669

examples/example3_crazy_color.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
2+
#
3+
# SPDX-License-Identifier: MIT
4+
15
# This is example is for the SparkFun Qwiic Single Twist.
26
# SparkFun sells these at its website: www.sparkfun.com
37
# Do you like this library? Help support SparkFun. Buy a board!
@@ -15,39 +19,38 @@
1519
control the Qwiic Twist RGB Rotrary Encoder over I2C to set
1620
the knob color to an endless number of random colors.
1721
"""
18-
22+
import sys
1923
from time import sleep
2024
import random
2125

2226
import board
23-
import busio
2427
import sparkfun_qwiictwist
2528

2629
# Create bus object using our board's I2C port
27-
i2c = busio.I2C(board.SCL, board.SDA)
30+
i2c = board.I2C()
2831

2932
# Create twist object
3033
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)
3134

32-
print('Qwicc Twist Example 3 Crazy Color')
35+
print("Qwicc Twist Example 3 Crazy Color")
3336

3437
# Check if connected
3538
if twist.connected:
36-
print('Twist connected.')
39+
print("Twist connected.")
3740
else:
38-
print('Twist does not appear to be connected. Please check wiring.')
39-
exit()
41+
print("Twist does not appear to be connected. Please check wiring.")
42+
sys.exit()
4043

41-
print('Type Ctrl-C to exit program.')
44+
print("Type Ctrl-C to exit program.")
4245

4346
# Turn off any color connections
4447
twist.connect_color(0, 0, 0)
4548

4649
try:
4750
while True:
48-
print('Count: ' + str(twist.count))
51+
print("Count: " + str(twist.count))
4952
if twist.pressed:
50-
print('Pressed!')
53+
print("Pressed!")
5154

5255
# Generate a random rgb value
5356
red = random.randint(0, 256)

examples/example4_connect_colors.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
2+
#
3+
# SPDX-License-Identifier: MIT
4+
15
# This is example is for the SparkFun Qwiic Single Twist.
26
# SparkFun sells these at its website: www.sparkfun.com
37
# Do you like this library? Help support SparkFun. Buy a board!
@@ -21,33 +25,32 @@
2125
increase the blue value with each tick. These values are stored
2226
in the Qwiic Twist and will be loaded after each power-on.
2327
"""
24-
28+
import sys
2529
from time import sleep
2630
import board
27-
import busio
2831
import sparkfun_qwiictwist
2932

3033
# Create bus object using our board's I2C port
31-
i2c = busio.I2C(board.SCL, board.SDA)
34+
i2c = board.I2C()
3235

3336
# Create twist object
3437
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)
3538

36-
print('Qwicc Twist Example 4 Connect Colors')
39+
print("Qwicc Twist Example 4 Connect Colors")
3740

3841
# Check if connected
3942
if twist.connected:
40-
print('Twist connected.')
43+
print("Twist connected.")
4144
else:
42-
print('Twist does not appear to be connected. Please check wiring.')
43-
exit()
45+
print("Twist does not appear to be connected. Please check wiring.")
46+
sys.exit()
4447

45-
print('Type Ctrl-C to exit program.')
48+
print("Type Ctrl-C to exit program.")
4649

4750
# Set Red and Blue LED brightnesses to half of max.
4851
twist.set_color(128, 0, 128)
4952

50-
#Set the individual color connections
53+
# Set the individual color connections
5154

5255
# Red LED will go down 10 in brightness with each encoder tick
5356
twist.red_connection = -10
@@ -59,9 +62,9 @@
5962

6063
try:
6164
while True:
62-
print('Count: ' + str(twist.count))
65+
print("Count: " + str(twist.count))
6366
if twist.pressed:
64-
print('Pressed!')
67+
print("Pressed!")
6568
sleep(0.5)
6669

6770
except KeyboardInterrupt:

examples/example5_timestamps.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
2+
#
3+
# SPDX-License-Identifier: MIT
4+
15
# This is example is for the SparkFun Qwiic Single Twist.
26
# SparkFun sells these at its website: www.sparkfun.com
37
# Do you like this library? Help support SparkFun. Buy a board!
@@ -20,38 +24,37 @@
2024
often and when the isMoved or isClick goes true, then read the
2125
timestamp and you'll know when the user did their thing.
2226
"""
23-
27+
import sys
2428
from time import sleep
2529
import board
26-
import busio
2730
import sparkfun_qwiictwist
2831

2932
# Create bus object using our board's I2C port
30-
i2c = busio.I2C(board.SCL, board.SDA)
33+
i2c = board.I2C()
3134

3235
# Create twist object
3336
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)
3437

35-
print('Qwicc Twist Example 5 Timestamps')
38+
print("Qwicc Twist Example 5 Timestamps")
3639

3740
# Check if connected
3841
if twist.connected:
39-
print('Twist connected.')
42+
print("Twist connected.")
4043
else:
41-
print('Twist does not appear to be connected. Please check wiring.')
42-
exit()
44+
print("Twist does not appear to be connected. Please check wiring.")
45+
sys.exit()
4346

44-
print('Type Ctrl-C to exit program.')
47+
print("Type Ctrl-C to exit program.")
4548

4649
try:
4750
while True:
48-
print('Count: ' + str(twist.count))
51+
print("Count: " + str(twist.count))
4952
if twist.moved:
50-
print('Last Twist time: ' + str(twist.time_since_last_movement))
53+
print("Last Twist time: " + str(twist.time_since_last_movement))
5154
if twist.clicked:
52-
print('Last Button time: ' + str(twist.time_since_last_press))
55+
print("Last Button time: " + str(twist.time_since_last_press))
5356
if twist.pressed:
54-
print('Pressed!')
57+
print("Pressed!")
5558
sleep(1)
5659

5760
except KeyboardInterrupt:

0 commit comments

Comments
 (0)