Qwiic_Dual_Encoder_Reader_Py

follow on Twitter

SparkFun Auto pHAT for Raspberry Pi

Python module for the qwiic dual encoder reader (ATTINY84), which is included on the SparkFun Auto pHAT for Raspberry Pi

This python package enables the user to take count readings from the on-board ATTINY84 that handles reading the dual motor encoders. The firmware that is used on the ATTiny84 is located in a separate repository here: SparkFun Dual Encoder Reader Firmware Repository

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.

Supported Platforms

The qwiic ICM20948 Python package current supports the following platforms:

Dependencies

This driver package depends on the qwiic I2C driver: Qwiic_I2C_Py

Documentation

The SparkFun qwiic Dual Encoder Reader documentation is hosted at ReadTheDocs

Installation

PyPi Installation

This repository is hosted on PyPi as the sparkfun-qwiic-dual-encoder-reader 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-dual-encoder-reader

For the current user:

pip install sparkfun-qwiic-dual-encoder-reader

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_dual_encoder_reader-<version>.tar.gz

Example Use

See the examples directory for more detailed use examples.

from __future__ import print_function
import qwiic_dual_encoder_reader
import time
import sys

def runExample():

    print("\nSparkFun Qwiic Dual Encoder Reader   Example 1\n")
    myEncoders = qwiic_dual_encoder_reader.QwiicDualEncoderReader()

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

    myEncoders.begin()

    while True:

        print("Count1: %d, Count2: %s" % (myEncoders.count1, \
            myEncoders.count2, \
            ))

        time.sleep(.3)

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

SparkFun - Start Something

Indices and tables