Skip to content

Commit c547a1a

Browse files
committed
Updated with changes from pre-commit
1 parent 271f1bc commit c547a1a

13 files changed

+79
-80
lines changed

README.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ at `SparkFun Qwiic Relay <https://github.com/sparkfun/Qwiic_Relay>`_
2828
:alt: SparkFun Qwiic Single Relay (COM-15093)
2929

3030
`SparkFun Qwiic Single Relay (COM-15093) <https://www.sparkfun.com/products/15093>`_
31-
31+
3232

3333

3434
Dependencies
@@ -48,7 +48,7 @@ or individual libraries can be installed using
4848
Raspberry Pi Setup
4949
------------------
5050
Adafruit has an excellent tutorial on `Installing CircuitPython Libraries on Raspberry Pi <https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi/>`_.
51-
51+
5252
Quick Start Summary:
5353
--------------------
5454
* Start with the latest version of Raspbian with Wifi configured.
@@ -202,15 +202,12 @@ Then run the build:
202202
203203
License Information
204204
-----------------------
205-
This product is **open source**!
205+
This product is **open source**!
206206

207-
Please review the LICENSE.md file for license information.
207+
Please review the LICENSE.md file for license information.
208208

209-
Please use, reuse, and modify these files as you see fit.
209+
Please use, reuse, and modify these files as you see fit.
210210

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

213213
Distributed as-is; no warranty is given.
214-
215-
216-

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/examples.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,3 @@ Examples
4545
.. literalinclude:: ../examples/example6_set_relay_status.py
4646
:caption: examples/example6_set_relay_status.py
4747
:linenos:
48-

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 Relay Hookup Guide <https://learn.sparkfun.com/tutorials/qwiic-single-relay-hookup-guide>
26+
Sparkfun Qwiic Single Relay Hookup Guide <https://learn.sparkfun.com/tutorials/qwiic-single-relay-hookup-guide>
2727

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

examples/example1_basic_control.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030
# Create relay object
3131
relay = sparkfun_qwiicrelay.Sparkfun_QwiicRelay(i2c)
3232

33-
print('Qwicc Relay Example 1 Basic Control')
33+
print("Qwicc Relay Example 1 Basic Control")
3434

3535
# Check if connected
3636
if relay.connected:
37-
print('Relay connected.')
37+
print("Relay connected.")
3838
else:
39-
print('Relay does not appear to be connected. Please check wiring.')
39+
print("Relay does not appear to be connected. Please check wiring.")
4040
sys.exit()
4141

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

4444
try:
4545
while True:

examples/example2_change_i2c_address.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,54 +41,53 @@
4141
if len(sys.argv) > 1:
4242
try:
4343
# check to see if hex or decimal arguement
44-
if '0x' in sys.argv[1]:
44+
if "0x" in sys.argv[1]:
4545
i2c_address = int(sys.argv[1], 16)
4646
else:
4747
i2c_address = int(sys.argv[1])
4848
except ValueError:
49-
print('Ignoring invalid arguement: ' + str(sys.argv[1]))
49+
print("Ignoring invalid arguement: " + str(sys.argv[1]))
5050

5151
# Show the initial address
52-
print('Current i2c address = ' + str(i2c_address)
53-
+ ' [' + hex(i2c_address) + ']')
52+
print("Current i2c address = " + str(i2c_address) + " [" + hex(i2c_address) + "]")
5453

5554
# Create busio object using our Board I2C port
5655
i2c = board.I2C()
5756
relay = sparkfun_qwiicrelay.Sparkfun_QwiicRelay(i2c, i2c_address)
5857

5958
if relay.connected:
60-
print('Qwiic Relay Example.')
59+
print("Qwiic Relay Example.")
6160
else:
6261
# if we can't connecct, something is wrong so just quit
63-
print('Relay does not appear to be connected. Please check wiring.')
62+
print("Relay does not appear to be connected. Please check wiring.")
6463
sys.exit()
6564

66-
print('Address: ' + str(i2c_address) + ' [' + hex(i2c_address) + ']')
65+
print("Address: " + str(i2c_address) + " [" + hex(i2c_address) + "]")
6766

68-
text = input('Enter a new I2C address (as a decimal from 8 to 119 or hex 0x08 to 0x77):')
67+
text = input(
68+
"Enter a new I2C address (as a decimal from 8 to 119 or hex 0x08 to 0x77):"
69+
)
6970

7071
# check to see if hex or decimal value
71-
if '0x' in text:
72+
if "0x" in text:
7273
new_address = int(text, 16)
7374
else:
7475
new_address = int(text)
7576

76-
print('Changing address to ' + str(new_address)
77-
+ ' [' + hex(new_address) + ']')
77+
print("Changing address to " + str(new_address) + " [" + hex(new_address) + "]")
7878

7979
result = relay.set_i2c_address(new_address)
8080

8181
if result:
82-
print('Address changed to ' + str(new_address)
83-
+ ' [' + hex(new_address) + ']')
82+
print("Address changed to " + str(new_address) + " [" + hex(new_address) + "]")
8483
# After the change check the new connection and show firmware version
8584
if relay.connected:
86-
print('Connected to Relay after address change.')
85+
print("Connected to Relay after address change.")
8786
else:
88-
print('Error after address change. Cannot connect to Relay.')
87+
print("Error after address change. Cannot connect to Relay.")
8988

9089
else:
91-
print('Address change failed.')
90+
print("Address change failed.")
9291

9392
# good advice whether the address changed worked or not
94-
print('Run example3_i2c_scanner.py to verify the Qwiic Relay address.')
93+
print("Run example3_i2c_scanner.py to verify the Qwiic Relay address.")

examples/example3_i2c_scanner.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@
3535
# Since i2c.scan() returns all addresses above the relay address,
3636
# we look for the relay address using only write requests.
3737

38+
3839
def test_i2c_write(addr):
39-
"Write to an address to see if there's an device there"""
40+
"Write to an address to see if there's an device there" ""
4041
while not i2c.try_lock():
4142
pass
4243

4344
try:
4445
# Make an empty write request to an address
45-
i2c.writeto(addr, b'')
46+
i2c.writeto(addr, b"")
4647
return True
4748

4849
except OSError:
@@ -53,7 +54,7 @@ def test_i2c_write(addr):
5354
i2c.unlock()
5455

5556

56-
print('Press Ctrl-C to exit program')
57+
print("Press Ctrl-C to exit program")
5758

5859
try:
5960
while True:
@@ -65,10 +66,12 @@ def test_i2c_write(addr):
6566
found.append(address)
6667

6768
if found:
68-
print('I2C addresses found:',
69-
[hex(device_address) for device_address in found])
69+
print(
70+
"I2C addresses found:",
71+
[hex(device_address) for device_address in found],
72+
)
7073
else:
71-
print('No I2C device found.')
74+
print("No I2C device found.")
7275

7376
# wait a bit and scan again
7477
sleep(5)

examples/example4_get_relay_status.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,24 @@
3232
# Create relay object
3333
relay = sparkfun_qwiicrelay.Sparkfun_QwiicRelay(i2c)
3434

35-
print('Qwiic Relay Example 4 Get Relay Status')
35+
print("Qwiic Relay Example 4 Get Relay Status")
3636

3737
# Check if connected
3838
if relay.connected:
39-
print('Relay connected.')
39+
print("Relay connected.")
4040
else:
41-
print('Relay does not appear to be connected. Please check wiring.')
41+
print("Relay does not appear to be connected. Please check wiring.")
4242
sys.exit()
4343

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

4646
try:
4747
while True:
4848
relay.relay_on()
49-
print('The relay status is ', relay.status)
49+
print("The relay status is ", relay.status)
5050
sleep(2)
5151
relay.relay_off()
52-
print('The relay status is ', relay.status)
52+
print("The relay status is ", relay.status)
5353
sleep(2)
5454

5555
except KeyboardInterrupt:

examples/example5_get_firmware_version.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@
3333
# Create relay object
3434
relay = sparkfun_qwiicrelay.Sparkfun_QwiicRelay(i2c)
3535

36-
print('Qwicc Relay Example 5 Get Firmware Version')
36+
print("Qwicc Relay Example 5 Get Firmware Version")
3737

3838
# Check if connected
3939
if relay.connected:
40-
print('Relay connected.')
40+
print("Relay connected.")
4141
else:
42-
print('Relay does not appear to be connected. Please check wiring.')
42+
print("Relay does not appear to be connected. Please check wiring.")
4343
sys.exit()
4444

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

4747
try:
4848
while True:
49-
print('Firmware version: ' + relay.version)
49+
print("Firmware version: " + relay.version)
5050
sleep(2)
5151

5252
except KeyboardInterrupt:

examples/example6_set_relay_status.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,27 @@
3030
# Create relay object
3131
relay = sparkfun_qwiicrelay.Sparkfun_QwiicRelay(i2c)
3232

33-
print('Qwiic Relay Example 6 Set Relay Status')
33+
print("Qwiic Relay Example 6 Set Relay Status")
3434

3535
# Check if connected
3636
if relay.connected:
37-
print('Relay connected.')
37+
print("Relay connected.")
3838
else:
39-
print('Relay does not appear to be connected. Please check wiring.')
39+
print("Relay does not appear to be connected. Please check wiring.")
4040
sys.exit()
4141

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

4444
try:
4545
while True:
4646
# Set status = 1/True is the same as relay.relay_on()
4747
relay.status = True
48-
print('The relay status is', bool(relay.status))
48+
print("The relay status is", bool(relay.status))
4949
sleep(2)
5050

5151
# Set status = 0/False is the same as relay.relay_off()
5252
relay.status = False
53-
print('The relay status is', bool(relay.status))
53+
print("The relay status is", bool(relay.status))
5454
sleep(2)
5555

5656
except KeyboardInterrupt:

examples/qwiicrelay_simpletest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@
2929

3030
# Check if connected
3131
if relay.connected:
32-
print('Relay connected.')
32+
print("Relay connected.")
3333
else:
34-
print('Relay does not appear to be connected. Please check wiring.')
34+
print("Relay does not appear to be connected. Please check wiring.")
3535
sys.exit()
3636

3737
# Print firmware version and current status
38-
print('Firmware version ' + relay.version)
39-
print('Relay status ', relay.status)
38+
print("Firmware version " + relay.version)
39+
print("Relay status ", relay.status)
4040

4141
# Turn the relay on and off
42-
print('Press Ctrl-C to exit program')
42+
print("Press Ctrl-C to exit program")
4343
while True:
4444
relay.relay_on()
45-
print('Relay status ', relay.status)
45+
print("Relay status ", relay.status)
4646
sleep(2)
4747
relay.relay_off()
48-
print('Relay status ', relay.status)
48+
print("Relay status ", relay.status)
4949
sleep(2)

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
],
5959
# What does your project relate to?
6060
keywords="adafruit blinka circuitpython micropython qwiicrelay sparkfun qwiic relay",
61-
6261
# You can just specify the packages manually here if your project is
6362
# simple. Or you can use find_packages().
6463
# IF LIBRARY FILES ARE A PACKAGE FOLDER,

0 commit comments

Comments
 (0)