Skip to content

sparkfun/Qwiic_Twist_Py

Repository files navigation

Qwiic_Twist_Py

follow on Twitter

SparkFun Qwiic Twist Breakout

Python module for the qwiic twist, which is part of the SparkFun Qwiic Twist

This python package is a port of the existing SparkFun Qwiic Twist Arduino Library

This package can be used in conjunction with the overall SparkFun qwiic Python Package

New to qwiic? Take a look at the entire SparkFun qwiic ecosystem.

Contents

Dependencies

This driver package depends on the qwiic I2C driver: Qwiic_I2C_Py

Documentation

The SparkFun qwiic Twist module documentation is hosted at ReadTheDocs

Installation

PyPi Installation

This repository is hosted on PyPi as the sparkfun-qwiic-twist package. On systems that support PyPi installation via pip, this library is installed using the following commands

For all users (note: the user must have sudo privileges):

sudo pip install sparkfun-qwiic-twist

For the current user:

pip install sparkfun-qwiic-twist

Local Installation

To install, make sure the setuptools package is installed on the system.

Direct installation at the command line:

python setup.py install

To build a package for use with pip:

python setup.py sdist

A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.

cd dist
pip install sparkfun_qwiic_twist-<version>.tar.gz
  

Example Use

See the examples directory for more detailed use examples.

import qwiic_twist
import time
import sys

def runExample():

	print("\nSparkFun qwiic Twist   Example 1\n")
	myTwist = qwiic_twist.QwiicTwist()

	if myTwist.connected == False:
		print("The Qwiic twist device isn't connected to the system. Please check your connection", \
			file=sys.stderr)
		return

	myTwist.begin()

	# Set the knob color to pink
	myTwist.set_color(100, 10, 50)

	while True:

		print("Count: %d, Pressed: %s" % (myTwist.count, \
			"YES" if myTwist.pressed else "NO", \
			))

		time.sleep(.3)

if __name__ == '__main__':
	try:
		runExample()
	except (KeyboardInterrupt, SystemExit) as exErr:
		print("\nEnding Example 1")
		sys.exit(0)

SparkFun - Start Something

About

Python driver for the Qwiic Twist breakout board

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages