Skip to content

Updated files from Black and Pylint #12

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
Nov 13, 2021
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
13 changes: 5 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ CircuitPython library for Sparkfun Qwiic Twist RGB Rotary Encoder. This library
:alt: SparkFun Qwiic Twist RGB Rotary Encorder (DEV-15083)

`SparkFun Qwiic Twist RGB Rotary Encoder (DEV-15083) <https://www.sparkfun.com/products/15083>`_

Dependencies
=============
This driver depends on:
Expand All @@ -47,7 +47,7 @@ Raspberry Pi Setup
------------------
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/>`_.

Quick Start Summary:

* Start with the latest version of Raspbian with Wifi configured.
Expand Down Expand Up @@ -197,15 +197,12 @@ Then run the build:

License Information
-----------------------
This product is **open source**!
This product is **open source**!

Please review the LICENSE.md file for license information.
Please review the LICENSE.md file for license information.

Please use, reuse, and modify these files as you see fit.
Please use, reuse, and modify these files as you see fit.

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

Distributed as-is; no warranty is given.



7 changes: 5 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@


intersphinx_mapping = {
"python": ("https://docs.python.org/3.4", None),"BusDevice": ("https://circuitpython.readthedocs.io/projects/busdevice/en/latest/", None),

"python": ("https://docs.python.org/3.4", None),
"BusDevice": (
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
None,
),
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
}

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Table of Contents
.. toctree::
:caption: Tutorials

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

.. toctree::
:caption: Related Products
Expand Down
16 changes: 11 additions & 5 deletions examples/example10_i2c_scanner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
#
# SPDX-License-Identifier: MIT

# This is example is for the SparkFun Qwiic Twist.
# SparkFun sells these at its website: www.sparkfun.com
# Do you like this library? Help support SparkFun. Buy a board!
Expand All @@ -19,19 +24,20 @@
import time

import board
import busio

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()

while not i2c.try_lock():
pass

print('Press Ctrl-C to exit program')
print("Press Ctrl-C to exit program")

try:
while True:
print('I2C addresses found:',
[hex(device_address) for device_address in i2c.scan()])
print(
"I2C addresses found:",
[hex(device_address) for device_address in i2c.scan()],
)
time.sleep(5)
except KeyboardInterrupt:
pass
Expand Down
23 changes: 13 additions & 10 deletions examples/example1_basic_readings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
#
# SPDX-License-Identifier: MIT

# This is example is for the SparkFun Qwiic Single Twist.
# SparkFun sells these at its website: www.sparkfun.com
# Do you like this library? Help support SparkFun. Buy a board!
Expand All @@ -15,34 +19,33 @@
control the Qwiic Twist RGB Rotrary Encoder over I2C and print
the number of steps the encoder has been twisted.
"""

import sys
from time import sleep
import board
import busio
import sparkfun_qwiictwist

# Create bus object using our board's I2C port
i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()

# Create twist object
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)

print('Qwicc Twist Example 1 Basic Readings')
print("Qwicc Twist Example 1 Basic Readings")

# Check if connected
if twist.connected:
print('Twist connected.')
print("Twist connected.")
else:
print('Twist does not appear to be connected. Please check wiring.')
exit()
print("Twist does not appear to be connected. Please check wiring.")
sys.exit()

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

try:
while True:
print('Count: ' + str(twist.count))
print("Count: " + str(twist.count))
if twist.pressed:
print('Pressed!')
print("Pressed!")
sleep(0.5)

except KeyboardInterrupt:
Expand Down
27 changes: 15 additions & 12 deletions examples/example2_set_color.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
#
# SPDX-License-Identifier: MIT

# This is example is for the SparkFun Qwiic Single Twist.
# SparkFun sells these at its website: www.sparkfun.com
# Do you like this library? Help support SparkFun. Buy a board!
Expand All @@ -16,28 +20,27 @@
the knob color to pink. This value is stored in the Qwiic Twist
and will be loaded after each power-on.
"""

import sys
from time import sleep
import board
import busio
import sparkfun_qwiictwist

# Create bus object using our board's I2C port
i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()

# Create twist object
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)

print('Qwicc Twist Example 2 Set Color')
print("Qwicc Twist Example 2 Set Color")

# Check if connected
if twist.connected:
print('Twist connected.')
print("Twist connected.")
else:
print('Twist does not appear to be connected. Please check wiring.')
exit()
print("Twist does not appear to be connected. Please check wiring.")
sys.exit()

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

# Turn off any color connections
twist.connect_color(0, 0, 0)
Expand All @@ -50,17 +53,17 @@

try:
while True:
print('Count: ' + str(twist.count))
print("Count: " + str(twist.count))
if twist.pressed:
print('Pressed!')
print("Pressed!")
if is_pink:
# Set the knob color to blue (r =10, g=10, b=100)
print('Change color to blue.')
print("Change color to blue.")
twist.set_color(10, 10, 100)
is_pink = False
else:
# Set the knob color to pink (r =100, g=10, b=50)
print('Change color to pink.')
print("Change color to pink.")
twist.set_color(100, 10, 50)
is_pink = True

Expand Down
23 changes: 13 additions & 10 deletions examples/example3_crazy_color.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
#
# SPDX-License-Identifier: MIT

# This is example is for the SparkFun Qwiic Single Twist.
# SparkFun sells these at its website: www.sparkfun.com
# Do you like this library? Help support SparkFun. Buy a board!
Expand All @@ -15,39 +19,38 @@
control the Qwiic Twist RGB Rotrary Encoder over I2C to set
the knob color to an endless number of random colors.
"""

import sys
from time import sleep
import random

import board
import busio
import sparkfun_qwiictwist

# Create bus object using our board's I2C port
i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()

# Create twist object
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)

print('Qwicc Twist Example 3 Crazy Color')
print("Qwicc Twist Example 3 Crazy Color")

# Check if connected
if twist.connected:
print('Twist connected.')
print("Twist connected.")
else:
print('Twist does not appear to be connected. Please check wiring.')
exit()
print("Twist does not appear to be connected. Please check wiring.")
sys.exit()

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

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

try:
while True:
print('Count: ' + str(twist.count))
print("Count: " + str(twist.count))
if twist.pressed:
print('Pressed!')
print("Pressed!")

# Generate a random rgb value
red = random.randint(0, 256)
Expand Down
25 changes: 14 additions & 11 deletions examples/example4_connect_colors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
#
# SPDX-License-Identifier: MIT

# This is example is for the SparkFun Qwiic Single Twist.
# SparkFun sells these at its website: www.sparkfun.com
# Do you like this library? Help support SparkFun. Buy a board!
Expand All @@ -21,33 +25,32 @@
increase the blue value with each tick. These values are stored
in the Qwiic Twist and will be loaded after each power-on.
"""

import sys
from time import sleep
import board
import busio
import sparkfun_qwiictwist

# Create bus object using our board's I2C port
i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()

# Create twist object
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)

print('Qwicc Twist Example 4 Connect Colors')
print("Qwicc Twist Example 4 Connect Colors")

# Check if connected
if twist.connected:
print('Twist connected.')
print("Twist connected.")
else:
print('Twist does not appear to be connected. Please check wiring.')
exit()
print("Twist does not appear to be connected. Please check wiring.")
sys.exit()

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

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

#Set the individual color connections
# Set the individual color connections

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

try:
while True:
print('Count: ' + str(twist.count))
print("Count: " + str(twist.count))
if twist.pressed:
print('Pressed!')
print("Pressed!")
sleep(0.5)

except KeyboardInterrupt:
Expand Down
27 changes: 15 additions & 12 deletions examples/example5_timestamps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 Gaston Williams
#
# SPDX-License-Identifier: MIT

# This is example is for the SparkFun Qwiic Single Twist.
# SparkFun sells these at its website: www.sparkfun.com
# Do you like this library? Help support SparkFun. Buy a board!
Expand All @@ -20,38 +24,37 @@
often and when the isMoved or isClick goes true, then read the
timestamp and you'll know when the user did their thing.
"""

import sys
from time import sleep
import board
import busio
import sparkfun_qwiictwist

# Create bus object using our board's I2C port
i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()

# Create twist object
twist = sparkfun_qwiictwist.Sparkfun_QwiicTwist(i2c)

print('Qwicc Twist Example 5 Timestamps')
print("Qwicc Twist Example 5 Timestamps")

# Check if connected
if twist.connected:
print('Twist connected.')
print("Twist connected.")
else:
print('Twist does not appear to be connected. Please check wiring.')
exit()
print("Twist does not appear to be connected. Please check wiring.")
sys.exit()

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

try:
while True:
print('Count: ' + str(twist.count))
print("Count: " + str(twist.count))
if twist.moved:
print('Last Twist time: ' + str(twist.time_since_last_movement))
print("Last Twist time: " + str(twist.time_since_last_movement))
if twist.clicked:
print('Last Button time: ' + str(twist.time_since_last_press))
print("Last Button time: " + str(twist.time_since_last_press))
if twist.pressed:
print('Pressed!')
print("Pressed!")
sleep(1)

except KeyboardInterrupt:
Expand Down
Loading